37
กกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกก กกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกก กกกกกกกกกกกกกกกกกกกก alization. Normalization is a formal method involved with a series of test to help database designer to be able to identify the optimal grouping of attributes for each relation in the relational schema. Normalization can be applied to individual relations so that database can be normalized to a specific form to prevent the possible occurrence of update anomaly. Normalization

การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Embed Size (px)

Citation preview

Page 1: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

การตรวจสอบความถู กต�องของการออกแบบระบบฐานข�อม ล ต�องม�ขบวนการการตรวจสอบอย่�างเป็�นข��นตอน เราเร�ย่กขบวนการน��ว�า

Normalization.

Normalization is a formal method involved with a series of test to help database designer to be able to identify the optimal grouping of attributes for each relation in the relational schema. Normalization can be applied to individual relations so that database can be normalized to a specific form to prevent the possible occurrence of update anomaly.

Normalization

Page 2: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Data Redundancy and Update Anomalies

วั�คถุ�ประสงค�หลั�กของการออกแบบระบบฐานข�อมู�ลัค�อ การ จั�ดกลั��มู attributes

ในแต่�ลัะร�เลัชั่�"นเพื่�"อลัดควัามูซ้ำ%&าซ้ำ�อนของข�อมู�ลั ซ้ำ'"งส�งผลัถุ'งการประหยั�ดเน�&อที่�"ในการจั�ดเก+บฐานข�อมู�ลัด�วัยั

ร�เลัชั่�"นที่�"มู�ข�อมู�ลัซ้ำ%&าซ้ำ�อนมูาก ก�อป,ญหา UPDATE ANOMALIES ซ้ำ'"งแบ�งออกเป.น 3 ประเภที่ค�อ

Insertion anomalies

Deletion Anomalies

Modification Anomalies

Page 3: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Insertion Anomalies

Deletion Anomalies

Modification Anomalies

Page 4: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Insertion Anomalies

To insert the details of new members of staff into the Staff_Branch relation, we must include the details of the branch at which the staff are to be located.

Deletion Anomalies

If we delete a row from the Staff_Branch relation thatrepresents the last member of staff located at a branch, the detailsabout that branch are also lost from the database.

Modification Anomalies

If we want to change the value of one of the attributes of a particular branch in the Staff_Branch relation, we must update the rows of all staff located at that branch. If this modification is not carried out on all the appropriate rows of the Staff_Branch relation, the data base will become inconsistent.

Page 5: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Staff_No SName SAddress Position Salary Branch_No BAddress Tel_No

SL21 John White 19 Taylor St, London Manager 30000 B5 22 Dear Rd,London 02-704-8109

SG37 Ann Beech 81 George St, Glasgow Snr Asst 12000 B3 163 Main St,Glasgow 02-953-8018

SG14 David Ford 63 Ashby St, Glasgow Deputy 18000 B3 163 Main St,Glasgow 02-255-8128

SA9 Mary Howe 2 Elm Pl, Aberdeen Assistant 9000 B7 16 Argyll St, Aberde 02-775-4995

SG5 Susan Brand 5 Gt Western Rd, Glas Manager 24000 B3 163 Main St,Glasgow 02-987-1234

SL41 Julie Lee 28 Malvern St,Kilburn Assistant 9000 B5 22 Dear Rd,London 02-342-5616

Staff_Branch Relation

Snew1 Julie Lee 28 Malvern St,Kilburn Assistant 9000Snew1 Yupin New 2 Ngamvongvan,BKK Snr Mgr 22000 B3 163 Main St,Glasgow 02-255-8128

B8 16 Lake Show 02-221-8128NULL NULL NULL NULL NULL B8 16 Lake Show 02-221-8128

Page 6: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Staff_No SName SAddress Position Salary Branch_No BAddress Tel_No

SL21 John White 19 Taylor St, London Manager 30000 B5 22 Dear Rd,London 02-704-8109

SG37 Ann Beech 81 George St, Glasgow Snr Asst 12000 B3 163 Main St,Glasgow 02-953-8018

