chapter 4 logical database design and the relational model

37
1 Chapter 4 Logical Database Design and the Relational Model Jason C. H. Chen, Ph.D. Professor of MIS School of Business Administration Gonzaga University Spokane, WA 99258 [email protected]

Upload: media

Post on 15-Feb-2016

2.019 views

Category:

Documents


139 download

DESCRIPTION

Chapter 4 Logical Database Design and the Relational Model. Jason C. H. Chen, Ph.D. Professor of MIS School of Business Administration Gonzaga University Spokane, WA 99258 [email protected]. #1-I(a), p.193. #1-I(b). Fig. 2-11: An associative entity (p. 78). #1-I (c). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 4  Logical Database Design and the Relational Model

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]

Page 2: Chapter 4  Logical Database Design and the Relational Model

2

#1-I(a), p.193

#1-I(b)

Page 3: Chapter 4  Logical Database Design and the Relational Model

Fig. 2-11: An associative entity (p. 78)(a) Attribute on a relationship (Link Attribute/Associative)

#1-I (c)

Page 4: Chapter 4  Logical Database Design and the Relational Model

4

#1-I (c)

EmployeeiD EmployeeName

EMPLOYEE

EmployeeID CourseID DateCompleted

CERTIFICATE

COURSE

CourseID CourseTitle

Birth_Date

Page 5: Chapter 4  Logical Database Design and the Relational Model

5

#1-I (c)

EmployeeiD EmployeeName

EMPLOYEE

EmployeeID CourseID DateCompleted

CERTIFICATE

COURSE

CourseID CourseTitle

Birth_Date

(see 3NF on the next Slide)

{ Topic }

?

Page 6: Chapter 4  Logical Database Design and the Relational Model

6

#1-I (c)

EmployeeiD EmployeeName

EMPLOYEE

EmployeeID CourseID DateCompleted

CERTIFICATE

COURSE

CourseID CourseTitle

Birth_Date

(see 3NF on the next Slide)

TopicCourseID

cpk

Page 7: Chapter 4  Logical Database Design and the Relational Model

Answer to: #1-I (c) 3NF

Topic

Why?

Page 8: Chapter 4  Logical Database Design and the Relational Model

8

#1-III(c)3NF

Page 9: Chapter 4  Logical Database Design and the Relational Model

9

#2-III-a (p.193) – from Fig3-6b (p. 121)

Page 10: Chapter 4  Logical Database Design and the Relational Model

10

#2-III-b (p.193) from Fig. 3-7a (p.122)

Page 11: Chapter 4  Logical Database Design and the Relational Model

11

#2-III-c (p.193) – from Fig.3-9 (p.124)

Page 12: Chapter 4  Logical Database Design and the Relational Model

12

#2-III-d (p.193) – from Fig. 3-10 (p.125)

Page 13: Chapter 4  Logical Database Design and the Relational Model

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)

Page 14: Chapter 4  Logical Database Design and the Relational Model

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)

Page 15: Chapter 4  Logical Database Design and the Relational Model

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.

Page 16: Chapter 4  Logical Database Design and the Relational Model

16

7. g)

Page 17: Chapter 4  Logical Database Design and the Relational Model

8. a)

partial dep. partial dep.

transitive dep.

Page 18: Chapter 4  Logical Database Design and the Relational Model

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).

Page 19: Chapter 4  Logical Database Design and the Relational Model

19

8. c-i) 2NF after remove partial wtih transitive dep.

transitive dep.

Page 20: Chapter 4  Logical Database Design and the Relational Model

20

8. c-ii) 3NF after remove partial & transitive dep.

Page 21: Chapter 4  Logical Database Design and the Relational Model

21

8. d)3NF after remove partial & transitive dep.

Page 22: Chapter 4  Logical Database Design and the Relational Model

22

8. e) Using MS/Visio

Page 23: Chapter 4  Logical Database Design and the Relational Model

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)

Page 24: Chapter 4  Logical Database Design and the Relational Model

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)

Page 25: Chapter 4  Logical Database Design and the Relational Model

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

Page 26: Chapter 4  Logical Database Design and the Relational Model

26

partial

transitive partial

First, convert it to 2NF (How?)Remove partial dependency. However, transitive dependency still exists

(9 c)

transitive

cpk

Page 27: Chapter 4  Logical Database Design and the Relational Model

27

(9 c) cont.

transitive

Finally, remove transitive dependency

Page 28: Chapter 4  Logical Database Design and the Relational Model

28

d. 3NF relations with referential integrity and functional dependencies shown

Page 29: Chapter 4  Logical Database Design and the Relational Model

29

ShipmentID (fk)ItemNumber (fk)

9d) ER-D

Page 30: Chapter 4  Logical Database Design and the Relational Model

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)

Page 31: Chapter 4  Logical Database Design and the Relational Model

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.

Page 32: Chapter 4  Logical Database Design and the Relational Model

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#

Page 33: Chapter 4  Logical Database Design and the Relational Model

33

b. Dependency diagram

partial transitive

partial

What else?

Page 34: Chapter 4  Logical Database Design and the Relational Model

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.

Page 35: Chapter 4  Logical Database Design and the Relational Model

35

d. Millenium College Public Safety Parking, 3NF relations

Page 36: Chapter 4  Logical Database Design and the Relational Model

36

e. Millenium College Public Safety Parking, EER diagram

Page 37: Chapter 4  Logical Database Design and the Relational Model

37

END OF CH4