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

ซุปเปอร์คีย์ใน RDBMS


Super Key คือแอตทริบิวต์ (หรือชุดของแอตทริบิวต์) ที่ระบุ tuple โดยไม่ซ้ำกัน เช่น เอนทิตีในชุดเอนทิตี

เป็น superset ของ Candidate Key เนื่องจาก Candidate Keys ถูกเลือกจาก super key

ตัวอย่าง

เรามาดูตัวอย่างกัน −

<นักเรียน>

Student_ID

Student_Enroll

Student_Name

Student_Email

S02
4545
เดฟ
ddd@gmail.com
S34
4541
แจ็ค
jjj@gmail.com
S22
4555
Mark
mmm@gmail.com


ต่อไปนี้เป็นซุปเปอร์คีย์สำหรับตารางด้านบน −

{Student_ID}
{Student_Enroll}
{Student_Email}
{Student_ID, Student_Enroll}
{Study_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}

ต่อไปนี้จะเป็นคีย์ตัวเลือกจากด้านบน −

{Student_ID}
{Student_Enroll}
{Student_Email}