2 comments

[ 1.8 ms ] story [ 13.2 ms ] thread
This is news to me, apparently Rails is actually getting support for composite primary keys. For years I remember it was a pattern you just avoided because it wasn't supported by ActiveRecord.
When is it better to use a composite primary key instead of a single unique primary key? In the context of SQL, it just seems like there are negligible storage space differences. Obviously you can still index and have unique constraints on the columns from the would be composite index.

I sought out discussion in the past and I recall similar conclusions. I suppose it really seems superfluous for a join table but other than that it seems like a unique primary key is a good practice.