对表格设计感到困惑。如何存储多个数据
我有一个用于存储邮递员覆盖区域的表。它有两个字段
postmanid cover_pincode
我要实现的是,当用户在文本框中输入 pincode 时,会显示覆盖该 pincode 的邮递员列表。
我的疑问是,我如何输入表中的值
1. Multiple pincodes stored in single row like
postmanid->1, covering_pincode-> 626123, 626124, 626432, 654564
或
2.通过每个单独的字段存储每个 pincode,例如
postmanid->1, covering_pincode->626123,
postmanid->1, covering_pincode->626124,
postmanid->1, covering_pincode->626432,
postmanid->1, covering_pincode->654564
请帮助哪一个最适合通过 pincode 搜索表
I have a table for storing the postman coverage area. It has two fields
postmanid
covering_pincode
What i am going to implement is, when a user enters a pincode in the textbox, the list of the postman covering that pincodes are displayed.
My doubt is, how can i enter the values in the table
1. Multiple pincodes stored in single row like
postmanid->1, covering_pincode-> 626123, 626124, 626432, 654564
OR
2.Storing each pincode by each seperate fields like
postmanid->1, covering_pincode->626123,
postmanid->1, covering_pincode->626124,
postmanid->1, covering_pincode->626432,
postmanid->1, covering_pincode->654564
Please help which one is best for searching the table by pincode
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
规范化规则说:使用第二个!
http://dev.mysql.com/tech-resources/文章/intro-to-normalization.html
The rules of normalisation say: use the second one!
http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
我会将每个值存储为表中的单独行,这样可以更轻松地添加/编辑/删除新值,而无需附加或提取单独的 pin 代码。
在数据库表上使用复合键,您不需要主键,并且应该'没有重复。
I'd store each one as a separate row in your table, this would make it easier to add/edit/delete new values without having to append to or extract individual pin codes.
Use a compound key on the database table and you won't need a primary key and shouldn't have duplication.
你真正想要的是第二个表
cover_pincodeid->1,postmanid->1,convering_pincode->626123
covering_pincodeid->2,postmanid->1,converting_pincode->626124
covering_pincodeid->3,postmanid->1,converting_pincode->626125
What you really want is a second table
covering_pincodeid->1,postmanid->1,convering_pincode->626123
covering_pincodeid->2,postmanid->1,convering_pincode->626124
covering_pincodeid->3,postmanid->1,convering_pincode->626125