
这是我设计数据库的方式:
通过 DB Designer Fork进行可视化
该
i18n表仅包含一个PK,因此任何表都只需引用该PK即可国际化字段。
translation然后,该表负责将此通用ID与正确的翻译列表链接。
locale.id_locale是
VARCHAr(5)同时管理
en和
en_US
ISO语法的。
currency.id_currency是
CHAr(3)管理ISO
4217语法的一个。
您可以找到两个示例:
page和
newsletter。这两种的 管理员管理
的entites分别需要国际化的田地,
title/description和
subject/content。
这是查询示例:
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
请注意,这是一个规范化的数据模型。如果您有一个庞大的数据集,也许您可以考虑对它进行规范化以优化查询。您还可以使用索引来提高查询性能(在某些数据库中,外键会自动建立索引,例如MySQL
/ InnoDB)。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)