Sobes.tech
Junior — Middle

Can you give an example of a situation where a composite primary key is used in a database?

sobes.tech AI

Answer from AI

A composite primary key is used when the uniqueness of a record is determined by a combination of multiple columns, rather than just one. For example, in a table of order items, where each record is a specific product in a specific order, the primary key can consist of order_id and product_id. This ensures that the same product will not be duplicated within a single order.