SQL primary key, surrogate key, composite keys, foreign keys... and JPA

 /  EN

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.


Franck Pachot

Franck is passionate about all databases. After 20 years of consulting on traditional databases (Oracle Certified Master/ACE Director as well as AWS Data Hero and AWS Academy educator) he is now a developer advocate for Yugabyte, a NewSQL open source distributed database full PostgreSQL-compatible. Franck loves to learn and share in technical communities, very active on Twitter (@FranckPachot) and multiple blogs.