I’m building a multilingual website.
I’ve been thinking about using a single table for all text content texts(key, language, content) that other tables can refer to.
For example, let’s say I have a table items(id, name, description). Instead of storing actual content, the name and the description columns store references to the texts table.
What do you think?
I think two tables in this simple case is unnecessary: you would still have a normalized design with one table,
items(id, language, text, content), with(id, language)as the primary key.Note that if you wanted to add non-localized fields (e.g., price in dollars), then you would want two tables:
items(id, priceInDollars)itemTexts(itemId, language, name, description)with
idthe primary key of items,(itemId, language)the primary key ofitemTexts, anditemIDa foreign key reference toidin theitemstable.