Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> SQL

Super Key ใน RDBMS


Super Key คือแอตทริบิวต์ (หรือชุดของแอตทริบิวต์) ที่ระบุ tuple (entity ใน entity set) ได้อย่างเฉพาะเจาะจง เป็น Superset ของ Candidate Key เนื่องจาก Candidate Keys ถูกเลือกมาจาก Super Key

ตัวอย่าง

<Student>

Student_ID Student_Enroll Student_Name Student_Email
S02 4545 Dave ddd@gmail.com
S34 4541 Jack jjj@gmail.com
S22 4555 Mark mmm@gmail.com

Super Keys ของตารางข้างต้น:

{Student_ID}
{Student_Enroll}
{Student_Email}
{Student_ID, Student_Enroll}
{Student_ID, Student_Name}
{Student_ID, Student_Email}
{Student_Name, Student_Enroll}
{Student_ID, Student_Enroll, Student_Name}
{Student_ID, Student_Enroll, Student_Email}
{Student_ID, Student_Enroll, Student_Name, Student_Email}

Candidate Keys (ที่เลือกมาจาก Super Keys):

{Student_ID}
{Student_Enroll}
{Student_Email}

สรุป

  • Super Key = ชุดแอตทริบิวต์ใดๆ ที่ระบุ tuple ได้อย่างเฉพาะเจาะจง
  • Candidate Key = Super Key ที่ minimal (ไม่มี subset ที่เป็น super key)
  • Primary Key = Candidate Key ที่เลือกใช้เป็นหลัก