我正在创建一个 每家餐厅的餐 table 在我的数据库中,以便我可以在提供他们的个人资料时动态地调用他们。
问题:餐厅菜单卡的差异很大,因此无法标准化数据。
当前 Sol-n : *我的数据结构如下所示
http://i.stack.imgur.com/AbqON.png
^ 这些是两家不同餐厅的结构,因为您可以根据菜单卡识别它们。
每个菜单类别有 5 列以便更好地分类。管理这种数据库非常忙碌,对于非技术人员执行数据输入也非常具有挑战性。
我做错了吗?请纠正我,一些代码引用将是可观的。
最佳答案
我宁愿使用两张 table 。
首先为产品创建一个表:
product_id,text,cat,desc,price
然后为订单创建一个表
order_id,product_id,sequence,type
因此您可以在一个订单中提供多于两种产品,例如:
order_id 1, product_id 5, sequence 1, type starter
order_id 1, product_id 20, sequence 2, type main
order_id 2, product_id 4, sequence 1, type starter
order_id 2, product_id 6, sequence 2, type starter
order_id 2, product_id 22, sequence 3, type main
order_id 3, product_id 4, sequence 1, type starter
order_id 3, product_id 6, sequence 1, type starter
order_id 3, product_id 22, sequence 2, type main
order_id 3, product_id 4, sequence 2, type starter
顺序显示什么时候上菜,类型不是真的必要,但我以你的例子为例。下一步是检查当同一张 table 上的 2 个人订购相同的产品时会发生什么?要么使用数量 - 但我更愿意在订单表中使用相同的产品两次。 - 因此,当有人为主菜订购开胃菜时,您可以自由更改顺序(请参阅 order_id 3)。
关于mysql - 点餐系统——数据库设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23747353/