normalization of database tables

61
Normalization of Database Tables กกก Normalize กกกกกกกกกกกกกกกกกกก กกกกกก กกกกกกกกก กก.กกกกก กกกกกก Normalize กกกกกกก กกกกกกกกกกกกกก Attribute กกกกกกกกกกกกกกกกกกก

Upload: phoebe-stanley

Post on 01-Jan-2016

75 views

Category:

Documents


0 download

DESCRIPTION

Normalization of Database Tables. การ Normalize คือหลักการออกแบบฐานข้อมูล คิดค้นโดย ดร.คอร์ด การทำ Normalize ในแต่ละระดับจะช่วยแยก Attribute ที่ซ้ำซ้อนกันออกไป. วัตถุประสงค์การเรียนรู้. สามารถอธิบายขั้นตอนการทำ Normalization ในแต่ละรูปแบบได้ - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Normalization of Database Tables

Normalization of Database Tables

การ Normalize คื�อหลักการออกแบบฐานข้�อมู�ลั คื�ดคื�นโดย

ดร.คือร�ด การทำ�า Normalize ในแต่�ลัะระดบจะช่�วยแยก Attribute

ทำ!"ซ้ำ�$าซ้ำ�อนกนออกไป

Page 2: Normalization of Database Tables

วั�ตถุ�ประสงค์ การเร�ยนร��

1 .สามูารถอธิ�บายข้$นต่อนการทำ�า Normalization ในแต่�ลัะร�ปแบบได�

2. มู!คืวามูเข้�าใจในการทำ�า Normalizationในแต่�ลัะร�ปแบบ

Page 3: Normalization of Database Tables

วั�ตถุ�ประสงค์ ของการทำ�า Normalization

1 .เพื่�"อลัดเน�$อทำ!"ในการจดเก,บข้�อมู�ลั2. เพื่�"อลัดป-ญหาทำ!"ข้�อมู�ลัไมู�ถ�ก

ต่�อง(Inconsistency)3. เป0นการลัดป-ญหาทำ!"เก�ดจากการเพื่�"มู

ปรบปร1งแลัะลับข้�อมู�ลั(Insert, Update and Delete Anomalies)

Page 4: Normalization of Database Tables

Series of stages called normal forms:

(First Normal Form : 1NF) (Second Normal Form : 2NF) (Third Normal Form : 3NF) (Boyce/Codd Normal Form :

BCNF) (Fourth Normal Form : 4NF) (Fifth Normal Form : 5NF)

Page 5: Normalization of Database Tables

The term first normal form (1NF) All the key attribute are defined

There are no repeating groups in the table

All attributes are dependent on the primary key

Page 6: Normalization of Database Tables

First Normal Form : 1NFRelation หน2"งๆ จะอย��ในร�ปแบบ

1 NF ก,ต่�อเมู�"อ “คื�าข้อง Attribute ต่�างๆ ในแต่�ลัะ

Tuple จะมู!คื�าข้องข้�อมู�ลัเพื่!ยงคื�าเด!ยว น"นคื�อไมู�มู! Repeating Group แลัะ

Multi-valued”

First Normal Form : 1NF

Page 7: Normalization of Database Tables

S# SNAME CITY P# QTY

S1 Henry London P1 300

P2 200

P3 400

P4 200

P5 100

P6 100

S2 Vivian Paris P1 300

P2 400

S3 Harry Paris P2 200

S4 James London P2 200

P4 300

P5 400

Page 8: Normalization of Database Tables

S# SNAME CITY P# QTY

S1 Henry London P1 300

S1 Henry London P2 200

S1 Henry London P3 400

S1 Henry London P4 200

S1 Henry London P5 100

S1 Henry London P6 100

S2 Vivian Paris P1 300

S2 Vivian Paris P2 400

S3 Harry Paris P2 200

S4 James London P2 200

S4 James London P4 300

S4 James London P5 400

Page 9: Normalization of Database Tables

