Table Relations: Problem 5 Problem 5. Online Store Database
Как да разбера кой е Тест 3, на който ми гърми кода? Ето го и него, диаграмата изглежда по същия начин (моята) ... Не мога да дебъгна, ако не знам какво гърми :)
create table Cities(
CityID int,
Name nvarchar(50),
constraint PF_Cities primary key (CityID));
create table Customers(
customerID int,
Name nvarchar(50),
Birthday date,
CityId int,
constraint PF_Customers primary key(CustomerID),
constraint FK_Customers_Cities foreign key (CityID)
references Cities(CityID));
create table Orders(
OrderID int,
CustomerId int,
constraint PK_Orders primary key(OrderId),
constraint FK_Orders_Customers foreign key(CustomerID)
references Customers(customerID));
create table ItemTypes(
ItemTypeID int,
Name nvarchar(50),
constraint PK_ItemTypes primary key(ItemTypeID));
create table Items(
ItemID int,
Name nvarchar(50),
ItemTypeID int,
constraint PK_Items primary key(ItemID),
constraint FP_Items_ItemTypes foreign key(ItemTypeID)
references ItemTypes(ItemTypeID));
create table OrderItems(
OrderId int,
ItemID int,
constraint PK_OrderItems primary key(OrderID, ItemID),
constraint FK_OI_Orders foreign key (OrderID)
references Orders(OrderID),
constraint FK_OI_Items foreign key(ItemID)
references Items(ItemID));
Da, eto:
create table Cities(
CityID int,
Name nvarchar(50),
constraint PF_Cities primary key (CityID));
create table Customers(
customerID int,
Name nvarchar(50),
Birthday date,
CityID int,
constraint PF_Customers primary key(CustomerID),
constraint FK_Customers_Cities foreign key (CityID)
references Cities(CityID));
create table Orders(
OrderID int,
CustomerID int,
constraint PK_Orders primary key(OrderID),
constraint FK_Orders_Customers foreign key(CustomerID)
references Customers(customerID));
create table ItemTypes(
ItemTypeID int,
Name nvarchar(50),
constraint PK_ItemTypes primary key(ItemTypeID));
create table Items(
ItemID int,
Name nvarchar(50),
ItemTypeID int,
constraint PK_Items primary key(ItemID),
constraint FP_Items_ItemTypes foreign key(ItemTypeID)
references ItemTypes(ItemTypeID));
create table OrderItems(
OrderID int,
ItemID int,
constraint PK_OrderItems primary key(OrderID, ItemID),
constraint FK_OI_Orders foreign key (OrderID)
references Orders(OrderID),
constraint FK_OI_Items foreign key(ItemID)
references Items(ItemID));
Мерси, на мен грешката ми беше че вместо 'create table ItemTypes' съм написал 'create table ItemsTypes'...заради една буква...