Example of table with auto-increment id.

PRACTICAL PROGRAMMING ADVICE

Three Issues With Using Database Generated IDs

Stop letting the database be in charge of your application

Nicklas Millard
The Startup
Published in
4 min readJun 20, 2020

--

You’ve probably let databases generate IDs for your entities at least once.

But, what if I told you there’s an alternative when developing applications?

I’m sure this stands in sharp contrast to what you learned in the Relational Databases 101 college course and the countless youtube tutorials you’ve watched when learning how toCREATE TABLE UsingTerribleIds ().

Generate your IDs at the application level. Not at the persistence level.

That’s it. You’re free to go on your merry way.

(please note that entity ID is not necessarily a database primary key)

Or, stay put if you want to know more about why database generated entity IDs may be troublesome and want to learn how I approach ID generation at client projects.

So, what’s the issue with having the database generate your entities’ IDs?

1 What’s most problematic is you’re delegating an important aspect of your domain to third party software.

--

--

Nicklas Millard
The Startup

I mostly write to "future me" sharing what I learn and my opinion on software development practices. youtube.com/@nmillard | open for contracts in Jan 2026.