Should the primary key be the email or a generated id

Back to list2025-09-18
You

Should the primary key be the email or a generated id?

ChatGPT

A surrogate id, with a unique constraint on the email. Natural keys change: people change emails, countries change codes, ISBNs get reissued. Every one of those becomes a cascading update across every table that referenced it.

You

Float or integer for prices?

ChatGPT

Integer minor units, or a decimal type where the database has one. Floats cannot represent 0.10 exactly, so sums drift by cents and the drift shows up in reconciliation months later. Store 1099, format as 10.99 at the edge.

You

Database enum, lookup table or plain text?

ChatGPT

A lookup table with a foreign key, unless the set is genuinely fixed forever. Database enums require a migration to add a value and cannot carry attributes; plain text accepts typos silently and then you have three spellings of the same status in production.

You

How do I know when it stops being worth it?

ChatGPT

When you stop noticing it. If it has not surfaced a problem in six months, it is either solved or it was never the bottleneck you thought.