What is a composite key?
How does it differ from a primary key?
A composite key is a combination of two or more columns in a table that can uniquely
identify each record in the table. It is used when a single column is not sufficient to uniquely
identify a row.
- Composite Key: Consists of multiple columns.
Example: A table storing student-course enrollments might use a composite key
consisting of StudentID and CourseID to uniquely identify each enrollment record.
- Primary Key: A primary key is a single column (or a composite of columns) that
uniquely identifies each record in a table. It can be a single column or a composite
of multiple columns, but it must be unique for each row.