Don't Do This With Your Database ER Diagram
This:
It's easy to understand why anyone would want to diagram the entire database so that developers and admins can see everything in one visual map. That works well for databases with a small number of tables, but as the tables increase the visual clarity quickly falls off, unless you make a giant diagram that requires zooming in and out to see any useful details.
There's a famous parable about the blind men and an elephant.
A group of blind men heard that a strange animal, called an elephant, had been brought to the town, but none of them were aware of its shape and form. Out of curiosity, they said: "We must inspect and know it by touch, of which we are capable". So, they sought it out, and when they found it they groped about it. The first person, whose hand landed on the trunk, said, "This being is like a thick snake". For another one whose hand reached its ear, it seemed like a kind of fan. As for another person, whose hand was upon its leg, said, the elephant is a pillar like a tree-trunk. The blind man who placed his hand upon its side said the elephant, "is a wall". Another who felt its tail, described it as a rope. The last felt its tusk, stating the elephant is that which is hard, smooth and like a spear.
This parable is often invoked in a way that criticizes the blind men for not seeing the entire picture. If we want to make our ER diagrams more comprehensible, we can flip this parable around and use multiple diagrams that are each only concerned with mapping sections of the entire database. For example, if your database is already neatly sectioned with the use of schemas, you could do a separate diagram for each one.
Application schema:
Sales schema:
Whether or not your database schemas are separated by usage, you can also limit your view of the database by business domain. For example, just the data warehouse tables:
Finally, let's say that you actually need to model a large number of tables to accurately map a business domain. You might still run into the same issue of inscrutable tables that require zooming in and out to read everything. One strategy to make the diagram more readable is to limit the amount of information displayed. Do you really need every column listed in the diagram if the goal is to illustrate the table relationships? By cutting down the displayed columns to just the table names and keys, or even just the table names, your diagrams will be much easier to read and understand.
Names and keys:
Names only:
To sum up, let's torture another elephant-related saying:
How do you understand a massive database schema? One table at a time.
Database examples taken from the Wide World Importers samples.
Comments
Post a Comment