Multi-valued Dependency คืออะไร?
เมื่อการมีอยู่ของแถว (Row) หนึ่งหรือมากกว่าในตาราง บ่งชี้ถึงแถวอื่นหนึ่งหรือมากกว่าในตารางเดียวกัน Multi-valued Dependency จึงเกิดขึ้น
ถ้าตารางมีแอตทริบิวต์ P, Q และ R แล้ว Q และ R เป็น multi-valued facts ของ P
แสดงด้วยลูกศรคู่ (Double Arrow):
| P ->> Q | P ->> R |
|---|
Multi-valued Dependency จะมีอยู่ก็ต่อเมื่อ Q และ R เป็นแอตทริบิวต์ที่ อิสระต่อกัน (Independent)
ตารางที่มี Multi-valued Dependency จะ ละเมิด 4NF
ตัวอย่าง
<Student>
| StudentName | CourseDiscipline | Activities |
|---|---|---|
| Amit | Mathematics | Singing |
| Amit | Mathematics | Dancing |
| Yuvraj | Computers | Cricket |
| Akash | Literature | Dancing |
| Akash | Literature | Cricket |
| Akash | Literature | Singing |
จากตารางเห็นว่า นักศึกษา Amit และ Akash สนใจกิจกรรมมากกว่าหนึ่งกิจกรรม
นี่คือ Multi-valued Dependency เพราะ CourseDiscipline ของนักศึกษาอิสระจาก Activities แต่ทั้งคู่อาศัยกับ Student
Multi-valued Dependency คือ:
| StudentName ->> CourseDiscipline | StudentName ->> Activities |
|---|
ความสัมพันธ์ข้างต้นละเมิด Fourth Normal Form
เพื่อแก้ไข ให้แบ่งตารางเป็น 2 ตารางแยกกัน และทำลาย Multi-valued Dependency:
<StudentCourse>
| StudentName | CourseDiscipline |
|---|---|
| Amit | Mathematics |
| Amit | Mathematics |
| Yuvraj | Computers |
| Akash | Literature |
| Akash | Literature |
| Akash | Literature |
<StudentActivities>
| StudentName | Activities |
|---|---|
| Amit | Singing |
| Amit | Dancing |
| Yuvraj | Cricket |
| Akash | Dancing |
| Akash | Cricket |
| Akash | Singing |
ตอนนี้ Multi-valued Dependency ถูกทำลายแล้ว และเรามี Functional Dependencies 2 อัน:
| StudentName → CourseDiscipline | StudentName → Activities |
|---|