帮助设计比萨商店的数据库模式 [英] Help designing a database schema for a pizza store

查看:231
本文介绍了帮助设计比萨商店的数据库模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是脚本:

create table Customer
(
CustomerId int primary key identity(1,1),
Name nvarchar(64) not null,
LastName nvarchar(256) not null,
Telephone nvarchar(32),
MobilePhone nvarchar(32),
Address nvarchar(256)
)

create table Product
(
ProductId int primary key identity(1,1),
Name nvarchar(64),
Price decimal
)

create table StoreOrder
(
StoreOrderId int primary key identity(1,1),
Date datetime,
CustomerId int foreign key references Customer(CustomerId),
Total decimal
)

create table ProductStoreOrder
(
ProductStoreOrderId int primary key identity(1,1),
StoreOrderId int foreign key references StoreOrder(StoreOrderId),
ProductId int foreign key references Product(ProductId),
Quantity int
)

我很困惑如何处理浇头。我应该能够在数据库中添加浇头,并使用N个浇头创建比萨饼,每个顶部也应该有相关的价格。

I'm confused on how to handle toppings. I should be able to add toppings in the database somewhere and create pizzas with N toppings, each topping should also have an associated price.

可以创建一个Toppings表并将其与Product相关联,但并不是每个产品都具有顶部。例如,面包棒,饮料苏打水,沙拉等。

I could create a Toppings table and associate it to Product but not every product has a topping. For example, bread sticks, a diet soda, a salad, etc.

处理这种情况的最佳方法是什么?另外,到目前为止,数据库设计的任何意见?

What would be the best way to handle this situation? Also, any comments on the database design so far?

感谢您的时间。

推荐答案

一个很好的候选人,利用一个超级/亚型DB设计。这是一个快速绘图,我相信在这一点上解决了你所关心的问题。这只是基础,您可以随心所欲地填写所需的属性和定价。

I think this is a good candidate to utilize a super/subtype DB design. Here is a quick drawing that I believe addresses the concerns you have at this point. This is just the base, you can take it and fill in the needed attributes and pricing as you are concerned about.

这篇关于帮助设计比萨商店的数据库模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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