1
Chapter 4 Logical Database Design and
the Relational ModelJason C. H. Chen, Ph.D.
Professor of MISSchool of Business Administration
Gonzaga UniversitySpokane, WA [email protected]
2
#1-I(a), p.193
#1-I(b)
Fig. 2-11: An associative entity (p. 78)(a) Attribute on a relationship (Link Attribute/Associative)
#1-I (c)
4
#1-I (c)
EmployeeiD EmployeeName
EMPLOYEE
EmployeeID CourseID DateCompleted
CERTIFICATE
COURSE
CourseID CourseTitle
Birth_Date
5
#1-I (c)
EmployeeiD EmployeeName
EMPLOYEE
EmployeeID CourseID DateCompleted
CERTIFICATE
COURSE
CourseID CourseTitle
Birth_Date
(see 3NF on the next Slide)
{ Topic }
?
6
#1-I (c)
EmployeeiD EmployeeName
EMPLOYEE
EmployeeID CourseID DateCompleted
CERTIFICATE
COURSE
CourseID CourseTitle
Birth_Date
(see 3NF on the next Slide)
TopicCourseID
cpk
Answer to: #1-I (c) 3NF
Topic
Why?
8
#1-III(c)3NF
9
#2-III-a (p.193) – from Fig3-6b (p. 121)
10
#2-III-b (p.193) from Fig. 3-7a (p.122)
11
#2-III-c (p.193) – from Fig.3-9 (p.124)
12
#2-III-d (p.193) – from Fig. 3-10 (p.125)
13
b. 3NFc. 2NF CLASS (CourseNo, SectionNo, Room)ROOM (Room, Capacity)
d. 1NFCOURSE (CourseNo, CourseName)CLASS (CourseNo, SectionNo, Room)ROOM (Room, Capacity)
a. 3NF
3. The normal form for the relations are: (make sure that you know why and how to transform it to 3NF)
14
7. Transforming Table 4-3 to relations: (p194)
Part_No Description
12341234567856785678
Logic ChipLogic ChipMemory ChipMemory ChipMemory Chip
Vendor_Name
Fast ChipsSmart ChipsFast ChipsQuality ChipsSmart Chips
CupertinoPhoenixCupertinoAustinPhoenix
Unit_CostAddress
10.008.003.002.005.00
a) PART SUPPLIER
b) Part_NoVendor_NamePart_No, Vendor_Name
DescriptionAddressUnit_Cost
Insert anomaly: we cannot insert a new vendor unless we also include a part number.Delete anomaly: if we delete part information, we also lose information about a vendor who supplies that part.Modification anomaly: if a vendor address changes, we have to modify all records (or rows) for that vendor.
c)
15
7. d)
Part_No Description Vendor_Name Address Unit_Cost
e) 1NF
f)
Part_No Description
Part_No Vendor_Name Unit_Cost
Vendor_Name Address
PART SUPPLIER
partial dep.partial dep.
16
7. g)
8. a)
partial dep. partial dep.
transitive dep.
8. b)
b) 1NF
partial dep. partial dep.
transitive dep.
The relation is currently in the first normal form (1NF) because it has no repeating groups and has a name and a valid primary key, but is not in 2NF because it has partial and transitive dependencies. For example, StudentName is dependent on only one of the two components of the primary key (StudentID).
19
8. c-i) 2NF after remove partial wtih transitive dep.
transitive dep.
20
8. c-ii) 3NF after remove partial & transitive dep.
21
8. d)3NF after remove partial & transitive dep.
22
8. e) Using MS/Visio
23
9.
ID:
Name:
a) Draw a relational schema and diagram the functional dependencies in the relation b) In what normal form is this relation? Why? c) Decompose MANIFEST into a set of 3NF relations.
First, just draw the relation (table/entity with all required fields)
(Boat Number)
24
9 a).
ID:Name:
a) Draw a relational schema and diagram the functional dependencies in the relation
Next, draw functional dependencies diagrampartial
transitive partial
Total weight is a derived attribute and can be calculated from weight and quantity. Therefore it is not shown here as part of the relational schema. Relational schema shown below:
cpk
(Boat Number)
25
(9 b)The relation is currently in the first normal form (1NF) because it has no repeating groups and has a name and a valid primary key, but is not in 2NF because it has partial and transitive dependencies. For example, ShipmentDate is dependent on only one of the two components of the primary key (ShipmentID).
partial
transitive partialcpk
26
partial
transitive partial
First, convert it to 2NF (How?)Remove partial dependency. However, transitive dependency still exists
(9 c)
transitive
cpk
27
(9 c) cont.
transitive
Finally, remove transitive dependency
28
d. 3NF relations with referential integrity and functional dependencies shown
29
ShipmentID (fk)ItemNumber (fk)
9d) ER-D
30
13 The Public Safety office at Millennium College maintains a list of parking tickets issued to vehicles parked illegally on the campus.
Table 4-6 shows a portion of this list for the fall semester (attribute names are abbreviated to conserve space)
31
13 a)
a. Convert this table to a relation in 1NF by entering appropriate data in the table. What are the determinants (pk) in this relation?b. Draw a dependency diagram that shows all functional dependencies in the relation, based on the sample data shown.c. Given an example of one or more anomalies that can result in using this relation.d. Convert the relation in (b) into 3NF.
32
a. Parking ticket table
a. Convert this table to a relation in 1NF by entering appropriate data in the table. What are the determinants (pk) in this relation?
The determinants (pk) are: STID, Ticket#
33
b. Dependency diagram
partial transitive
partial
What else?
34
c. i) An insertion anomaly would occur
if you tried to insert a student who has never had a parking ticket.ii) A deletion anomaly would occur if you were to delete a record of any student with only one parking ticket since all student information would be lost.iii) A modification anomaly would occur whenever the PhoneNo (or Name, State License, or License Number) data of a student was updated.
35
d. Millenium College Public Safety Parking, 3NF relations
36
e. Millenium College Public Safety Parking, EER diagram
37
END OF CH4