Relational Database Design: Converting Conceptual Models To Relational Databases
Relational Database Design: Converting Conceptual Models To Relational Databases
SalespersonID Name
123456 Fred
654321 Francis
Relational Database Model
Some principles of the relational model
Entity Integrity
A primary key in a table must not contain a null value
Guarantees uniqueness of entities and enables proper referencing of
primary key values by foreign key values
Referential Integrity
A value for a foreign key in a table must either
Be null (blank)
Match exactly a value for the primary key in the table from which it
was posted
One Fact, One Place
Fact = a pairing of a candidate key attribute value with
another attribute value
Facts are found in the extensional data
Referential Integrity Example
One Fact-One Place Violations
One fact in multiple places
2
3
1
3
2
4
One Fact-One Place Violations
Multiple facts in one place
1 2
3 4 5
Converting Conceptual to Relational
Step 1: Create a separate table to represent each entity
in the conceptual model
1A: Each attribute of the entity becomes a column in the
relational table
2A: Each instance (member) of the entity set will become a row
in the relational table
Relationship Conversion
Step 2: Create a separate table to represent each
many-to-many relationship in the conceptual model
You must create a separate table to represent the
relationship
The primary keys of the related entity tables are posted into the
relationship table to form its primary key. This kind of primary
key is called a composite or concatenated primary key
This avoids redundancy
There are no exceptions to this rule!!!
If you post a foreign key in either direction, redundancy
will be a problem for many-to-many relationships
Relationship Conversion
Maximum Cardinalities
The general rule is to post into a “1” entity table
This avoids “repeating groups” redundancy
You can NEVER post into an “N” entity
This causes “repeating groups” redundancy
Minimum Cardinalities
The general rule is to post into a “1” (mandatory) entity table
This avoids null values in the foreign key column
This rule should be violated in some circumstances (to be
discussed soon)
Example: Many-Many Relationships
student # course #
name
name
address
(1,N) (1,N)
(1,N) (1,N)
Acg3101 FAR 1
Relationship Conversion
Step 3: For participation cardinality pattern
(1,1)-(1,1), consider whether the two entities are
conceptually separate or whether they should be
combined
If they should remain separate, then
3A: Post the primary key from one entity’s table into
the other entity’s table as a foreign key
DO NOT make a separate table
Example: (1,1)-(1,1)
SaleID Date Amount CR-ID Date Amount
• If relationship becomes
a separate table, then
relationship attributes
are placed in that table
• If relationship can be
represented by a posted
foreign key, relationship
attribute is posted
alongside the foreign
key
Fixing One Fact Multiple Places
Employee
EmpID EmpName Payrate Hours Worked Dept# DeptName
8532 Andy $13 36 D423 Audit
7352 Jennifer $14 45 D423 Audit
215 Arlie $20 50 D777 ISAAS
4332 Craig $18 60 D821 Tax
74 Steven $22 64 D821 Tax
Employee Department
EmpID EmpName Payrate Hours Worked Dept# Dept# DeptName
8532 Andy $13 36 D423 D423 Audit
7352 Jennifer $14 45 D423 D777 ISAAS
215 Arlie $20 50 D777 D821 Tax
4332 Craig $18 60 D821
74 Steven $22 64 D821
Fixing Multiple Facts in One Place
Warehouse
InventoryInWarehouse
Warehouse# Address QOH
Warehouse# Product#
W1 123 Oak 2,14,784
W1 AB12
W2 456 Pine 4,23,873
W1 BC445
Inventory W1 DD2
Product# Description StdCost QOH W2 AB12
AB12 Granddaddy $5,000 2,4 W2 BC445
BC445 Mama $3,000 14,23 W2 DD2
DD2 Littlebabe $100 784,873