Composite Key
A composite key is a database concept where two or more columns in a table are combined to uniquely identify each row, serving as the primary key. It is used when a single column cannot guarantee uniqueness, such as in many-to-many relationship tables or complex data models. This approach ensures data integrity by preventing duplicate entries based on the combined values.
Developers should use composite keys in relational databases when a single attribute is insufficient for uniqueness, such as in junction tables for many-to-many relationships (e.g., linking users to roles) or in scenarios with natural keys like date-location combinations. It simplifies schema design by avoiding artificial surrogate keys and enforces business logic constraints directly at the database level.