Saving multiple versions of a value in the database

The issue of database design.

I need to create an item with multiple versions of the same value, for example, in a store for a store in a multilingual store.

Say I have a product

CREATE TABLE product id INT, name VARCHAR(64), description SMALLTEXT, whatever BOOL, another INT; 

and translation table

 CREATE TABLE product_language product_id INT, language_id INT, name VARCHAR(64), descripton SMALLTEXT; 

Now my question is ... is the product table reasonable or not? Most stores will only have one language, so it makes sense to store the name and description in the default language in the product table, to avoid JOINs when there is only one language in the system? Or will it give me headaches that I cannot foresee?

+4
source share
1 answer

I would say that the JOIN to get product_language would be inconsequential. RDBMs are really good at performing performing associations :). I see no benefit from using the default name and description. You will need to synchronize the value and / or have special processing in your application in order to display the default name and description if the corresponding language does not exist.

+4
source

Source: https://habr.com/ru/post/1413493/


All Articles