Is it better to repeat field or Join to access the relationship?

Asked

Viewed 42 times

1

Hello, thinking about performance and also good practices, what would be the ideal in this scenario?

3 objects: - Enterprise - Person representing the company - Visit (object of a commercial visit by a seller)

For me to display the information to the user would it be better if I leave as in the image below? respecting the hierarchy or could repeat data, placing the customer id also in the table of visits not to need to give a Join?

Modelagem exemplo para fins didáticos

  • I have seen them use both forms, each with its pros and cons. According to good practices, the ideal is to keep everything separate. But to facilitate the queries, you can use the repeated data, speeding up the search in the bank. It is at your discretion.

  • Already law regarding [tag:] ?

1 answer

0


The ideal is to use JOIN, because if you put the customer id in the VISIT table you will be creating a relation that is redundant, since you can get the same information using JOIN through the relationship between the other tables (VISITA, REPRESENTANTE_CLIENTE and CLIENT). This should be avoided according to the literature and good practices.

Browser other questions tagged

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