Is it better to store redundant information or join tables when necessary in MySQL? Is it better to store redundant information or join tables when necessary in MySQL? database database

Is it better to store redundant information or join tables when necessary in MySQL?


It is almost always better to join and avoid redundant information. You should only denormalize when you must do so in order to meet a performance goal - and you can't know if you need to do this until you try with normalized tables first.

Note that denormalization helps in read performance at the expense of slowing down writes and making it easier for a coding mistake to cause data to be out of sync (since you're storing the same thing in more than one place you now have to be sure to update it all).


Generally it is better to avoid redundant information. This seems like it should be quite a cheap join to do given appropriate indexes and I wouldn't denormalise in that manner unless I saw in the query plans that the JOIN was causing problems (perhaps because of the number of records in the tables)

You would also need to consider the ratio of reads to writes. Denormalisation will help the reads but add overhead to writes.


From a design point of view, storing redundant data is not necessary. In your case it might be. Try to make some tests and if the query time is improved due this redundancy then you should proceed with the denormalization.