When you start working with an unfamiliar database, how do you figure out which tables relate to each other without getting lost?
How do you get familiar with a new database schema quickly?
Answers
Start with an entity relationship diagram. If you have a tool that can generate one from the database, use it as a map. Otherwise, sketch the tables and connections yourself.
For a large schema, a diagram of everything might be overwhelming. Start with the tables around the feature you care about, then add neighboring tables as you need them.
Reply to this answer
Look at primary keys and foreign key constraints first. An orders table with a customer_id foreign key pointing to a customers table gives you a concrete relationship to follow. Naming conventions can offer clues too, but a matching name alone doesn't prove a relationship.
Check the constraints rather than assuming every connection is enforced by the database. A diagram is useful, but it's only as complete as the relationships it captures.
Reply to this answer
Don't try to understand the whole thing before doing anything. Pick the small area you need for your current task, trace the tables involved, and expand your map as new questions come up. The bigger picture can emerge piece by piece.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions