Reputation: 393
Which of these two is more preferable?
I consider performance as the first and convenience as the second.
Upvotes: 1
Views: 208
Reputation: 2032
I would ask my self this question. Is the image only relates to 1 model?
If, it will only be related to 1 model, like profile picture. Then, it will be best fit for first approach
Model has field image, which type of is json (and keep them as array).
If the image will be used for multiple models like emoji or letter_avatar. Then, it will be fit on the second approach
Model has_many_and_belongs_to related model like "Image".
Performance wise, it will be better in the first approach. You don't have to spend resource to fetch related models.
Upvotes: 2