Начало основного контента
SQL primary key, surrogate key, composite keys, foreign keys... and JPA
In Java, all objects have an identity from their memory address. When persisting them, a key is required. And this is where religious wars start... Natural key? Composite key? Surrogate key? Sequence or UUID? Let's see what they are. Their pros and cons, for a wise decision, per use-case. The tradeoffs, for performance, agility, scalability, JPA, or other framework support. In the modern world of microservices and distributed databases.