Relational Model Keys
Relational Model Keys
Model
Introduction
Proposed by Edgar. F. Codd (1923-2003) in the
early seventies. [ Turing Award – 1981 ]
Most of the modern DBMS are relational.
Simple and elegant model with a mathematical
basis.
Led to the development of a theory of data
dependencies and database design.
Relational algebra operations –
crucial role in query optimization and execution.
Laid the foundation for the development of
Tuple relational calculus and then
Database standard SQL
Relation
Scheme
C o nsists o f re latio n name , and a se t o f
attributes or f ie ld names or column names. Each
attribute has an associated domain.
Example:
student ( studentName : string,
rollNumber : string,
phoneNumber : integer,
Relation yearOfAdmission : integer,
name branchOfStudy : string )
Attribute domain
names s
Domain – set of atomic (or indivisible ) values –
data type
Relation
Instance
A f inite set of tuples constitute a relation instance.
A tuple of relation with scheme R = (A1, A2, … ,
Am) is an ordered sequence of values
(v1,v2, ... ,vm) such that vi ∈ domain (Ai),
1≤ i ≤ m
student
studentName rollNumber
yearOf phoneNumber branch Of
Admission Study
Ravi Teja CS05B015 2005 9840110489 CS
Rajesh CS04B125 2004 9840110490 EC
…
enrollment
studentName rollNumber courseNo sectionNo
Course Department
courseId name credits deptNo deptId name hod phone
An Example:
CE751 MASS 3 4
TRANSFER
19
Example Relational
Scheme
student (rollNo, name, degree, year, sex, deptNo, advisor)
Here, degree is the program ( B Tech, M Tech, M S, Ph
D etc) for which the student has joined. Year is the
year of admission and advisor is the EmpId of a
faculty member identified as the student’s advisor.
Student(studno,name,tutor,year)
Staff(lecturer,roomno,appraiser)
Referential Integrity
• Student(studno,name,tutor,year)
• Staff(lecturer,roomno,appraiser)
• CASCADE
– delete all matching foreign key tuples
eg. STUDENT
• RESTRICT
– can’t delete primary key tuple STAFF whilst a foreign key
tuple STUDENT matches
• NULLIFY
– foreign key STUDENT.tutor set to null if the foreign key
ids allowed to take on null
Entity Integrity and Nulls
No part of a key can be null
• Attribute values THREE categories of null values
1. Not applicable
– Atomic 2. Not known
3. Absent (not recorded)
– Known domain
– Sometimes can be null
STUDENT
The Data Dictionary and System
• Data dictionary
Catalog
– Provides detailed accounting of all tables found within the
user/designer-created database
– Contains (at least) all the attribute names and characteristics for
each table in the system
– Contains metadata: data about data
– Active & passive
• System catalog
– Contains metadata
– Detailed system data dictionary that describes all objects within the
database
• Data about table names, table’s creator, creation date, number of
columns in each table, data type of each column, index filenames,
index creators, authorized users and access privileges
28
30
The Data Dictionary and System
Catalog
• Homonym
– Indicates the use of the same name to label
different attributes
• Use C_NAME in a CUSTOMER table for customer
name and in a CONSULTANT table for consultant
name
• Synonym
– Opposite of a homonym
• Indicates the use of different names to describe
the same attribute e.g., CAR and AUTO
31
Codd’s Relational Database Rules
• In 1985, Codd published a list of 12 rules
to define a relational database system
– Products marketed as “relational” that did not
meet minimum relational standards
• Even dominant database vendors do not
fully support all 12 rules
32
33