I need database structure for storing versions of site’s content in different languages. Right now I’m doing it like this:
[Item]
Id
SomeColumn
[ItemStrings]
ItemId
LanguageId
Title
Description
...
[Languages]
Id
Culture
Although, it is a pretty neat way to do translation, it requires a lot of monkey coding when adding new entities into the system.
The other solution, that I thought of, was some global table for ALL strings that need to be translated, with unique id and language id as primary key.
I like the second way much more because it is more DRY.
Now, real question is: can I use nvarchar(MAX) for all my records? Will it consume much more memory, when, say only 20% of values will be worth varchar(max) and others would easily fit in nvarchar(50-something)?
I’m using SQL Server 2008.
The second approach is closer to how localization is typically done (each string has an ID of some sort and can be looked up for various languages.)
Regarding using nvarchar(MAX), that should be fine. varchar types only use as much space as they need.