表中有多少字段是“太多”? [英] How many fields is 'too many' in a table?

查看:284
本文介绍了表中有多少字段是“太多”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个同事计划一个新的应用程序的数据库,将有几个表,每个超过30字段。这是过多吗?也许我只是没有足够的理解。

I have a coworker who is planning a database for a new app that will have several tables with over 30 fields each. Is this excessive? Maybe I'm just not enterprisey enough to understand.

编辑:另外,很多字段都是选项类型的东西(比如在请求表单上,你希望你的部件是黄色还是绿色,有一个字段为'color'与枚举)。很可能这些将被添加或删除随着时间的推移。我没有真正做数据库设计,并试图远离它自己,所以也许我是完全愚蠢的,但肯定有一个更好的方法这样做??

Also, a lot of the fields are option-type sort of things (like on a request form, would you like your widget to be yellow or green, he has a field for 'colour' with an enum). It's quite likely that these will be added to or removed over time. I haven't really done database design and try to stay away from it myself, so maybe I'm being completely stupid, but surely there's a better way of doing this??

推荐答案

数据库表可以合法地有30个或更多的字段。你需要看看的是数据的归一化,以及归一化是否有意义。它通常会在未来改变,以及。

Database tables can legitimately have 30 or more fields in them. What you need to look at is the normalization of the data and whether that normalization makes any sense. It will normally change in the future, as well. But, you want to try to minimize that.

例如,如果您有一个包含地址的表格,您是否包含城市,州和邮政编码字段?或者,你只包括一个字段点到一个单独的表中的记录为那些值?单独的表格将包含唯一的城市,州,邮政编码组合。将数据拆分为两个表的效果是减少存储的数据量(很可能但不是绝对的),但是当您对数据库运行查询时会增加一些复杂性。现在,你必须处理2表而不是只有一个。但是,在明亮的一面,它更干净,更小(可能)。

For instance, if you have a table that has addresses in it, do you include the city, state, and zip code fields in that table? Or, do you only include one field that "points" to a record in a separate table for those values? The separate table would contain unique city, state, zip code combinations. The effect of splitting the data into two tables is a reduction in the amount of data stored (most likely but not absolute) but a bit of added complexity when you go to run queries against the database. Now, you have to deal with 2 tables instead of just one. But, on the bright side, it's much cleaner, and much smaller (likely).

真正的答案是可以离开city-state-zip数据在地址表在适当的情况下。或者,你可能想标准化出来。

The real answer is it's okay to leave the city-state-zip data in the address table in the right circumstances. Or, you might want to "normalize" it out. Both are okay.

找到一个好的数据库管理员,并雇用他们短期内审查计划,如果它在预算。从长远来看,它将得到回报。

Find a good database administrator and hire them short term to review the plan, if it's in the budget. It will pay off in the long run.

这篇关于表中有多少字段是“太多”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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