SG14 David Ford 63 Ashby St, Glasgow Deputy 18000 B3 163 Main St,Glasgow 02-255-8128

Staff_Branch Relation

SG5 Susan Brand 5 Gt Western Rd, Glas Manager 24000 B3 163 Main St,Glasgow 02-987-1234

SL41 Julie Lee 28 Malvern St,Kilburn Assistant 9000 B5 22 Dear Rd,London 02-342-5616

SA9 Mary Howe 2 Elm Pl, Aberdeen Assistant 9000 B7 16 Argyll St, Aberde 02-775-4995

Delete Anomalies

Page 7: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Staff_No SName SAddress Position Salary Branch_No BAddress Tel_No

SL21 John White 19 Taylor St, London Manager 30000 B5 22 Dear Rd,London 02-704-8109

SG37 Ann Beech 81 George St, Glasgow Snr Asst 12000 B3 163 Main St,Glasgow 02-953-8018

SG14 David Ford 63 Ashby St, Glasgow Deputy 18000 B3 163 Main St,Glasgow 02-255-8128

SA9 Mary Howe 2 Elm Pl, Aberdeen Assistant 9000 B7 16 Argyll St, Aberde 02-775-4995

SG5 Susan Brand 5 Gt Western Rd, Glas Manager 24000 B3 163 Main St,Glasgow 02-987-1234

SL41 Julie Lee 28 Malvern St,Kilburn Assistant 9000 B5 22 Dear Rd,London 02-342-5616

Staff_Branch Relation

Modification Anomalies

Page 8: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Functional Dependencies

One of the main concepts associated with normalization is functional dependency, which describes the relationship between attributes.

น�ย่ามของกฎเกณฑ์"ของการข#�นต�อก�น(Definition of Functional Dependency)

ระบ�ไวั�วั�า สมูมู�ต่1ให� B เป.นแอต่ที่ร1บ1วัต่�วัหน'"ง แลัะ A แอต่ที่ร1บ1วัอ�กต่�วัหน'"ง ( A อาจัเป.นเซ้ำ+ต่ของแอต่ที่ร1บ1วัก+ได�)

เรากลั�าวัวั�า B เป.นฟั,งก�ชั่� "นการข'&นอยั��ก�บ A (denoted A B) ก+ต่�อเมู�"อค�าของ A สามูารถุใชั่�ในการเลั�อก (determine)

ค�าของ B ได�เพื่�ยัง 1 ค�าเสมูอ ส�ญญลั�กษณ์�การข'&นต่�อก�น (A B) อ�านได�ด�งน�&

B มู�ฟั,งก�ชั่�"นการข'&นอยั��ก�บ A หร�อ A มู�ฟั,งก�ชั่�"นในการเลั�อก B หร�อ B ข'&นก�บ A

Page 9: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Functional Dependencies อน�ญาต่ให�ผ��ใชั่�ระบ�กฏเกณ์ฑ์�การ ข'&นต่�อก�นด�วัยั attribute ที่�"ไมู�ได�เป.น candidate key ได� เชั่�น

