Computer Science · Ch 8 — Database Concepts
Composite Primary Key
Composite Primary Key
Composite Primary Key
Sometimes, no single column in a table can guarantee that every row will be unique. When that happens, you cannot pick just one attribute as the primary key. Instead, you combine two or more attributes together, and this combination becomes the primary key. Such a key, made up of more than one attribute, is called a composite primary key.
Consider the ATTENDANCE relation. It records which student was present on which date. If you try to use RollNumber alone as the primary key, it fails — the same roll number appears in multiple rows because the same student attends on different dates. Similarly, AttendanceDate alone cannot be the primary key because the same date repeats for every student who was present that day. …