Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asking for opinions : One sequence for all tables

Here's another one I've been thinking about lately. We have concluded in earlier discussions : 'natural primary keys are bad, artificial primary keys are good.' Working with Hibernate earlier I have seen that Hibernate default creates one sequence for all tables. At first I was puzzled by this, why would you do this. But later I saw the advantage that it makes linking parents and children fool proof. Because no tables have the same primary key value, accidentally linking a parent with a table that is not a child gives no results.

Does anyone see any downsides to this approach. I only see one : you cannot have more than 999999999999999999999999999 records in your database.

like image 479
Rob van Laarhoven Avatar asked Oct 08 '09 08:10

Rob van Laarhoven


1 Answers

There could be performance issues with all code getting values from a single sequence - see this Ask Tom thread.

like image 77
Tony Andrews Avatar answered Oct 04 '22 18:10

Tony Andrews