
Envoyé par
Hibernate in action
Experience has shown that natural keys almost always cause problems in the long run. A good primary key must be unique, constant, and required (never null or unknow). Very few entity attributes satisfy these requirements, and some that do aren't efficiently indexable by SQL databases. In addition, you should make absolutely certain that a candidate key definition could never change throughout the lifetime of the database before promoting it to a primary key. Changing the definition of a primary key and all foreign keys that refer to it as a frustrating task.
For these reasons, we strongly recommend that new applications use synthetic identifiers (also called surrogate keys). Surrogate keys have no business meaning - they are unique values generated by the database or application.
Partager