Index Structure.

Slides:



Advertisements
Similar presentations
1 Constraints, Triggers and Active Databases Chapter 9.
Advertisements

SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Physical Database Design CIT alternate keys - named constraints - indexes.
SQL Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
Introduction to Database Systems
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
R ELATIONAL D ATA M ODEL Joe Meehean 1. R ELATIONAL D ATA M ODEL Data stored as a set of relations really just tables Tables related to one another through.
DBMS Spring 2014 Database Integrity Sources: Security in Computing, Pfleeger and Pfleeger, Prentice Hall, 2003 Lecture Slides, CSE6243, MSU, Rayford B.
Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber.
SQL 101 for Web Developers 14 November What is a database and why have one? Tables, relationships, normalization SQL – What SQL is and isn’t – CRUD:
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Constraints, Triggers and Index James Wang.
Chapter No 4 Query optimization and Data Integrity & Security.
Constraints and Triggers. What’s IC? Integrity Constraints define the valid states of SQL-data by constraining the values in the base tables. –Restrictions.
INCLUDING CONSTRAINTS lecture5. Outlines  What are Constraints ?  Constraint Guidelines  Defining Constraint  NOT NULL constraint  Unique constraint.
Indexes and Views Unit 7.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
Description and exemplification use of a Data Dictionary. A data dictionary is a catalogue of all data items in a system. The data dictionary stores details.
Chapter 3: Relational Databases
Table Structures and Indexing. The concept of indexing If you were asked to search for the name “Adam Wilbert” in a phonebook, you would go directly to.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Fundamentals of DBMS Notes-1.
Rob Gleasure robgleasure.com
Fundamental of Database Systems
Databases.
Logical DB Design: ER to Relational
Translating ER into Relations; Normalization
Data Indexing Herbert A. Evans.
Rob Gleasure robgleasure.com
CS320 Web and Internet Programming SQL and MySQL
Indices.
INLS 623– Database Systems II– File Structures, Indexing, and Hashing
The Basics of Data Manipulation
Chapter 6 - Database Implementation and Use
Indices.
Constraints and Triggers
COMP 430 Intro. to Database Systems
Persistence Database Management Systems
Translation of ER-diagram into Relational Schema
SQL – Column constraints
Lecturer: Mukhtar Mohamed Ali “Hakaale”
The Relational Model Relational Data Model
Relational Databases The Relational Model.
Relational Databases The Relational Model.
Physical Database Design
The Basics of Data Manipulation
Constraints.
SQL data definition using Oracle
For student, require values for name and address.
Chapter 4 Indexes.
CH 4 Indexes.
Index Use Cases.
SQL DATA CONSTRAINTS.
CH 4 Indexes.
Unit I-2.
CS3220 Web and Internet Programming SQL and MySQL
A Very Brief Introduction to Relational Databases
CS3220 Web and Internet Programming SQL and MySQL
Instructor: Samia arshad
Indexes and Performance
Including Constraints
កម្មវិធីបង្រៀន SQL Programming ជាភាសាខ្មែរ Online SQL Training Course
CSC 453 Database Systems Lecture
Database 2.
Presentation transcript:

Index Structure

Logical vs. Physical Indices Physical indices map a key to a physical address. A physical address is an actual location in the hardware (a memory address or cylinder/disk/block on a hard drive). Logical indices instead map keys to the Primary Key of a table. To actually get to the row you need to use the Primary Key to get to the physical address using the Primary Index (which must be physical). Logical http://www.startrek.com/database_article/spock

Logical vs. Physical Indices (cont.) Physical indices are faster (they don't have the indirection of logical indices). But if the physical addresses change (from insertion/deletion), physical indices must by updated as well. Changes to physical addresses don't affect logical indices. Physical http://www.bookofdaystales.com/tag/original-series/

Which is the fastest? students (first_name, last_name, grade) Primary Key = first_name, last_name 1. Primary Index (first_name, last_name) 2. Physical Index on grade 3. Logical Index on first_name 4. Depends on the query using the index

Choosing the Primary Key Most DBMSs order the physical placement of rows in memory according to the Primary Key of the table. Thus queries based on the Primary Key are very fast. But if queries are primarily concerned with other attributes, those queries will be slow. You should choose Primary Keys oriented for the most common/important queries. http://higher-quality.com/primary-key-image.html

Indices for Key Contraints Indices can be used outside of SELECT statements. One common use is in the enforcement of key constraints. Reminder about constraints: Constraints are restrictions on what values an attribute can take. CREATE TABLE students (student_id NOT NULL UNIQUE INTEGER, course_id TEXT, FOREIGN KEY (course_id) REFERENCES courses(course_id)); You can use an index on student_id to check for each row modified that its student_id is unique. You can use an index on course_id (for the table courses) to check that each course_id in students has a key in the index.