Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 多方面具有固定值的一对多关系_Sql Server_Database_Database Design_One To Many - Fatal编程技术网

Sql server 多方面具有固定值的一对多关系

Sql server 多方面具有固定值的一对多关系,sql-server,database,database-design,one-to-many,Sql Server,Database,Database Design,One To Many,我有一个要求,我有仓库,仓库可以有5个固定类别的产品(一次不止一个,例如wh1可以有producttype1和producttype2产品)。建议的数据库设计应该是什么。一种选择是创建固定值的单独表,并与仓库建立多对多关系。还有什么其他选择 仓库表 WareHouseID, WareHouseTitle,Address 固定产品类型 Producttype1,Producttype2,Producttype3,Producttype4,Producttype5 我想你已经回答了你自己的问题

我有一个要求,我有仓库,仓库可以有5个固定类别的产品(一次不止一个,例如wh1可以有producttype1和producttype2产品)。建议的数据库设计应该是什么。一种选择是创建固定值的单独表,并与仓库建立多对多关系。还有什么其他选择 仓库表

WareHouseID, WareHouseTitle,Address
固定产品类型

Producttype1,Producttype2,Producttype3,Producttype4,Producttype5 

我想你已经回答了你自己的问题:

仓库可以有5个固定类别的产品(一次超过一个>例如wh1可以有producttype1和producttype2产品)


唯一正确的设计应该是仓库表1-*M2M表*-1产品类型表,因为其他任何东西都会违反3NF规则。

您永远不想允许5种可能的类别,因为在现实世界中,情况会发生变化。你不想回去重新设计,因为明天有人会推出第六款。绝对是多对多的要求。