The Relational Database Model
The Relational Database Model
• Superkey
– Uniquely identifies each entity
– STU_NUM
– STU_NUM, STU_LNAME
– STU_NUM, STU_LNAME, STU_INIT
• Candidate key
– Minimal superkey
– STU_NUM
– STU_LNAME, STU_FNAME, STU_INIT,
STU_PHONE
Relational Database Keys
• Secondary key
– Used only for data retrieval
• Foreign key
– Values must match primary key in
another table
Integrity Rules
• Entity integrity
– Ensures all entities are unique
– Each entity has unique key
• Referential integrity
– Foreign key must have null value or
match primary key values
– Makes it impossible to delete row
whose primary key has mandatory
matching foreign key values in
An Illustration of Integrity
Rules
Relational Database Operators
• M:N relationship
- Must be avoided because they lead to data
redundancies
• 1:1 relationship
- Should be rare in any relational database
design
The 1:M Relationship Between
Painter and Painting
1:M Relationship
The M:N Relationship Between
Student and Class
Sample Student Enrollment Data
A Many-to-Many Relationship
Between Student and Class
Changing the M:N
Relationship to Two 1:M
Relationships
The Expanded
Entity
Relationship
Model
The Relational Schema for the
Entity Relationship Diagram
Data Redundancy Revisited