Ask HN: What are some examples of good database schema designs?
437 pointsI've seen many examples of database schemas but don't always recognise a good design over a mediocre or poor design.
This is what I mean by schema (is this a good design?)
https://www.drupal.org/node/1785994
When I read about database schemas with thousands of tables I wonder what kind of problem could possibly require so many tables.
What are good schema examples? And what are some poor examples?
Comments (175) 52 threads
Earlier commentsCRMs often have hundreds of tables and ERPs have thousands or tens of thousands or more.
https://www.mediawiki.org/w/index.php?title=Manual:Database_...
My 2 cents after doing this long enough to recognise it
- Aim for 3NF but not religiously. Still, if you need a flat table try a view.
- Any ternary relationship can be modeled as a pair of binary relations (you'll never regret keeping it simpler)
- You don't need EAV (Magento is a good example of why you shouldn't)
- On the other hand don't serialize data (looking at you WordPress)
- XML and JSON data types though are perfectly fine when you need to store an object
- Every table should have a primary key (preferably an integer)
- If you really want a string for your primary key make it a candidate key (why, because someone will insist on changing it)
- E/R diagrams are your friend
- So are Venn diagrams for visualizing a complex select
All comments shown.
Couldn't load more comments. Check your connection and try again.