MySQL实现翻译,翻译的MySQL结构

博客讨论了在数据库设计中如何处理默认语言的问题。当前方案是通过两个表格实现,但当管理员需要更改默认语言时存在挑战。提出了两种解决方案,但认为它们不够理想。一种建议是为每种语言创建单独的表格,以方便切换。
摘要由CSDN通过智能技术生成

According to this approach, default language is already translated in first table. If a user doesn't need a translation, he won't struggle with them. Just connect primary table, that's all...

PRODUCT TABLE (InnoDB):

Obj_id(PK) name desc

--------- ------------------- ------------------

1 Million Dollar Baby Short description is...

2 Music Album Another explanation...

TRANSLATION TABLE (InnoDB)

trans_id (PK) Obj_id (FK) lang field trans

-------------- ----------- ------ -------- ---------------------

22 1 TR name Milyonluk Bebek

23 1 BA name Djevojka od milijun...

24 1 TR desc Kisa açiklama burada

25 1 BA desc Kratki opis je ovdje

26 2 BA name Glazba albuma

But the problem occurs when administrator wants to change default language. I have two options to solve this problem:

Administrator has to decide default_lang at the beginning of the project and if he still wants to change default_lang in the future, the program will say: Go to hell.

Like first solution, admin has to decide default_lang at first, but the system will be able to transfer new default_lang data from translation table to primary table (i don't do this actually).

I think my solutions are not good enough.

Do you have better idea about DEFAULT_LANG problem with or without change the structure (if it's possible, don't change the structure - i like it)?

解决方案

I wonder if having a table per language would be better. That way you'd just switch out tables that are being used.

TRANSLATIONS_TR

TRANSLATIONS_EN

TRANSLATIONS_FR

TRANSLATIONS_BR

Then in your user display routines, you decide what table to query when displaying translation text.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值