คืวามูผิ�ดพื่ลัาดบางอย�างทำ!"อาจเก�ดข้2$นกบข้�อมู�ลัใน Relation ก,ยงมู!อย��

เช่�น1. Insert Anomaly การทำ!"จะเพื่�"มู

ข้�อมู�ลัข้องผิ��ผิลั�ต่จะทำ�าได�ต่�อเมู�"อผิ��ผิลั�ต่รายน$นมู!การส�งส�นคื�าไปให�ผิ��ซ้ำ�$อ ร!เลัช่"น

จะไมู�แสดงรายลัะเอ!ยดข้องผิ��ผิลั�ต่ S5 ทำ!"อย��ทำ!" Athens ถ�ายงไมู�มู!การส�งส�นคื�า ดงน$นหากมู!เพื่!ยงข้�อมู�ลัข้องผิ��ผิลั�ต่แต่�ยงไมู�เคืยได�รบการส"งส�นคื�าก,จะเพื่�"มู

ข้�อมู�ลัข้องผิ��ผิลั�ต่ไมู�ได�

First Normal Form : 1NF

Page 10: Normalization of Database Tables

2. Delete Anomaly ในการลับข้�อมู�ลับาง Tuple จะลับทำ$งข้�อมู�ลัผิ��ผิลั�ต่

แลัะข้�อมู�ลัการส�งส�นคื�า ป-ญหาข้อง Relation น!$คื�อ Relation น!$ประกอบด�วย Attribute มูากเก�นไปโดยทำ!"ข้�อมู�ลั

บาง Attribute อาจไมู�จ�าเป0นต่�องใช่�งานแต่�มูาผิ�กต่�ดกบ Attribute ทำ!"ต่�อง

ใช่�งาน

First Normal Form : 1NF

Page 11: Normalization of Database Tables

3. Update Anomaly การปรบปร1งจะทำ�าให�ย1�งยากแลัะเส!ยเวลัา รวมูทำ$งอาจ

ก�อให�เก�ดคืวามูผิ�ดพื่ลัาดทำ!"ข้�อมู�ลัไมู�เหมู�อนกน เช่�น เปลั!"ยนช่�"อเมู�องข้อง S1

เป0น New York

First Normal Form : 1NF

Page 12: Normalization of Database Tables

ป-ญหาทำ!"เก�ดข้2$น สามูารถแก�ไข้ได�โดยแต่ก Relation

(Decomposition) เป0น 2Relation คื�อ Relation SUPPLIER

