开发者

which one is best for performance for my project, more columns or more rows?

I'm writ开发者_运维技巧ing a localization plugin for my cms. I have a few options to do this but the easiest is creating extra columns for each language (like title_en, content_en).

The other way is creating a column called 'language' and each language in each article I create a row. However dynamic areas are only 'title', 'content' and 'nice_url' but there are 10 columns (id, category, display, date ...) and these columns will be unnecessary.

The other ways (like creating extra table named article_translations) are not suitable for my CMS's plugin algorithm.


More columns is not scaleable, and it's much easier to add rows than columns.

It is better to have a row for each language's data.

You haven't posted much information, but try to put all the common data into a one table and put the language-specific data in another child table with either an foreign key or an enum type for language. Use a foreign key to a language table if there is info about the language to want to store/retrieve. Use an enum instead if you want to check the value, or just use text if you are not fussy.

Also, it should be noted that you are unlikely to want more than one language at a time, so there wold be no advantage in having a hugely wide table where one row hold all information about all languages.


The solution is depends on how many languages are you planning support? If several you can add several additional columns without any problems. It will be easy to use this model for switching between languages. But if you are planning using many languages I think you should think about additional table(s).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