1 / 18

Normalization

Normalization. การลดความซ้ำซ้อนของข้อมูล อ.กรรณิการ์ มาระโภชน์. Normalization. Normalization คือ กระบวนการปรับปรุงโครงสร้างข้อมูลของฐานข้อมูลที่มีความซ้ำซ้อนให้อยู่ในรูปแบบที่เป็นบรรทัดฐาน Normal Form มีอยู่ 3 ระดับด้วยกัน คือ 1. Normal Form ระดับที่ 1 หรือเรียกว่า 1NF

italia
Télécharger la présentation

Normalization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Normalization การลดความซ้ำซ้อนของข้อมูล อ.กรรณิการ์ มาระโภชน์

  2. Normalization • Normalization คือ กระบวนการปรับปรุงโครงสร้างข้อมูลของฐานข้อมูลที่มีความซ้ำซ้อนให้อยู่ในรูปแบบที่เป็นบรรทัดฐาน • Normal Form มีอยู่ 3 ระดับด้วยกัน คือ 1. Normal Form ระดับที่ 1 หรือเรียกว่า 1NF 2. Normal Form ระดับที่ 2 หรือเรียกว่า 2NF 3. Normal Form ระดับที่ 3 หรือเรียกว่า 3NF

  3. Normalization (ต่อ) • นอกจากนี้ยังมีระดับที่ทำให้ Normal Form ระดับที่ 3 มีความแข็งแกร่งขึ้นกว่าเดิม เรียกว่า BCNF ( Boyce-Codd Normal Form) ซึ่งพัฒนาขึ้นโดย R.Boyce และ E.F.Codd โดย Normal Form ทุกระดับตั้งอยู่บนพื้นฐานของฟังก์ชันการขึ้นต่อกันระหว่างแอททริบิวต์ของ Relation ( Functional Dependency ) • Normal Form ในระดับที่สูงขึ้นไปอีกที่อยู่ถัดจาก BCNF ก็ได้ถูกพัฒนาขึ้น คือ Normal Form ระดับที่ 4 ( 4NF) และระดับที่ 5 (5NF) ซึ่งพัฒนาโดย Fagin(1977,1979) อย่างไรก็ตามรูปแบบ 4NF และ 5NF ในทางปฏิบัติถือว่าเกิดขึ้นได้ยากมาก

  4. วัตถุประสงค์ในการทำให้เป็นรูปแบบบรรทัดฐานวัตถุประสงค์ในการทำให้เป็นรูปแบบบรรทัดฐาน • เพื่อลดความซ้ำซ้อนของข้อมูลที่จัดเก็บในแต่ละรีเลชัน ทำให้เกิดประโยชน์ดังนี้ • ประหยัดเนื้อที่ในการจัดเก็บข้อมูล • ลดปัญหาขาดความถูกต้องของข้อมูล • ลดปัญหาที่เกิดจากการปรับปรุง เพิ่มเติม และลบข้อมูล

  5. กระบวนการ Normalization Steps in normalization

  6. First Normal Form (1NF) “Relation ที่อยู่ในรูป 1NF ถ้า ค่าของ Attribute เป็น atomic นั่นคือ มีค่าเพียงค่าเดียวเท่านั้นไม่สามารถแบ่งแยกได้”

  7. Normalization into 1 NF Dname Dnumber Dmgrssn Dlocation Research 5 33344 {Bellaire,sugarland,houston} Administration 5 98765 stafford Headquarter 1 88866 Houston Relation schema that is not in 1NF 1NF relation with redundancy Dname Dnumber Dmgrssn Dlocation Research 5 33344 Bellaire Research 5 33344 sugarland Research 5 33344 houston Administration 5 98765 stafford Headquarter 1 88866 Houston

  8. ฟังก์ชันการขึ้นตรงต่อกัน (Functionally Dependent :FD) • ใน Relation ใดๆ Attribute Y เป็น FD กับ Attribute X ก็ต่อเมื่อ ถ้าทราบค่า X จะต้องทราบค่าของ Y • สัญลักษณ์ • S.SID  S.SName • S.SID  S.City • S.SID  S.(SName,City)

  9. 2st Normal Form (2NF) • Relation ใดๆจะเป็น 2NF ก็ต่อเมื่อ • ต้องมีคุณสมบัติเป็น 1NF • ทุกๆ Non-keyAttribute ต้องเป็น Fully FD กับ Primary Key เท่านั้นนั่นคือ ไม่มี Non-keyAttribute ตัวใดที่เป็น Partially FD กับ Primary key

  10. Key Attribute SSN PNUMBER HOURS ENAME PNAME PLOCATION FD1 Non-Key Attribute FD2 FD3 ไม่อยู่ใน 2 NF เนื่องจาก FD2,FD3

  11. Second Normal Form Emp_Proj SSN PNUMBER HOURS ENAME PNAME PLOCATION FD1 Ssn,Pnumber  Hours FD2 Ssn  Ename FD3 Pnumber  Pname,Plocation SSN PNUMBER HOURS Emp_Proj1 แตกให้อยู่ใน รูป2 NF SSN ENAME Emp_Proj2 PNUMBER PNAME PLOCATION Emp_Proj3

  12. EmpID CourseTitle Name DeptName Salary DateCompleted EmpID, CourseTitle  DateCompleted EmpID  Name, DeptName, Salary Functional Dependencies in EMPLOYEE Dependency on entire primary key Dependency on only part of the key Therefore, NOT in 2nd Normal Form!!

  13. EmpID Name DeptName Salary EmpID CourseTitle DateCompleted Getting it into 2nd Normal Form • decomposed into two separate relations Both are full functional dependencies

  14. Third Normal Form : 3NF “Relation ที่อยู่ในรูปของ 3NF ก็ต่อเมื่อ 1.Relation ที่อยู่ในรูป 2 NF 2.ต้องไม่มี FD ระหว่าง Non-key Attribute หรือไม่มี Transitively FD on Primary Key”

  15. Relation with transitive dependency (a) SALES relation with simple data

  16. Relation with transitive dependency CustID  Name CustID  Salesperson CustID  Region All this is OK (2nd NF) BUT Salesperson  Region FD ระหว่าง Non-key Attribute

  17. Removing a transitive dependency (a) Decomposing the SALES relation

  18. Relations in 3NF Salesperson  Region CustID  Name CustID  Salesperson Now, there are no transitive dependencies… Both relations are in 3rd NF

More Related