Composite Key
Definition
A composite key is a candidate key / primary key made by combining two or more columns (attributes) in a database table to uniquely identify each record (tuple).
What Problem It Solves
Solves the issue where single column is not enough to ensure uniqueness of a row. It enforces entity integrity when data is naturally dependent on multiple attributes.
What Happens If Not Used
Without a composite key, you may face duplicate records, inability to uniquely identify rows, and data integrity issues.
Easy Wording
When one field can’t uniquely identify data, we combine multiple fields to make a unique identity.
Technical Example
In a school, Student ID alone is not enough for exam records. So we combine:
StudentID + Subject → unique result entry.
Table: ExamResults
Columns: StudentID, SubjectID, Marks
Composite Key: (StudentID, SubjectID)
→ Together they uniquely identify each row.