Join or separate repeated columns in different tables

Asked

Viewed 51 times

2

I created a table tbl_users.

But I have Profissionais and Empresas many columns are the same. It would be interesting to use in the same table, or it is better to separate?

  • Your question is too vague, no one will be able to help you. Place the tables with all attributes so we can help you.

  • Excellent content to read on this subject DEV MEDIA. You have to evaluate the amount of columns that are equal. Assuming each table has 10 columns and these 10 or 7 are equal, I would leave together.

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site

1 answer

2

Even with the question not having enough information to give an accurate answer, there is something that always counts: normalize the information.

Modeling is defining where everything goes.

We can talk about DRY here. If the information happens to be the same, but there is no direct relationship between them then it is all right. If it is essentially the same information then one should think about having a separation of the repeating part. At least in logical model.

In physical model there are cases of optimization that end up being more interesting to have the model partially repeated to avoid unnecessary relationships. It’s just for performance.

It is not the repetition that matters, it is the functionality that the columns have. It is not the number of repeated columns that matters.

Let’s say there are address columns in each table. Is it worth having a separate address? If it’s just to organize the table, it’s not worth it. If you want to have addresses as a distinct entity that can be used in more than one entity in the same table or in different tables, then it makes sense to have something like this.

In fact modeling has to start from a correct conceptualization that comes before solving these things. Needs to study ontology, taxinomy and even semiotics. For example of what would already change understanding these things and not use tbl_ in table names. Now that’s redundancy.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.