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

Composite Key ใน RDBMS


Composite Key คือ Primary Key ที่ประกอบด้วยแอตทริบิวต์ 2 ตัวขึ้นไป คือการรวมคอลัมน์ 2 คอลัมน์ขึ้นไป

ตัวอย่าง

Composite Key ใน RDBMS

Composite Key คือ OrderID และ ProductID

{OrderID, ProductID}

ตัวอย่างเพิ่มเติม

<Student>

StudentID StudentEnrollNo StudentMarks StudentPercentage
S001 0721722 570 90
S002 0721790 490 80
S003 0721766 440 86

Composite Keys คือ StudentID และ StudentEnrollNo ตารางมี 2 แอตทริบิวต์เป็น Primary Key

สรุป

Primary Key ที่ประกอบด้วยแอตทริบิวต์ 2 ตัวขึ้นไป เรียกว่า Composite Key