Yhdistelmäprimääriavaimen
Yhdistelmäprimääriavain, often translated as composite primary key in English, is a database concept. It refers to a primary key that is composed of two or more columns. These columns, when combined, uniquely identify each row in a database table. Unlike a single-column primary key, a composite primary key requires the values in all its constituent columns to be unique together. No single column within the composite key may be null. The primary purpose of a composite primary key is to enforce entity integrity, ensuring that each record in a table can be distinctly identified without ambiguity. This is particularly useful when a single attribute is insufficient to guarantee uniqueness. For instance, in a table tracking student enrollments in courses, a composite primary key might consist of the student ID and the course ID. Individually, neither the student ID nor the course ID might be unique across all enrollments, but the combination of a specific student with a specific course will uniquely identify a single enrollment record. The selection of columns for a composite primary key should be based on their ability to provide a unique and stable identifier for each record.