これは、多言語 Web サイトや e ショップで多くの作業を行ってきた経験豊富な人々にとってより重要な質問です。これは、データベース構造に関する質問などではありません。これは、多言語 Web サイトを保存する方法に関する質問です。翻訳を保存する方法ではありません。多言語 Web サイトは、複数の言語に翻訳できるだけでなく、言語固有のコンテンツを含めることもできます。たとえば、ウェブサイトの英語版は、ロシア語や他の言語の同じウェブサイトとはまったく異なる構造を持つことができます. このような場合に備えて、2 つのストレージ スキーマを考えました。
// NUMBER ONE
table contents // to store some HYPOTHETICAL content
id // content id
table contents_loc // to translate the content
content, // ID of content to translate
lang, // language to translate to
value, // translated content
online // availability flag, VERY IMPORTANT
ADVANTAGES:
- Content can be stored in multiple languages. This schema is pretty common, except maybe for the "online" flag in the "_loc" tables. About that below.
- Every content can not only be translated into multiple languages, but also you could mark online=false for a single language and disable the content from appearing in that language. Alternatively, that record could be removed from "_loc" table to achieve the same functionality as online=false, but this time it would be permanent and couldn't be easily undone. For instance we could create some sort of a menu, but we don't want one or more items to appear in english - so we use online=false on those "translations".
DISADVANTAGES:
- Quickly gets pretty ugly with more complex table relations.
- More difficult queries.
// NUMBER 2
table contents // to store some HYPOTHETICAL content
id, // content id
online // content availability (not the same as in first example)
lang, // language of the content
value, // translated content
ADVANTAGES:
1. Less painful to implement
2. Shorter queries
DISADVANTAGES:
2. Every multilingual record would now have 3 different IDs. It would be bad for eg. products in an e-shop, since the first version would allow us to store different languages under the same ID and this one would require 3 separate records to represent the same product.
最初のストレージ オプションは、2 番目のストレージ オプションの代わりに簡単に使用できるため、優れたソリューションのように思えますが、その逆は簡単ではありません。唯一の問題は...最初の構造が少しやり過ぎのように見えることです(製品の保管などの場合を除く)
だからあなたへの私の質問は:
最初のストレージ オプションを実装することは論理的ですか? あなたの経験では、そのようなソリューションが必要になる人はいますか?