English 中文(简体)
高效工匠 亚洲开发银行的国际化结构
原标题:Efficient MYSQL DB structure for internationalization

我将支持我的剪辑。 它有大约10个有不同结构的表格。 我勾画了我认为是良好办法的结构:

Languages

lang_id (int)
lang_name (varchar 128)

Sample 1

sample_1_id (int)
name (int -- tran_id)
description (int -- tran_id )

Sample 2:

sample_2_id (int)
person (int -- tran_id)
page (int -- tran_id)

Translations:

tran_id (int)
lang_id (int)
content (text)

然而,要使整个工作取得一定结果,翻译表中的内容一栏必须具有哪类文字? 如果是这样的话,那么废物空间,特别是当大多数数据所消耗的只是少数特性时? 是否有更好的办法?

最佳回答

考虑两个翻译表。 例如:

翻译部门 短期:

tran_id (int)
lang_id (int)
content (VARCHAR(255))

请注意,MySQL 5.0.3+中的VARCHAR的限额实际上为65 535英特,但也是增长限额。 因此,你可以使用:

tran_id (int)
lang_id (int)
content (VARCHAR(65522))

与此类似:

译自:

tran_id (int)
lang_id (int)
content (text)

文本只有65535,因此,MySQL.50.3+已经涵盖。 您也可在此使用MEDIUMTEXT。

然后,你可以按以下一栏决定:

sample_1_id (int)
name (int -- tran_long_id)
description (int -- tran_short_id )

你们的申请将知道哪些人与权利挂钩?

无论如何,TEXT确实使用的空间远远大于VARCHAR。 也许有一、二tes。 它的表现是一个问题,而不是空间。 由于你在计算科学文栏的索引时获胜,这不大可能成为一个问题,除非你计划使用索引(在科学文中是可能的)。 VARCHARs的指数限于767兆字塔,因此,你无法使用包括VARCHAR栏767英特的指数。

但是,如果你真的认为有必要,这将允许你分裂。

问题回答

What about this... Let s take for example the "pages" table.

主要“pages:

id - 初级

链接

日期

日期

地位

......

Translate “pages_langs table:

页: 1

lang_id - "languages" table for example 1 ** here all what you want to manage for translation **

标题——例如用兰_id=1页的标题

案文

term - (the term is for url beautify and stuff like this and needs to be in langs table)

language table:

id - 初级

标题

先决条件

选任考试委员会也这样做:

SELECT p.id, p.链接, pl.标题, pl.案文 
FROM pages
INNER JOIN pages_langs pl ON p.id = pl.page_id AND pl.lang_id = <<current lang id>>

任何问题?





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签