Professional Documents
Culture Documents
Lect 2 Relational Model
Lect 2 Relational Model
RELATIONAL
MODEL
TYPES OF DATABASE MODEL
POPULATED DATABASE STATE FOR COMPANY
POPULATED DATABASE STATE FOR COMPANY
ENTITIES AND ATTRIBUTES
Relation schema R
Tuples
DATABASE AND RELATIONS
results in
repetition of information
Alternative Primary
KEY
Candidate Superkey
CANDIDATE KEY
Relation R
Attributes
Non-prime
Prime Attributes
Attributes
i.e. any candidate key whose values are always NOT NULL.
Eg. Ssn: Primary Key (no null value allowed)
PRIMARY KEY DRILL
Ssn, Dnumber, Dname are qualified to become a primary key. But since Ssn,
Dnumber are the primary key, DName becomes the alternative key.
ALTERNATIVE KEY DRILL
DeptCode DeptName
001 Science
002 English
005 Computer
Referencing
Relation
REFERENTIAL INTEGRITY CONSTRAINT
(CONT.)
Tuples in the referencing relation R1 have attributes FK (called foreign
key attributes) that reference the primary key attributes PK of the
referenced relation R2.
R2 R1
……. ……. ……. ……. PK ……. ……. FK
The value in the foreign key column (or columns) i.e. FK of the the
referencing relation R1 can be either:
a) a value of an existing primary key value of a corresponding primary key
PK in the referenced relation R2,
or
b) a null.
REFERENTIAL INTEGRITY
CONSTRAINTS
values.
REFERENTIAL INTEGRITY
CONSTRAINTS
Insertion No Violation
Referencing Deletion
Relation No Violation
( EMP )
Updation Restricted
REFERENTIAL INTEGRITY CONSTRAINT -
INSERTION
Insertion in Referenced
Relation is allowed
Insertion in Referencing
Relation is restricted
DELETION/UPDATION IN REFERENCED
RELATION
ON DELETE, CASCADE
ON UPDATE, CASCADE
DELETION/UPDATION IN REFERENCED
RELATION
ON DELETE, NO ACTION
ON UPDATE, NO ACTION
DELETION IN REFERENCING RELATION
UPDATION IN REFERENCING RELATION
PRIMARY KEY VS FOREIGN KEY