Forum Discussion
David2312
Jun 06, 2024Copper Contributor
Usage of surrogate keys
is it good practice to always use auto incremented primary keys to identify entities in a relational database. For example if an order is identified by three composite keys (customer_id, orderdateTime, orderItem) shouldn't I just make a new surrogate PK order_id which identifies all other attributes?
1 Reply
Sort By
- olafhelperBronze Contributor
David2312 the question can't be answered with yes or no.
For example, you have a table for products and each product do have a unique product number = natural key; whe adding an additional technical key, makes it more complicated.
Or you have a product table for a multi-tenant solution => tenant id + product nummer = surrogate keys