Lurker News
I'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 comments
OJFord#
> When I read about database schemas with thousands of tables I wonder what kind of problem could possibly require so many tables.

They're probably mostly small (in terms of columns), many of them done just to have foreign key constraints, separate indexes, and arguably easier querying (joining) on just the data you need.
But I think it's a particular style, rather than a 'problem' that 'requires' so many.
(IANA database expert though, just my tuppence.)

larrywright#
When you think about large enterprise software systems with screen after screen full of data entry forms, with drop down lists everywhere, every single one of those drop down selectors is likely a database table. Every schema like that will have a mix of large tables (customers, products, etc) and lots of small tables.

I don’t think there’s a number above which you should not go, it’s really about how the data is organized and how easy it is to get data in and out of. I agree with another comment here about looking at anti-patterns first. There are some common ones that would be red flags.
As an example of what not to do: I once worked with a DBA who insisted that tables shouldn’t have more than 15 columns. So any table with more than 15 columns would have to be split into multiple tables, even if those tables would always have to be fetched together.

dougk16#
Not to be too self-promoty, but I spent a ton of time thinking about the schema for my site, and have gotten some compliments on the detail and documentation: https://aytwit.com/sql

I hope that helps spark some ideas for you.

arethuza2 replies#
A SAP partner once told me (the company I was working at was considering using SAP) that the deployment would have ~180K tables - I don't know if they got the figure wrong, I have misremembered (I did check when they said it) or maybe that's for a "fully loaded" instance.

Edit: Not SAP, but certain other ERP products have an alarming habit of not using foreign keys - which makes working out the structure of the database quite interesting...

gberger1 reply#
How do you perform joins without foreign keys? Do you just have a column that is effectively a foreign key but is not marked as such?
dizaime#
Sure it is. We can perform DB joins with any column as long as the data type and the data value is matched.
AdrianB1#
It depends on the version and how many modules you have installed. In my company it was ~ 50k tables for R/3, so the order of magnitude is right.

Load more comments