栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Database modeling for international and multilingual purposes

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Database modeling for international and multilingual purposes

Here is the way I would design the database:

Visualization byDB Designer
Fork

The

i18n
table only contains a PK, so that any table just has to reference
this PK to internationalize a field. The table
translation
is then in charge
of linking this generic ID with the correct list of translations.

locale.id_locale
is a
VARCHAr(5)
to manage both of
en
and
en_US
ISO
syntaxes.

currency.id_currency
is a
CHAr(3)
to manage the ISO 4217
syntax.

You can find two examples:

page
and
newsletter
. Both of these admin-
managed
entites need to internationalize their fields, respectively
title/description
and
subject/content
.

Here is an example query:

select  t_subject.tx_translation as subject,  t_content.tx_translation as contentfrom newsletter n-- join for subjectinner join translation t_subject  on t_subject.id_i18n = n.i18n_subject-- join for contentinner join translation t_content  on t_content.id_i18n = n.i18n_contentinner join locale l  -- condition for subject  on l.id_locale = t_subject.id_locale  -- condition for content  and l.id_locale = t_content.id_locale-- locale conditionwhere l.id_locale = 'en_GB'  -- other conditions  and n.id_newsletter = 1

Note that this is a normalized data model. If you have a huge dataset, maybe
you could think about denormalizing
it to optimize your queries.
You can also play with indexes to improve the queries performance (in some DB,
foreign keys are automatically indexed, e.g.
MySQL/InnoDB).



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/432816.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号