composite key
A key made of two or more columns together, such as order and product on an order line.
In more detail
PRIMARY KEY (order_id, product_id) states the business rule that a product appears at most once per order, so no application code has to enforce it. Each column alone may repeat; only the combination is unique.
Example
PRIMARY KEY (order_id, product_id)Related terms
- primary key — The column, or columns, whose value uniquely identifies each row of a table and can never be NULL.
- composite index — An index on several columns in a fixed order, which serves queries on a leading prefix of those columns.
- second normal form — The rule that, in a table with a composite key, every other column depends on the whole key and not on just part of it.
Taught in
- Keys, Constraints And Referential Integrity — PostgreSQL, Indexing & Relational Data Modeling
- Normalisation To Third Normal Form — PostgreSQL, Indexing & Relational Data Modeling