Why single primary key is better than composite keys?

前端 未结 9 1114
栀梦
栀梦 2020-12-05 10:34

Why is the rejection of composite keys in favor of all tables using a single primary key named id? Cause generally all ORM follow this.

EDIT

9条回答
  •  余生分开走
    2020-12-05 10:59

    You can use both. In some cases when making an association between an entity you can use both entity keys as a composite key.

    As a rule of thumb I use generated ids for entities and composite keys for relationships.

提交回复
热议问题