Primary key in relational tables. Composite primary key or unique primary key in those pure relational tables?
Which design would you recommend to use in MySQL for high performance? See diagram
Technical advantages and disadvantages!
Thanks everyone!
解决方案
It really depends on the type of query you're doing...
If you add an extra surrogate, you'll end up doing two unique checks instead of a single one for every insert, update and delete. That makes the composite key sound right.
But if you're constantly referencing that primary key in other foreign keys, the composite option means you end up storing twice as much information and need to do more work when joining. That makes the single key sound right.