I’m building a relational database, and so many of my tables have ‘name’ columns. And they’re all related to each other.
For example, a central column is the Client table, and the client can have multiple Customers, and each client has a name, and each customer has a name. And each customer will be subscribed to any number of Services, which also has a name.
So I can have a ‘name’ column on every table, or alternatively I can have ‘client_name’, ‘customer_name’, ‘service_name’ and so on. Which hypothetically would make joins easier.
What do you recommend?
Advertisement
Answer
When you go to join two or more of these tables, you can (and probably should) use table aliases when referring to the individual columns. So, there is no chance anyway of the column name
on one table being confounded with name
from another table. That being said, I also recommend using the shorter version because it makes the labelling of each individual table more concise and readable. Calling a column in the client
table client_name
is redundant, and doesn’t add any useful information.