Quantcast
Channel: Why are composite primary keys still around? - Stack Overflow
Browsing latest articles
Browse All 10 View Live

Answer by jkj for Why are composite primary keys still around?

Short answer: Multi-column foreign keys naturally refer to multi column primary keys. There can still be an autogenerated id column that is part of the primary key.Philosophical answer: Primary key is...

View Article



Answer by ses011 for Why are composite primary keys still around?

Just as functions encapsulate a set of instructions, or database views abstract base table connections, so to do surrogate keys abstract the meaning of the entity they are placed on. If, for example,...

View Article

Answer by John for Why are composite primary keys still around?

In short, the purpose of composite keys is to use the database to enforce one or more business rules. In other words: protect the integrity of your data.Ex. You have a list of parts that you buy from...

View Article

Answer by BillThor for Why are composite primary keys still around?

While I prefer surrogate keys, I use composite cases in a few cases. The composite key may consist entirely or partially of surrogate key fields.Many to many join tables. These usually require a unique...

View Article

Answer by A-K for Why are composite primary keys still around?

Natural primary keys are brittle. Suppose we have built a system around a natural PK on (CountryCode, PhoneNumber), and several years down the road we need to add Extension, or change the PK to one...

View Article


Answer by nvogel for Why are composite primary keys still around?

The very simple answer is data integrity. If the data is to be useful and accurate then the keys are presumably required. Having an "autogenerated id" doesn't remove the requirement for other keys as...

View Article

Answer by Quassnoi for Why are composite primary keys still around?

Composite keys are required when your primary keys are non-surrogate and inherently, um, composite, that is, breakable into several non-related parts.Some real-world examples:Many-to-many link tables,...

View Article

Answer by HLGEM for Why are composite primary keys still around?

Personally I prefer the use of surrogate keys. However, in joining tables that consist only of the ids from two other tables (to create a many-to-many relationships) composite keys are the way to go...

View Article


Answer by Aliostad for Why are composite primary keys still around?

Composite primary key provides better performance when it comes to them being used as Foreign keys in other tables and reduces table reads - sometimes they can be life savers. If you use surrogate...

View Article


Why are composite primary keys still around?

I'm assigned to migrate a database to a mid-class ERP.The new system uses composite primary keys here and there, and from a pragmatic point of view, why?Compared to autogenerated IDs, I can only see...

View Article
Browsing latest articles
Browse All 10 View Live




Latest Images