Why single primary key is better than composite keys?

前端 未结 9 1098
栀梦
栀梦 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 11:16

    Objects in OO programming have identity regardless of their contents. Rows (tuples) in relational databases are identified by their contents only. So when really doing ORM, i.e. mapping objects from an object-oriented programming language to a relational database, an extra ID must be provided as distinct from the fields and/or properties the object has in the program - unless one or more of those are somehow known to identify objects uniquely.

提交回复
热议问题