English 中文(简体)
在使用多种语文时如何设计表格
原标题:How to design tables when using multiple languages

你们建议如何在某一地点使用多种语文时设计表格? 例如,我们有一个称为产品表。 这可能包含像SKU、价格、秩序和其他环境这样的 st。 不过,名称和说明将以几种语文提供。 这些案文应列入表格,如:

tbl product_lang_en
product_id | name | description
tbl product_lang_de
product_id | name | description

Or should everything be collected in one table
tbl product_lang
product_id | lang | name | description

后者更正确,如果添加新的措辞,将保持数据库的完整性。 在表格增长巨大时,是否要铭记业绩有任何差别? 维护情况等

卡车

问题回答

第二项设计无疑较好。 第一个表格的明细推断:两个表格的栏目相同,数据事实列于表格(“en”、“de”)中。

就业绩而言,甚至比表2(或更多)好一个表。 如果你制定适当的指数(例如,如果你想要在兰子里打一环),那么,只有一张表格才能找到任何产品的描述。

我想提出另一种解决办法:

product
--------------------------------------
id    SKU(or any other internal name)   
//depending on the structure, you can skipp the id and replace it with the SKU/...

lang
--------------------------------------------------
id    product_id   name     lang     description

这似乎是一种缺点,但对于我来说,它有一些好处:

  • There can be more info related to the product that really belongs to the product e.g. price, VAT, ....
  • When you remove one product, you can have constraints that remove also the matching languages for it
  • The SKU from my example can be virtually anything that help internal (meaning not exposed to a user) number, name whatever. This way, there is no need for someone to look through all languages for a certain product. It can get pretty hard in your second design for someone to remove products in many different languages.
  • A application accessing the data can decide on it s own what language it should deliver. When doing the UI, you just need to worry about the unique identifier from the products table, and the code can decide what language is the proper one and select the rows accordingly
  • As Ned Batchelder mentioned above, indexes are very important and the performance difference (this approach will be slower of course) will be very small, but the maintainability will be given more easily IMO since there is no need to know what*s going on in lang (literally speaking, I think you get the point).

这似乎比上小,但我认为我会采取这种做法。





相关问题
How to model a many-to-many relationship in App Engine?

I have a question regarding how to model a many-to-many relationship in App Engine: A Blogentry can have many tags, a tag can apply to many blog entries. I see a couple of scenarios: Use a Set of ...

How to emulate tagged union in a database?

What is the best way to emulate Tagged union in databases? I m talking about something like this: create table t1 { vehicle_id INTEGER NOT NULL REFERENCES car(id) OR motor(id) -- not valid ... } ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

How to best implement a 1:1 relationship in a RDBMS?

Yesterday while working on a project I came up on a peculiar 1:1 relationship which left me wondering - how to best implement this (clearly, we had done it wrong :D) The idea is that there are two ...

Automatic filling entity properties

I have some type an architect(?) question I develop an application, based on Spring and Hibernate (annotated configuration) For each table in my database I added 4 fields: createdBy and modifiedBy(...

热门标签