Database design 帮助设计比萨饼店的数据库模式

Database design 帮助设计比萨饼店的数据库模式,database-design,schema,Database Design,Schema,以下是脚本: 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 prim

以下是脚本:

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个配料的比萨饼,每个配料也应该有一个相关的价格

可以创建一个浇头表并将其与产品关联,但不是每个产品都有浇头。例如,面包条、减肥苏打水、沙拉等

处理这种情况的最佳方法是什么?还有,到目前为止对数据库设计有何评论


谢谢您的时间。

您可以尝试以下方法:

  • 比萨饼、苏打水、棍棒、沙拉都很好吃 产品表
  • 产品有许多浇头(联接表中两个表的外键,此联接表中的价格)

在您可以在另一个表中定义产品“模板”后,定义类别以及产品是否具有浇头或其他特殊属性。

按照@Andy的建议,或向产品表添加一个布尔值,指示产品是否为浇头

我认为这是利用超级/子类型DB设计的一个很好的候选者。这里有一个快速绘图,我相信它解决了您在这一点上的担忧。这只是基础,您可以根据需要填写所需的属性和定价


有什么意见吗?首先,现在的每一列都可以为空。那不太可能是对的。您将如何设计包含订单的模式?2.您如何轻松地缩放“类别”,为每个类别制作一个表格?