存储SET大于64的最佳方式 [英] Best way to store a SET bigger than 64

查看:102
本文介绍了存储SET大于64的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站有一个电影数据库,我正在重新设计,以提高效率。



电影表有一个名为 countries 的字段。此时,使用csv将值存储在 varchar 中。例如:

 西班牙,法国,德国

这是非常缺乏。例如,很难从法国中选择所有电影。



我不能使用 set ,因为有超过64个不同的国家。
我可以创建一个表格的国家和另一个表链接 id_country id_movie 。但是,我需要另一个加入来获取电影数据(像我对演员o导演)。



任何建议?

解决方案

从我的角度来看,一个SET归一化解)使事情更复杂。



使用JOIN不是符合复杂性的东西,它是为数据库制作和擅长的。



如果您需要维护元素的已定义顺序,则必须向该查找表添加一个额外的排序列。


I have a database of movies for my website and I'm redesigning it to make it more efficient.

The movies table has a field called countries. In this moment, the values are stored in varchar, using csv. For example:

Spain,France,Germany

This is very inneficient. For example, It's hard to select all movies from France.

I can't use a set because there are more than 64 different countries. I could make a table of countries and another table that links id_country with id_movie. But then I need to make another join to get the movie data (like I do with actors o directors).

Any suggestions? Which could be the best way to store the countries information?

解决方案

From my point of view a SET (which is a non-normalized solution) makes things more complicated.

Using a JOIN is not something that qualifies as "complexity", it's what databases are made for and are good at.

If you need to maintain a defined order of the elements you will have to add an extra "sort" column to that lookup table.

这篇关于存储SET大于64的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