แลัะ Relation ORDERSUPPLIER(S#, SNAME, CITY)

ORDER(S#, P#, QTY)

First Normal Form : 1NF

Page 13: Normalization of Database Tables

A table is in second normal form(2NF) if:

It is in 1NF It includes no partial dependencies;

that is, no attribute is dependent on only a portion of the primary key.

Page 14: Normalization of Database Tables

Second Normal Form : 2NFRelation หน2"งๆ จะอย��ในร�ปแบบ 2NF ก,ต่�อเมู�"อ“1. Relation น$นๆ ต่�องอย��ในร�ปแบบ 1 NF

2 Attribute ทำ1กต่วทำ!"ไมู�ได�เป0นคื!ย�หลัก จะต่�องมู!คืวามูสมูพื่นธิ�ระหว�างคื�าข้อง Attribute แบบฟั-งก�ช่นกบคื!ย�หลัก(Fully Functional Dependency ) หร�อกลั�าวง�ายๆ ว�า ไมู�มู! Partial Dependency เก�ดข้2$น”

Page 15: Normalization of Database Tables

Relation SUPPLIER แลัะ ORDER อย��ใน 2 NF แลั�ว แต่�หากสมูมูต่�ให� Relation ORDER1 ถ�กออกแบบเป0นดงน!$

S# P# PNAME

QTY

S1 P1 PAPER 200S1 P2 RULER 150S1 P3 PENCIL 300S2 P1 PAPER 50S2 P3 PENCIL 100S3 P4 PEN 100

ORDER1

Page 16: Normalization of Database Tables

S# P# PNAME QTY

Second Normal Form : 2NF

Page 17: Normalization of Database Tables

เพื่ราะฉะน$น Relation ORDER1 ไมู�ได�อย��ในร�ป 2 NF ต่�องทำ�าการแต่ก Relation เพื่�"อลัดคืวามูซ้ำ�$าซ้ำ�อนข้องข้�อมู�ลั ดงน!$ORDER1(S#, P#, QTY)PRODUCT(P#, PNAME)

Second Normal Form : 2NF

Page 18: Normalization of Database Tables

Step 1: Write Each Key Component on a Separate Line

Write each key component on separate line, then write original (composite) key on

last line Each component will become key in new

table

Second Normal Form

Page 19: Normalization of Database Tables

Step 2: Assign Corresponding Dependent Attributes

Determine those attributes that are dependent on other attributes

At this point, most anomalies have been eliminated

Second Normal Form

Page 20: Normalization of Database Tables

A table is in third normal form(3NF) if:

It is in 2NF It contains no transitive

dependencies transitive dependency; that is,

one or more attribute may be functionally dependent on nonkey attributes

Page 21: Normalization of Database Tables

Third Normal Form : 3NFRelation หน2"งๆ จะอย��ในร�ปแบบ 3NF ก,ต่�อเมู�"อ“1. Relation น$นๆ ต่�องอย��ในร�ปแบบ 2NF

2. Attribute ทำ1กต่วทำ!"ไมู�ได�เป0นคื!ย�หลัก ไมู�มู!คื1ณสมูบต่�ในการก�าหนดคื�าข้อง Attribute อ�"นทำ!"ไมู�ใช่�คื!ย�หลัก หร�อกลั�าวง�ายๆ ว�า ไมู�มู! Transitive Dependency เก�ดข้2$น”

Page 22: Normalization of Database Tables

Third normal form(3NF)Data anomalies created are easily

eliminated by completing three stepsStep 1: Identify Each New Determinant For every transitive dependency, write

its determinant as PK for new table Determinant

Any attribute whose value determines other values within a row

Page 23: Normalization of Database Tables

Third normal form(3NF)Step 2: Identify the Dependent

Attributes Identify attributes dependent on

each determinant identified in Step 1 and identify dependency

Name table to reflect its contents and function

Page 24: Normalization of Database Tables

S# SNAME

CITY RATING

S1 Henry

London

1

S2 Vivian

Paris 2

S3 Harry Paris 2S4 Jame

sLondo

n1

S5 Pete Athens

3

SUPPLIER1Third normal form(3NF)

Page 25: Normalization of Database Tables

SUPPLIER1 อย��ใน 2 NF แลั�วแต่�ยงมู! Transitive Dependency เก�ดข้2$นอย�� ทำ�าให�มู!คืวามูผิ�ดพื่ลัาดบางอย�างทำ!"อาจเก�ดข้2$นกบข้�อมู�ลัใน Relation ก,ยงมู!อย�� เช่�น

1. Update Anomaly หากมู!การแก�ไข้การจดอนดบข้องจงหวดข้องผิ��ผิลั�ต่ จะต่�องทำ�าการแก�ไข้ข้�อมู�ลัหลัาย Tuple

Third normal form(3NF)

Page 26: Normalization of Database Tables

2. Delete Anomaly หากมู!การลับข้�อมู�ลัการจดอนดบข้องจงหวดข้องผิ��ผิลั�ต่ จะทำ�าให�ข้�อมู�ลัการจดการจดอนดบหายไปจากฐานข้�อมู�ลั

Third normal form(3NF)

Page 27: Normalization of Database Tables

ป-ญหาทำ!"เก�ดข้2$น สามูารถแก�ไข้ได�โดยแต่ก Relation (Decomposition)

SUPPLIER1 เป0น 2 Relation โดยแยก Attribute ทำ!"ถ�กก�าหนดคื�ากบ

Attribute ทำ!"เป0นต่วก�าหนดคื�า(Determinant ) ออกเป0น

Relation ใหมู�แลัะ ก�าหนดให� Attribute ทำ!"

เป0นDeterminant เป0นคื!ย�หลักข้อง Relation ใหมู�

Third normal form(3NF)

Page 28: Normalization of Database Tables

จะได�SUPPLIER(S#, SNAME, CITY)CITY(CITY, RATING)

Third normal form(3NF)

Page 29: Normalization of Database Tables

ในบางคืร$งผิ��ออกแบบพื่ยายามูแต่ก Relation ทำ!"มู! attribute มูากๆ ออกเป0นหลัายๆ Relation ซ้ำ2"งจะทำ�าให�เก�ดป-ญหาการแต่ก Relation ทำ!"ไมู�

เหมูาะสมูได�(Bad Decomposition) เช่�น

หากแต่ก Relation SUPPLIER1 เป0นดงน!$SUPPLIER(S#, SNAME,

CITY)SUPPLIER2(S#, RATING)

Page 30: Normalization of Database Tables

S# SNAME

CITY

S1 Henry

London

S2 Vivian

Paris

S3 Harry

Paris

S4 James

London

S5 Pete Athens

Normal FormSUPPLIER

Page 31: Normalization of Database Tables

Normal FormS# RATI

NGS1 1S2 2S3 2S4 1S5 3

SUPPLIER2

Page 32: Normalization of Database Tables

จากต่วอย�าง การแต่ก Relation น!$ด�เหมู�อนจะแก�ป-ญหาคืวามูผิ�ดพื่ลัาดทำ!"

อาจจะเก�ดจากการเพื่�"มู ลับ ปรบปร1งข้�อมู�ลัได� เพื่ราะได�แต่กออกเป0น 2

Relation แลัะอย��ในร�ป 3NF แลั�ว แต่�การแต่ก Relation อาจก�อให�เก�ดคืวามู

ผิ�ดพื่ลัาดข้2$นได�อ!กเช่�นกน จะเห,นว�า การเพื่�"มูช่�"อจงหวดแลัะ

การจดอนดบข้องจงหวดใหมู�จะทำ�าไมู�ได� จนกว�าจะมู!ผิ��ผิลั�ต่รายใดอย��ทำ!"จงหวดทำ!"จะ

เพื่�"มูช่�"อแลัะจดอนดบน$น

Third normal form(3NF)

Page 33: Normalization of Database Tables

Relation SUPPLIER แลัะ SUPPLIER2 เป0น Relation ทำ!"ไมู�เป0นอ�สระต่�อกน เพื่ราะจงหวดเป0นต่วก�าหนดการจดอนดบได�S# CITY

RATING

S# CITY

RATING

Third normal form(3NF)

Page 34: Normalization of Database Tables

The Boyce-Codd Normal Form (BCNF) Every determinant in table is a candidate

key Has same characteristics as primary key, but for some reason, not chosen to

be primary key When table contains only one candidate key, the 3NF and the BCNF are equivalent BCNF can be violated only when table

contains more than one candidate key

Page 35: Normalization of Database Tables

The Boyce-Codd Normal Form (BCNF) Table is in 3NF when it is in 2NF and

there are no transitive dependencies Table can be in 3NF and fails to meet

BCNF No partial dependencies, nor does

it contain transitive dependencies A nonkey attribute is the determinant of a key attribute

Page 36: Normalization of Database Tables

Boyce/Codd Normal Form : BCNFRelation หน2"งๆ จะอย��ในร�ปแบบ BCNF ก,ต่�อเมู�"อ“1. Relation น$นๆ ต่�องอย��ในร�ปแบบ 3NF

2. ไมู�มู! Attribute อ�"นใน Relation ทำ!"สามูารถระบ1คื�าข้อง Attribute ทำ!"เป0นคื!ย�หลักหร�อส�วนหน2"งส�วนใดข้องคื!ย�หลักในกรณ!ทำ!"คื!ย�หลักเป0นคื!ย�ผิสมู(Composite Key)”

Page 37: Normalization of Database Tables

BCNF จะอย��ในร�ปแบบ 3 NF แต่�ไมู�จ�าเป0นเสมูอไปว�าร�ปแบบ 3 NF จะอย��

ในร�ปแบบข้อง BCNF เน�"องจากร�ปแบบน!$เป0นร�ปแบบทำ!"ข้ยาย

ข้อบเข้ต่ข้องร�ปแบบ 3 NF ให�เหมูาะสมูย�"งข้2$น

โดยร�ปแบบข้อง Relation ทำ!"จะต่�องผิ�านการทำ�าให�เป0น BCNF มูกจะมู!

คื1ณสมูบต่� ดงน!$

The Boyce-Codd Normal Form (BCNF)

Page 38: Normalization of Database Tables

1 .เป0น Relation ทำ!"มู! CK หลัายคื!ย�(Multiple Candidate Key)

2. CK เป0นคื!ย�ผิสมู(Composite Key)3. CK น$นมู!บางส�วนซ้ำ�$าซ้ำ�อน

กน(Overlapped)

The Boyce-Codd Normal Form (BCNF)

Page 39: Normalization of Database Tables

จะใช่� Relation SUPPLIER3 โดยสมูมูต่�ว�า SNAME เป0นคื�าไมู�ซ้ำ�$ากนแลัะมู!คื1ณสมูบต่�เป0นคื!ย�หลักได�เช่�นกน

The Boyce-Codd Normal Form (BCNF)

Page 40: Normalization of Database Tables

S# SNAME P# QTY

S1 Henry P1 300

S1 Henry P2 200

S1 Henry P3 400

S1 Henry P4 200

S1 Henry P5 100

S1 Henry P6 100

S2 Vivian P1 300

S2 Vivian P2 400

S3 Harry P2 200

S4 James P2 200

S4 James P4 300

S4 James P5 400

SUPPLIER3

Page 41: Normalization of Database Tables

จากต่วอย�างจะเป0น Relation ทำ!"มู!ป-ญหาเพื่ราะมู! CK เป0นคื!ย�ผิสมูแลัะมู!คืวามูซ้ำ�$าซ้ำ�อนกน CK ทำ!"มู!คื1ณสมูบต่�เป0นคื!ย�หลักข้องร!เลัช่น อาจเป0น S# แลัะ P# หร�อ SNAME แลัะ P#

Relation น!$ไมู�ได�อย��ในร�ปแบบ BCNF เพื่ราะเมู�"อเลั�อก CK ใดเป0นคื!ย�หลักแลั�ว CK ทำ!"ไมู�ถ�กเลั�อกจะยงปรากฎซ้ำ�$าซ้ำ�อนอย��ใน Relation น!$แลัะมู!คื1ณสมูบต่�ในการระบ1คื�าข้อง Attribute ทำ!"เป0นคื!ย�หลัก

The Boyce-Codd Normal Form (BCNF)

Page 42: Normalization of Database Tables

เช่�น หากเลั�อก S# แลัะ P# เป0นคื!ย�หลักแลั�วจะเก�ดป-ญหาใน Relation น!$คื�อ SNAME จะมู!คื1ณสมูบต่�ในการระบ1คื�าข้อง Attribute S# ดงน!$

S# SNAME P# QTY

The Boyce-Codd Normal Form (BCNF)

Page 43: Normalization of Database Tables

ดงน$น Relation SUPPLIER3 ต่�องทำ�าการแต่กร!เลัช่นออก โดยแยก attribute ทำ!"สามูารถระบ1คื�าข้อง PK แยกเป0นอ!กร!เลัช่นหน2"ง ซ้ำ2"งทำ�าได� 2 กรณ!คื�อ

1 . SUPPLIER4(S#, SNAME) ORDER2(S#, P#, QTY)

หร�อ 2. SUPPLIER4(S#, SNAME) ORDER2(SNAME, P#, QTY)

The Boyce-Codd Normal Form (BCNF)

Page 44: Normalization of Database Tables

A

B

C

D

E

The Boyce-Codd Normal Form (BCNF)

Page 45: Normalization of Database Tables

Fourth Normal Form (4NF) Table is in fourth normal form (4NF) when

both of the following are true: It is in 3NF Has no multiple sets of multivalued

dependencies 4NF is largely academic if tables conform

to following two rules: All attributes must be dependent on primary

key, but independent of each other No row contains two or more multivalued

facts about an entity

Page 46: Normalization of Database Tables

Fourth Normal Form : 4NFRelation หน2"งๆ จะอย��ในร�ปแบบ 4NF ก,ต่�อเมู�"อ“1. Relation น$นๆ ต่�องอย��ในร�ปแบบ BCNF

2. เป0น Relation ทำ!"ไมู�มู!คืวามูสมูพื่นธิ�ในการระบ1คื�าข้อง Attribute แบบหลัายคื�าโดยทำ!" Attribute ทำ!"ถ�กระบ1คื�าเหลั�าน!$ไมู�มู!คืวามูสมูพื่นธิ�กน(Independently Multivalued Dependency) ”

Fourth Normal Form (4NF)

Page 47: Normalization of Database Tables

เช่�น ผิ��ผิลั�ต่หน2"งผิลั�ต่ได�หลัายโคืรงการแลัะผิ��ผิลั�ต่หน2"งๆ มู!โรงงานต่$ง

อย��หลัายจงหวดทำ�าให�อย��ในร�ป BCNF โดยให�ทำ1ก

Attribute ประกอบกนเป0นคื!ย�หลัก

Fourth Normal Form (4NF)

Page 48: Normalization of Database Tables

S# PJ# CITY

S1 PJ1 Khonkaen

S1 PJ1 Bangkok

S1 PJ2 Khonkaen

S1 PJ2 Bangkok

S2 PJ3 Nontaburi

S2 PJ3 Chiangmai

S2 PJ4 Nontaburi

S2 PJ4 Chiangmai

SPJC

Page 49: Normalization of Database Tables

จะได�S# ->-> PJ#S# ->-> CITY

การทำ!" attribute ทำ$งสองไมู�มู!คืวามูสมูพื่นธิ�กนแต่�มูาอย��ใน Relation เด!ยวกนจะก�อให�เก�ดคืวามูซ้ำ�$าซ้ำ�อนข้องข้�อมู�ลั ถ2งแมู�ว�า Relation SPJC จะอย��ในร�ป BCNF โดยมู!ทำ1ก Attribute ประกอบเป0นคื!ย�หลักก,ต่ามูแต่�ยงมู!ป-ญหาอย��

Fourth Normal Form (4NF)

Page 50: Normalization of Database Tables

ดงน$น Relation SPJC ต่�องทำ�าการแต่กร!เลัช่นออกเป0น 2Relation ดงน!$

SPJ(S#, PJ#) SC(S#, CITY)

Fourth Normal Form (4NF)

Page 51: Normalization of Database Tables

S# PJ#

S1 PJ1

S1 PJ2

S2 PJ3

S2 PJ4

SPJ

S# CITY

S1 Khonkaen

S1 Bangkok

S2 Nontaburi

S2 Chiangmai

SC

Page 52: Normalization of Database Tables

Fifth Normal Form : 5NFFifth Normal Form : 5NF

Relation หน2"งๆ จะอย��ในร�ปแบบ 5NF ก,ต่�อเมู�"อ“1. Relation น$นๆ ต่�องอย��ในร�ปแบบ 4NF

2. ไมู�มู! Symmetric Constraint กลั�าวคื�อ หากมู!การแต่กRelation ออกเป0น Relation ย�อย(Projection) แลัะเมู�"อทำ�าการเช่�"อมูโยง Relation ย�อยทำ$งหมูด(Join ) จะไมู�ก�อให�เก�ดข้�อมู�ลัใหมู�ทำ!"ไมู�เหมู�อน Relation เด�มู(Spurious Tuple)”

Page 53: Normalization of Database Tables

เช่�น Relation SPP ประกอบด�วย SNAME, PNAME, PJNAME โดยมู! Attribute ทำ$ง 3 เป0นคื!ย�หลักSNA

MEPNAME

PJNAME

Henry

PEN PJ2

Henry

TABLE

PJ1

James

PEN PJ1

Henry

PEN PJ1

Fifth Normal Form : 5NF

Page 54: Normalization of Database Tables

Normal FormRelation SPP อย��ใน 4 NF

ด�วยการให� Attribute ทำ$ง 3 ประกอบกนเป0นคื!ย�หลัก แต่�ยงมู!ป-ญหาในการปรบปร1งข้�อมู�ลัต่�างๆ

เพื่�"อหลั!กเลั!"ยงป-ญหา จ2งทำ�าการแต่ก Relation SPP เป0น 3Relation ย�อย(Projection) โดยแต่�ลัะ Relation ย�อยจะประกอบด�วย Attribute ต่�อลัะคื��เป0นคื!ย�หลัก

Page 55: Normalization of Database Tables

Normal Form

SNAME

PNAME

Henry

PEN

Henry

TABLE

James

PEN

PNAME

PJNAME

PEN PJ2TABL

EPJ1

PEN PJ1

PJNAME

SNAME

PJ2 Henry

PJ1 Henry

PJ1 James

SP PPJ PJS

Page 56: Normalization of Database Tables

ดงน$น หากมู!การแต่กร!เลัช่"นออกมูาแลั�วทำ�าการเช่�"อมูโยงร!เลัช่"นย�อยน$นใหมู� หากไมู�มู!ข้�อมู�ลัทำ!"แต่กต่�างไปจากร!

เลัช่"นเด�มู ก,สามูารถจะแต่กร!เลัช่"นน$นได� แต่�ถ�าหากแต่กเป0นร!เลัช่"นย�อยแลั�วเก�ดข้�อมู�ลัไมู�เหมู�อนกบร!เลัช่"นเด�มูก,ไมู�คืวรแต่กร!เลัช่นให�ถ�อว�าร!เลัช่นเด�มูอย��ใน

5 NF แลั�ว

Fifth Normal Form : 5NF

Page 57: Normalization of Database Tables

S# CITY PJ#S1 New

YorkPJ1

S1 Paris PJ2S3 Paris PJ1

SCPJ

Fifth Normal Form : 5NF

Page 58: Normalization of Database Tables

S# CITYS1 New

YorkS1 ParisS3 Paris

CITY PJ#New York

PJ1

Paris PJ2Paris PJ1

S# PJ#S1 PJ1S1 PJ2S3 PJ1

Fifth Normal Form : 5NF

Page 59: Normalization of Database Tables

S# CITY PJ#S1 New

YorkPJ1

S1 Paris PJ2S1 Paris PJ1S3 Paris PJ1

Spurious Tuple

Fifth Normal Form : 5NF

Page 60: Normalization of Database Tables

แบบฝึ�กหั�ดทำ�ายบทำ1. When is a table in 1NF?2. When is a table in 2NF? 3. When is a table in 3NF? 4. When is a table in BCNF?5. Define and discuss the concept of transitive dependency.

Page 61: Normalization of Database Tables

แหัล่!งอ�างอ"งข�อมู�ล่Database Systems:

Design, Implementation, and Management, Seventh Edition,

Rob and Colonel