We are going to start a new project in which we (hopefully) will support thousands of customers, and therefore we are studying architecture. One of the key aspects of the application will be support for several languages โโ(English, Spanish, etc., without restrictions on the number of languages). We have a lot of experience in modeling, this is a traditional DBMS (Sql Server, Oracle, etc.), but we fight when it comes to NoSQL modeling. In the SQL model, we would create a โtextโ table with a โlanguageโ column pointing to a โlanguageโ table with all the different languages. Thus, all texts can be submitted in all supported languages. Consider a simple example:
table: Category columns: id (PK), Enabled (Bool)
table: Category_Descriptions columns: id (PK), CategoryID (FK), LanguageID (FK), description (text)
table: Language columns: id (PK), Enabled (Bool)
table: Language_Descriptions columns: id (PK), DescriptionLanguageID (FK), LanguageID (FK), description (text)
Thus, all languages โโwill be saved in the Language table, with their corresponding description stored in the Language_Descriptions table. In addition, all categories will be stored in the Category table with descriptions in all languages โโin the Category_Descriptions table. Thus, to get all categories in a given language (English = 1):
select c.id, cd.Description from Category c, Category_Descriptions cd where c.id = cd.CategoryID and c.Enabled = 1;
Of course, the category itself is not very useful; it will be part of another entity, such as an incident report:
table: Incident columns: identifier (PK) generated (date), category code (FK), etc.
To get information from this table, I will then make the same connection as before, and select the description column in the correct language. The basic material, we all did this before ...
Finally, we come to my question: how to store it correctly in a NoSQL database? :)
I reviewed a few (bad) solutions:
- Save only the code and then find the correct runtime description
- Save the last used description along with the language code and then update if the language has changed (another user)
- Store all descriptions in one document
- Save the description of the code in the active language, and then, if necessary, add a description in new languages โโ(i.e., on request in an unused language).
All these solutions have many shortcomings and require a lot of work on implementation and support ... So, any contribution to how to best solve this problem will be appreciated.
EDIT: We look at NoSQL for two reasons:
- Performance (scale)
- Dynamic schema (a lot of work needs to be done to make this happen in SQL)