Menu

1 / 3

No Foreign Keys. No Documentation. Good Luck Finding the Right JOIN.

DEV Community: sql·Arisyn·1 day ago
#FMHaWcyA
#devtosql#devto#dev#relationship#customer_id
Long article (764 words) — no AI summary yet.
Reading 0:00
15s threshold

Four practical checks for discovering database relationships before building your next dbt model.

You inherit a database with hundreds of tables.

Foreign keys are missing. Documentation is outdated. The person who designed the schema left two years ago.

Your task sounds simple: build a new data model.

But before writing the SQL, you need to figure out how everything connects.

If you've ever worked with a legacy database, you probably know this feeling.

Here are four checks that can make the process a little less painful.

1. Stop Relying on Column Names

Consider these three columns:

orders . buyer_ref customers . customer_id accounts . account_id

Enter fullscreen mode

Exit fullscreen mode

Which one should you join to orders.buyer_ref ?

Similar column names don't necessarily indicate a relationship. Different column names don't necessarily rule one out.

Start by examining data types, value formats, and existing model definitions.

Treat column names as clues, not evidence.

2.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.