Computer >> Computer tutorials >  >> Programming >> SQL

Composite Key in RDBMS


A primary key having two or more attributes is called composite key. It is a combination of two or more columns.

An example can be −

Composite Key in RDBMS

Here our composite key is OrderID and ProductID

{OrderID, ProductID}


Let us see another example −

<Student>

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


Above, our composite keys are StudentID and StudentEnrollNo. The table has two attributes as primary key.

Therefore, the Primary Key consisting of two or more attribute is called Composite Key.