Skip to content
Advertisement

SQL good practices: should I use associative tables in this example?

I want to link two tables: a “company” table and a “branches” table. I find two ways to do it:

Method 1:

Method 1

Method 2:

Method 2

In practice, I think that both ways work the same, but professionally speaking, I think Method 2, using associative tables, would be the proper way to do it following SQL good practices.

I would like to know which is, professionally speaking, the proper way to do it and why it is the proper way to do it. Thank you

Advertisement

Answer

A company can have many branches.

But a branch (presumably) belongs to only one company.

This is not an many-to-many relationship. It is a one-to-many relationship. Your second method, with two tables, should accurately model this data.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement