Answer the question
In order to leave comments, you need to log in
OneToOne (JOIN) vs extra field on entity?
The page displays a catalog of companies with their logos.
There are entities^ Company and File
Files are taken from the storage, the path is generated by the file storage method
I think about the decision to add the logo property to the Company:
Option 1: write the path to the file in the storage along with the name - path/to/logo.jpg
pluses: no extra request to the database to get the path and file name
minus: duplication of information in the database in the files table (there are already path and file fields)
Option 2; write only the file ID - 357
pros no duplication of information in the database
cons: an extra request to the database to get the path and name
Have I taken into account all the pros/cons?
Maybe there are other options?
What is the usual solution for such a problem?
Thank you all in advance for your replies!
Answer the question
In order to leave comments, you need to log in
Duplicate data is only worth it if there is an urgent need. For example, high load on the database. Otherwise, normalize the base.
There are no particular pros and cons here. This question is not about Doctrine. But the second option is definitely better. If you feel sorry for extra requests - use the cache.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question