数据库设计中的更多行或更多表?
我很确定我已经知道答案,但需要一些确认...
我们收到了 220 个提供商的文本文件。每个文件都是不同类别的提供者。总共有 320 万条记录。
我倾向于创建一个类别表和一个通过 ID 链接到类别的提供程序表,然后对可能在类似州甚至姓氏上搜索的任何其他列建立索引。
另一种选择是每个类别有一个表,但我认为除了较小的行大小之外,这种方法还有很多缺点。
这是一个 PHP/MySQL 实现。
有人认为单独的表格选项出于某种原因更好吗?
谢谢, D .
I'm pretty sure I already know the answer, but would like some confirmation...
We received 220 text files of providers. Each file is a different category of provider. In total there are 3.2 million records.
My inclination is to create a category table and a provider table that links to category by an ID, then index any other columns that may be searched on like state, or even last name.
The other option is to have one table per category, but I think other than the smaller row size there are a lot of disadvantages to this approach.
It's a PHP/MySQL implementation.
Anyone think the separate table option is better for any reason?
Thanks,
D.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
采用两种表方法 -
categories
和providers
。这将使您能够
provider
的state
等列轻松反向搜索类别。从数据结构的角度来看,这也是有意义的。一张表中的一种数据。
Go with two table approach --
categories
andproviders
.This will enable you to
state
ofprovider
.It make sense from data-structure point of view as well. One type of data in one table.
我同意你最初的想法,也同意尼尚特的回答。除了他的观点之外,它还规范了数据,并且如果类别由于某种原因更改名称,则可以轻松更新。
I agree with your original thought, and with Nishant's answer. In addition to his points, it also normalizes the data, and allows easy updates if a category changes names for some reason.