Professional Documents
Culture Documents
Database
Design and the
Relational
Model
Chapter 4 (Part 1)
The Relational Data Model
2
Components of the Relational
Data Model
1. Data Structure - Data are organized in two-dimensional
tables (called relations) with rows and columns
3
Relational Data Structure
Structure of a relation
Relation name (attribute1, attribute2, etc.)
E.g., EMPLOYEE (EMP_ID, Name, Dept_Name, Salary)
4
Relational Keys
Primary Key
An attribute (or combination of attributes) that uniquely
identifies each row in a relation.
EMPLOYEE (EMP_ID, Name, Dept_Name, Salary)
Composite Key
A primary key that consists of more than one attribute
DEPENDENT(EMP_ID, Dependent_Name)
5
Relational Keys
Foreign Key
To represent the relationship between two
tables
Attribute in one relation that serves as the
primary key of another relation in the
same database (i.e., linking field)
EMPLOYEE (EMP_ID, Name, Dept_Name, Salary)
DEPARTMENT (Dept_Name, Location, Fax)
6
Customer_id Order_Id Product_Id
address Product_name
First_name Last_name
state
Middle_name
zip
7
Example of Four Relations
PK
8
Instance of a relational schema
9
Integrity Constraints
Domain Constraint
constrains allowable values for an attribute (e.g.,
domain name, meaning, data type, field
size/length, allowable values/range)
Entity Integrity Rule
No primary key attribute (or component of a
primary key attributes) can be null
Referential Integrity Constraint
A rule that states that either each foreign key
value must match a primary key value in the
other relation or else the foreign key value must
be null
10
Diagramming Referential Integrity
Constraints
11
A well structured relation
EMPLOYEE1
12
Is this a well structured relation?
EMPLOYEE2
13
Well-Structured Relations
14
Why minimize redundancies?
16
Insertion anomaly
17
Anomalies
Deletion Anomalies
are experienced when a value for one attribute
we wish to keep is unexpectedly removed
when a value for another attribute is deleted
18
Deletion anomaly
19
Anomalies
Modification Anomalies
are experienced when changes to multiple
instances of an entity (rows of a table) are
needed to effect an update to a single value of
an attribute
20
Modification anomaly
21