views:

20

answers:

1

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?

+1  A: 

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 id the primary key of items, (itemId, language) the primary key of itemTexts, and itemID a foreign key reference to id in the items table.

ngroot