Primary keys revisited
Following [Bauer2015] (p.88) we list important properties of primary keys with respect to “best practices” on top of their relational counterparts:
-
A primary key's values never change
-
Primary key values should not have a business meaning
-
Primary keys should be chosen to have proper indexing support with respect to the database product in question.
Regarding persistence we have three different concepts related to object identity:
- Java Object identity
-
The operator == checks whether two identifiers point to the same memory address.
- Java Object equality
-
The
Object.equals(Object)
. - Database identity
-
Two distinct datasets (tuples) are identical if all primary key attributes have the same value.
In other words: Two distinct database objects differ at least in one of their primary key attribute values.
We recommend [Bloch2008] regarding Java identity and equality of objects.