0

I've got a simple database of products.

Each product is N:1 related to several attributes, such as material, gender, shape and so on.

Each attribute is a table (e.g. table "shapes" with square, round and other rows)

Now I'd like to "translate" each attribute, for example, I want the "square" record, to be associated with "quadrato" (it), "carré" (fr) and so on. "languages" is another table (it,fr,en) and languages can be added or removed, so having columns "it_value", "fr_value" is obviously impossible and ugly.

I'm thinking about

  • create a table "TRANSLATIONS" with id, language_id and value
  • create a table "LANGUAGES" with id, name
  • create tables "SHAPES" and "MATERIALS" with id and other columns
  • create a table (for example) "MATERIAL_TRANSLATIONS" with translation_id and material_id
  • create a table "SHAPE_TRANSLATIONS" with the same idea, as above

Do you think other solutions could be more efficient or more elegant than that?

(Sorry for not posting an ER diagram too, but I'm not a so 'graphic' person! ;))

4

2 に答える 2

1

形状/材料の表はどの程度似ていますか?「属性のタイプ」(形状/材料)と「属性の名前」(正方形、綿など)のフィールドセットを持つ単一のテーブルでそれを達成できませんでしたか?

その場合は、おそらく次のようなものを使用します。

items: id, name  
languages: id, name  
items_translations: item_id, language_id, name

itemsテーブルの「name」はシステムのデフォルト言語(英語など)であり、翻訳はitems_translationsテーブルの「name」フィールドにあります。

于 2012-09-18T14:43:01.120 に答える
1

That sounds fine.

You could use a more abstract representation, but I think your explicit mapping approach is more understandable, and therefore better.

于 2012-09-18T14:45:02.040 に答える