2 the relational model and normalization (cont.) · pdf filelogical table design so that it...

11
1 IT468 DB @ ITAM 1 §2 – The Relational Model and Normalization (cont.) Fen Wang [email protected] Lecture 7 IT468 DB @ ITAM 2 Agenda The foundation of the relational model Characteristics of relations The basic relational terminology Primary, candidate, and composite keys How foreign keys represent relationships The purpose and use of surrogate keys The meaning of functional dependencies Possible insertion, deletion, and update anomalies Apply a process for normalizing relations

Upload: dinhkhue

Post on 13-Mar-2018

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

1

IT468 DB @ ITAM 1

§2 – The Relational Model and

Normalization (cont.)

Fen Wang

[email protected]

Lecture 7

IT468 DB @ ITAM 2

Agenda

• The foundation of the relational model

• Characteristics of relations

• The basic relational terminology

• Primary, candidate, and composite keys

• How foreign keys represent relationships

• The purpose and use of surrogate keys

• The meaning of functional dependencies

• Possible insertion, deletion, and update anomalies

• Apply a process for normalizing relations

Page 2: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

2

IT468 DB @ ITAM 3

Normalization Principles

• Primarily a tool to validate and improve a logical table design so that it satisfies certain constraints that avoid unnecessary duplication of data

• The process of decomposing relations with anomalies to produce smaller, well-structured relations, in which every determinant must be a candidate key

IT468 DB @ ITAM 4

Normal Forms

Page 3: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

3

IT468 DB @ ITAM 5

The Normalization Process: Review Practice

• Example: Company that manages building projects

– Charges its clients by billing hours spent on each contract

– Hourly billing rate is dependent on employee’s position

– Periodically, report is generated that contains information displayed in the following Table

IT468 DB @ ITAM 6

The Normalization Process: Review Practice (cont.)

Page 4: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

4

IT468 DB @ ITAM 7

The Normalization Process: Review Practice (cont.)

IT468 DB @ ITAM 8

Steps in Normalization Process

Remove

repeating

groups

Page 5: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

5

IT468 DB @ ITAM 9

The Normalization Process: Review Practice (cont.)

IT468 DB @ ITAM 10

The Normalization Process: Review Practice (cont.)

Page 6: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

6

IT468 DB @ ITAM 11

The Normalization Process: Review Practice (cont.)

IT468 DB @ ITAM 12

The Normalization Process: Review Practice (cont.)

Page 7: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

7

IT468 DB @ ITAM 13

Steps in Normalization Process

Remove

repeating

groups

When table contains only ONE

candidate key, 3NF and BCNF

are equivalent

IT468 DB @ ITAM 14

The Normalization Process: Exercise (1)

EQUIPMENT_REPAIR (ItemNumber, Type, AcquisitionCost,

RepairNumber, RepairDate, RepairAmount)

Page 8: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

8

IT468 DB @ ITAM 15

The Normalization Process: Exercise (1) cont.

EQUIPMENT_REPAIR (ItemNumber, Type, AcquisitionCost, RepairNumber, RepairDate, RepairAmount)

ItemNumber (Type, AcquisitionCost)

RepairNumber (ItemNumber, Type, AcquisitionCost,

RepairDate, RepairAmount)

ITEM (ItemNumber, Type, AcquisitionCost)

REPAIR (RepairNumber, ItemNumber, RepairDate, RepairAmount)

Where ItemNumber in REPAIR must exist in ItemNumber in ITEM

IT468 DB @ ITAM 16

The Normalization Process: Exercise (1) cont.

Page 9: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

9

IT468 DB @ ITAM 17

The Normalization Process: Exercise (2)

EMPLOYEE (EmployeeNumber, LastName, Department,

Email, Department, DeptPhone)

IT468 DB @ ITAM 18

The Normalization Process: Exercise (2) cont.

• Normalized EMPLOYEE and DEPARTMENT relations and data

Where Department in EMPLOYEE must exist in Department in DEPARTMENT

Page 10: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

10

IT468 DB @ ITAM 19

The Normalization Process: Exercise (3)

MEETING (Attorney, ClientNumber, ClientName, Date, Duration)

IT468 DB @ ITAM 20

The Normalization Process: Exercise (3) cont.

• Normalized MEETING and CLIENT relations and data

Where ClientNumber in MEETING must exist in ClientNumber in CLIENT

Page 11: 2 The Relational Model and Normalization (cont.) · PDF filelogical table design so that it satisfies certain ... in which every determinant must be a candidate key IT468 DB @ ITAM

11

IT468 DB @ ITAM 21

Steps in Normalization Process

Remove

repeating

groups

IT468 DB @ ITAM 22

Before next class

• Practice more with MS Access 2010 and MS Visio Professional

• Continue working on Project D1

• Finalize working on Assignment#2 (due 10PM on Friday)

• Read Textbook Chapter 2 – Normalization