( โดยัที่�" ไมู�ได�เป.น candidate key)

ส%าหร�บที่�ก ๆ แถุวัในร�เลัชั่�"น r หากแถุวัใดที่�"มู�ค�าในแอต่ที่ร1บ1วั เหมู�อนก�น ระบบต่�อง ร�บประก�นวั�า ในบรรดาแถุวัเหลั�าน�&น ต่�องมู�ค�าของแอต่ที่ร1บ1วั ที่�"เหมู�อนก�นด�วัยั กลั�าวัค�อ

ถุ�า holds on R ด�งน�&น ถุ�า t1[] = t2[] ระบบต่�องร�บประก�นวั�า t1[] = t2[]

Given a relation R, attribute y of R is dependent on attribute x of R if and only if whenever two tuples of R agree on their x-value,they must necessarily agree on their y-value.

Page 10: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

A BB is functionallydependent on A

When a functional dependency exists, the attribute or groupOf attributes on the left-hand side of the arrow is called the determinant.

Staff_No PositionPosition is functionally

dependent on Staff_No

SL21 System Engineer

Position Staff_NoStaff_No is not functionallydependent on Position

System Engineer SL21

SG5

Page 11: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Staff_No SName, Saddress, Position, Salary, Branch_NoBranch_No BAddress, Tel_NoBAddress Branch_No

Page 12: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Normalization is a formal method involved with a series of test to help database designer to be able to identify the optimal grouping of attributes for each relation in the relational schema.

Unnormalized Form

1st Normal Form

2nd Normal Form

3rd Normal Form

Boyce-Codd Normal Form

Normalization can be applied to individual relations so that database can be normalized to a specific form to prevent the possible occurrence of update anomaly.

The process of normalization is a formalmethod that identifies relations based onprimary key (or candidate keys in the case of BCNF the functional dependencies among their attributes.

Page 13: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Relationships of Normal Forms1NF

2NF

3NF/BCNF

4NF

5NF

DKNFHigherNormalforms

Page 14: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน
Page 15: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Case StudyThe DreamHome company manages property on behalf of the owners, and as part of this service, the company takes care of the property’s rental. To simplify this example, we assume that a customer rents a given property only once, and cannot rent more than one property at any one time.

Unnormalized form (UNF) : A table that contains one or more repeating groups.

A repeating group is an attribute or group of attributes within a table that occurs with multiple values for a single occurrence of the key attribute (s) for that table. The term key refers to the attribute (s)That uniquely identify each row within the unnormalized table.

Custome_No CName Property_No PAddress Rent RentStart RentFinish Owner_No OName

CR76 John Kay PG4

PG16

6 Lawrence St,

5 Norwar Dr

350

450

1-Jul-94

1-Sep-96

31-Aug-96

1-Sep-98

CO40

CO93

Tina Murphy

Tony Shaw

CR56 Aline

Stewart

PG4

PG36

PG16

6 Lawrence St,

2 Manor Rd,

5 Norwar Dr

350

375

450

1-Sep-92

10-Oct-94

1-Jan-96

10-Jan-94

1-Dec-95

10-Aug-96

CO40

CO93

CO93

Tina Murphy

Tony Shaw

Tony Shaw

Customer_Rental Relation

Page 16: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

First normal form (1NF) : A relation in which the intersection of each row and column contains one and only one value.

For the relational data model, it is important to recognize that it is only first normal form(1NF) that is critical in creating appropriate relations. All the subsequent normal forms are optional. However, to avoid the update anomalies, it is recommended that we proceed to at least 3NF.

Custome_No Property_No CName PAddress Rent RentStart RentFinish Owner_No OName

CR76 PG4 John Kay 6 Lawrence St, 350 1-jul-94 31-Aug-96 CO40 Tina Murphy

CR76 PG16 John Kay 5 Norwar Dr 450 1-Sep-98 1-Sep-98 CO93 Tony Shaw

CR56 PG4 Aline Stew 6 Lawrence St, 350 10-Jun-94 10-Jun-94 CO40 Tina Murphy

CR56 PG36 Aline Stew 2 Manor Rd, 375 1-Dec-95 1-Dec-95 CO93 Tony Shaw

CR56 PG16 Aline Stew 5 Norwar Dr 450 10-Aug-96 10-Aug-96 CO93 Tony Shaw

Customer_Rental Relation

Page 17: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Set of the Functional Dependency of Customer_Rental relation

fd1 Customer_No, Property_No RentStart, RentFinish (Primary key)

fd2 Customer_No CName (Partial dependency)

fd3 Property_No PAddress, Rent, Owner_No, OName (Partial dependency)

fd4 Owner_No OName (Transitive dependency)

fd5 Customer_No, RentStart Property_No, PAddress, RentFinish, Rent, Owner, OName (Candidate key)

fd6 Property_No, RentStart Customer_No, CName, RentFinish (Candidate key)

Page 18: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Customer_No Property_No CName RentFinish RentPAddress Owner_NoRentStart OName

(Primary key)

(Partial dependency)(Partial dependency)

(Transitive dependency)

(Candidate key)

(Candidate key)

fd1

fd2

fd3

fd5

fd6

fd6

Page 19: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

A relation that is in the first normal form and every non-primary key attribute is fully functionally dependent on the primary key.

Second Normal Form (2NF) :

Full functional : Indicates that if A and B are attributes of a relation, B is fully functionally dependentdependency on A if B is functionally dependent on A, but not on any proper subset of A.

ถุ�า B เป.น Non-Key attribute ซ้ำ'"งมู�ฟั,งก�ชั่� "นการข'&นต่�อก�นอยั��ก�บส�วันใดส�วันหน'"ง ของค�ยั�หลั�ก เราจัะเร�ยักวั�า B

partial dependence on A. Partial dependency ต่�องถุ�กขจั�ดออกโดยั การแยัก ออกไปต่�&งเป.นต่ารางใหมู� เพื่�"อให�

Non-Key attribute ต่�วัน�& fully dependent on ค�ยั�หลั�กCustomer_No Property_No CName RentFinish RentPAddress Owner_NoRentStart

(Primary key)

(Partial dependency)

(Partial dependency)

fd1

fd2

fd3

OName

Page 20: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

2NF applies to relations with composite keys, that is, relations with a primary key composed of two or more attributes. A relation with a single attribute primary key is automatically in at least 2NF.

Customer (Customer_No, CName)

Customer_No CName

CR76 John Kay

CR56 Aline Stewart

Customer_No Property_No

RentStart RentFinish

CR76 PG14 1-Jul-94 31-Aug-96

CR766 PG16 1-Sep-96 1-Sep-98

CR56 PG4 1-Sep-92 10-Jun-94

CR56 PG36 10-Oct-94 1-Dec-95

CR56 PG16 1-Jan-96 10-Aug-96

Customer RelationRental Relation

Property_No PAddress Rent Owner_No OName

PG14 6 Lawrence St, 350 CO40 Tina Murphy

PG16 5 Norwar Dr 450 CO93 Tony Shaw

PG36 2 Manor Rd, 375 CO93 Tony Shaw

Property-Owner Relation

Rental (Customer_No, Property_No, RentStart, RentFinish)Property_Owner (Property_No, PAddress, Rent, Owner_No, OName)

Page 21: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Transitive dependency

Property_No PAddress Rent Owner_No OName

PG14 6 Lawrence St, 350 CO40 Tina Murphy

PG16 5 Norwar Dr 450 CO93 Tony Shaw

PG36 2 Manor Rd, 375 CO93 Tony Shaw

Property-Owner Relation

Customer (Customer_No, CName)Rental (Customer_No, Property_No, RentStart, RentFinish)Property_Owner (Property_No, PAddress, Rent, Owner_No, OName)

Transitive dependency

Customer_No CName

CR76 John Kay

CR56 Aline Stewart

Customer_No Property_No

RentStart RentFinish

CR76 PG14 1-Jul-94 31-Aug-96

CR766 PG16 1-Sep-96 1-Sep-98

CR56 PG4 1-Sep-92 10-Jun-94

CR56 PG36 10-Oct-94 1-Dec-95

CR56 PG16 1-Jan-96 10-Aug-96

Customer Relation Rental Relation

Page 22: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Transitive dependency : A condition where A, B, and C are attributes of a relation such that if A B and B C, then C is transitively dependent on A via B (provided that A is not functionally dependent on B or C).

Definition of Third Normal Form:

A relation that is in first and second normal form, and in which no non-primary key attributeis transitively dependent on the primary key.

Property_No PAddress Rent Owner_No

PG14 6 Lawrence St, 350 CO40

PG16 5 Norwar Dr 450 CO93

PG36 2 Manor Rd, 375 CO93

Property-for-Rent Relation

Customer (Customer_No, CName)Rental (Customer_No, Property_No, RentStart, RentFinish)Property_Owner (Property_No, PAddress, Rent, Owner_No, OName)

Owner_No OName

C040 Tina Murphy

Co93 Tony Shaw

Owner Relation

Page 23: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Custome_No Property_No CName PAddress Rent RentStart RentFinish Owner_No OName

CR76 PG4 John Kay 6 Lawrence St, 350 1-jul-94 31-Aug-96 CO40 Tina Murphy

CR76 PG16 John Kay 5 Norwar Dr 450 1-Sep-98 1-Sep-98 CO93 Tony Shaw

CR56 PG4 Aline Stew 6 Lawrence St, 350 10-Jun-94 10-Jun-94 CO40 Tina Murphy

CR56 PG36 Aline Stew 2 Manor Rd, 375 1-Dec-95 1-Dec-95 CO93 Tony Shaw

CR56 PG16 Aline Stew 5 Norwar Dr 450 10-Aug-96 10-Aug-96 CO93 Tony Shaw

Customer_Rental Relation

Customer (Customer_No, CName)Rental (Customer_No, Property_No, RentStart, RentFinish)Property (Property_No, PAddress, Rent, Owner_No)Owner (Owner_No, Oname)

Page 24: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Customer_No CName

CR76 John Kay

CR56 Aline Stewart

Customer_No Property_No

RentStart RentFinish

CR76 PG14 1-Jul-94 31-Aug-96

CR766 PG16 1-Sep-96 1-Sep-98

CR56 PG4 1-Sep-92 10-Jun-94

CR56 PG36 10-Oct-94 1-Dec-95

CR56 PG16 1-Jan-96 10-Aug-96

Customer Relation

Rental Relation

Property_No

PAddress Rent Owner_No

PG14 6 Lawrence St, 350 CO40

PG16 5 Norwar Dr 450 CO93

PG36 2 Manor Rd, 375 CO93

Property-Owner Relation

Owner_No OName

CO40 Tina Murphy

CO93 Tony Shaw

Owner Relation

Customer_Rental

Customer Rental

Property_Owner

Property_for_Rent Owner

1NF

2NF

3NF

Page 25: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

From 3NF to Boyce-Codd Normal Form (BCNF)

The difference between 3NF and BCNF is that for a functional dependency AB, 3NF allows this dependency in a relation if B is a primary-key attribute and A is not a candidate key. Whereas, BCNF insists that for this dependency to remain in a relation, A must be a candidate key. Therefore, BCNF is a stronger form of 3NF, such every relation in BCNF is also in 3NF.

BCNF is based on functional dependencies that take into account all candidate keys in a relation. For a relation with only one candidate key, 3NF and BCNF are equivalent.

Boyce-Codd : A relation is in BCNF if and only if every determinant is normal form (BCNF) a candidate key.

Violation of BCNF is quite rare, since it may only happen under specific conditions. The potential to violate BCNF may occur in relation that

• contains two (or more) composite candidate keys and

• which overlap, that is share at least one attribute in common

Page 26: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Case Study

In this example, Client_Interview relation is presented. It contains details of the arrangements for interviews of clients by members of staff of the DreamHome company. The members of staff involved in interviewing clients are allocated to a specific room on the day of interview. However, a room may be allocated to several members of staff as required throughout a working day. A client is only interviewed once on a given date, but may be requested to attend further interviews at later dates. This relation has three candidate keys:

(Client_No, Interview_Date), (Staff_No, Interview_Date, Interview_Time), and (Room_No, Interview_Date, Interview_Time).

Therefore the Client_Interview relation has three composite candidate keys, which overlap by sharing the common attribute Interview_Date. We select Client_No, Interview_Date) to act as the primary key for this relation.

Page 27: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Fd1 Client_No, Interview_Date Interview_Time, Staff_No, Room_No (Primary key)

Fd2 Staff_No, Interview_Date, Interview_Time Client_No (Candidate key)

Fd3 Room_No, Interview_Date, Interview_Time Staff_No, Client_No (Candidate key)

Fd4 Staff_No, Interview_Date Room_No

Client_Interview (Client_No, Inverview_Date, Interview_Time, Staff_No, Room_No)

The Client_Interview relation has the following functional dependencies :

Client_No Interview_Date Interview_Time Staff_No Room_No

CR76 13-May-98 10:30 SG5 G101

CR56 13-May-98 12:00 SG5 G101

CR74 13-May-98 12:00 SG37 G102

CR56 1-Jul-98 10:30 SG5 G102

Client_Interview Relation

Page 28: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Client_No Interview_Date Interview_Time Staff_No

CR76 13-May-98 10:30 SG5

CR56 13-May-98 12:00 SG5

CR74 13-May-98 12:00 SG37

CR56 1-Jul-98 10:30 SG5

Interview Relation

Staff_No Interview_Date Room_No

SG5 13-May-98 G101

SG37 13-May-98 G102

SG5 1-Jul-98 G102

Staff_Room Relation

Interview (Client_No, Interview-Date, Interview_Time, Staff_No)

Staff_Room (Staff_No, Interview-Date, Room_No)

Page 29: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Review of Normalization (1NF to BCNF)

The DreamHome company manages property on behalf of the owners, and as part of this service the company undertakes regular inspections of the property by members of staff. When staff are required to undertake these inspections, they are allocated a company car for use on the day of the inspections. However, a car may be allocated to several members of staff, as required throughout the working day. A member of staff may inspect several properties on a given date, but a property is only inspected once on a given date.

Property_No PAddress IDate ITime Comments Staff_No SName Car_Reg

PG4 6 Lawrence St, 18-Oct-96

22-Apr-97

1-Oct-98

10:00

09:00

12:00

Need to replace crockery

In good order

Damp rot in bathroom

SG37

SG14

SG14

Ann Beech

David Ford

David Ford

M231 JGR

M533 HDR

N721 HFR

PG16 5 Norwar Dr 22-Apr-96

24-Oct-97

13:00

14:00

Replace room carpet

Good condition

SG14

SG37

David Ford

Ann Beech

M533 HDR

N721 HFR

Property_Inspection Relation

Property_Inspection (Property_No, PAddress, IDate, ITime, Comments, Staff_No, SName, OName)

Page 30: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

1NF : Property_Inspection Relation

Property_No IDate ITime PAddress Comments Staff_No SName Car_Reg

PG4 18-Oct-96 10:00 6 Lawrence St, Need to replace crockery SG37 Ann Beech M231 JGR

PG4 22-Apr-97 09:00 6 Lawrence St, In good order SG14 David Ford M533 HDR

PG4 1-Oct-98 12:00 6 Lawrence St, Damp rot in bathroom SG14 David Ford N721 HFR

PG16 22-Apr-96 13:00 5 Norwar Dr Replace room carpet SG14 David Ford M533 HDR

PG16 24-Oct-97 14:00 5 Norwar Dr Good condition SG37 Ann Beech N721 HFR

Property_Inspection (Property_No, IDate, ITime, PAddress, Comments, Staff_No, SName, OName)

Property_No IDate ITime PAddress Comments Staff_No SName Car_Reg

(Partial dependency)

(Primary key)

(Transitive dependency)

(Candidate key)

(Candidate key)

FD1

FD2

FD3

FD4

FD5

FD6

Page 31: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Property_No IDate ITime PAddress Comments Staff_No SName Car_Reg

(Partial dependency)

(Primary key)FD1

FD2

Property Relation

Property_No PAddress

PG4 6 Lawrence St,

PG16 5 Norwar Dr

Property_Inspection Relation

Property_No IDate ITime Comments Staff_No SName Car_Reg

PG4 18-Oct-96 10:00 Need to replace crockery SG37 Ann Beech M231 JGR

PG4 22-Apr-97 09:00 In good order SG14 David Ford M533 HDR

PG4 1-Oct-98 12:00 Damp rot in bathroom SG14 David Ford N721 HFR

PG16 22-Apr-96 13:00 Replace room carpet SG14 David Ford M533 HDR

PG16 24-Oct-97 14:00 Good condition SG37 Ann Beech N721 HFR

Remove Partial dependency (decompose the relation) to obtain 2NF

Page 32: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Property Relation (Property_No, PAddress)

Property_No PAddress

PG4 6 Lawrence St,

PG16 5 Norwar Dr

Property_Inspection Relation

Property_No IDate ITime Comments Staff_No SName Car_Reg

FD1

FD3

FD4

FD5

FD6

(Primary key)

(Transitive dependency)

(Candidate key)

(Candidate key)

Page 33: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Property Relation

Property_No PAddress

PG4 6 Lawrence St,

PG16 5 Norwar Dr

Property_Inspection Relation

Property_No IDate ITime Comments Staff_No Car_Reg

PG4 18-Oct-96 10:00 Need to replace crockery SG37 M231 JGR

PG4 22-Apr-97 09:00 In good order SG14 M533 HDR

PG4 1-Oct-98 12:00 Damp rot in bathroom SG14 N721 HFR

PG16 22-Apr-97 13:00 Replace room carpet SG14 M533 HDR

PG16 24-Oct-97 14:00 Good condition SG37 N721 HFR

Remove Transitive dependency (decompose the relation) to obtain 3NF

Staff Relation

Staff_No SName

SG37 Ann Beech

SG14 David Ford

Page 34: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Property Relation

Property_No PAddress

PG4 6 Lawrence St,

PG16 5 Norwar Dr

Property_Inspection Relation

Property_No IDate ITime Comments Staff_No Car_Reg

Remove remaining anomalies from functional dependencies to obtain BCNF

Staff Relation

Staff_No SName

SG37 Ann Beech

SG14 David Ford

Staff_Car (Staff_No, IDate, Car_Reg)Inspection (Property_No, IDate, ITime, Comments, Staff_No)

Page 35: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

From BCNF to Fourth Normal Form (4NF)

Although BCNF removes any anomalies due to functional dependencies, further research led to the identification of another type of dependency called multi-valued dependency (MVD), which can cause similar design problems for relations in terms of data redundancy.

Lecturer_Name Subject Research

Yuen Data Structure Natural Language Processing

Yuen Data Structure Protocal Analyzer

Yuen Discrete Math Natural Language Processing

Yuen Discrete Math Protocal Analyzer

Yuen Data Base Natural Language Processing

Yuen Data Base Protocal Analyzer

Chalerrmsak Data Structure Protocal Analyzer

Chalerrmsak Data Structure Compiler Utilities

Chalerrmsak Data Structure Natural Language Processing

ต่ารางต่�อไปน�&เป.น BCNF แต่�ยั�งเก1ดป,ญหา update anomaliesLect_Sub_Research Relation

Page 36: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Multi-valued : Represents a dependency between attributes (for example, A,dependency B, and C) in a relation, such that for each value of A there is a (MVD) set of values for B, and a set of values for C. However, the set

of values for B and C are independent of each other.

A > BA > C

Lecturer > SubjectLecturer > Research

Lecturer_Name Subject Research

Yuen Data Structure Natural Language Processing

Yuen Data Structure Protocal Analyzer

Yuen Discrete Math Natural Language Processing

Yuen Discrete Math Protocal Analyzer

Yuen Data Base Natural Language Processing

Yuen Data Base Protocal Analyzer

Chalerrmsak Data Structure Protocal Analyzer

Chalerrmsak Data Structure Compiler Utilities

Chalerrmsak Data Structure Natural Language Processing

Lec_Sub_Research Relation

Lecturer_Name Subject

Yuen Data Structure

Yuen Discrete Math

Yuen Data Base

Chalerrmsak Data Structure

Lec_Sub Relation

Lecturer_Name Research

Yuen Natural Language Processing

Yuen Protocal Analyzer

Chalerrmsak Protocal Analyzer

Chalerrmsak Compiler Utilities

Chalerrmsak Natural Language Processing

Lec_Research Relation

Page 37: การตรวจสอบความถูกต้องของการออกแบบระบบฐานข้อมูล ต้องมีขบวนการการตรวจสอบอย่างเป็นขั้นตอน

Unnormalized form (UNF)

First normal form (1NF)

Second normal form (2NF)

Third normal form (3NF)

Boyce-Codd form (BCNF)

Fourth normal form (4NF)

Remove repeating groups

Remove partial dependencies

Remove transitive dependencies

Remove remaining anomalies From functional dependencies

Remove multi-valued dependencies