Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table Countries
- (
- Id int identity primary key,
- Name nvarchar(50) unique
- )
- create table Customers
- (
- Id int identity primary key,
- FirstName nvarchar(25),
- LastName nvarchar(25),
- Gender char(1) CHECK (Gender in ('M', 'F')),
- Age int,
- PhoneNumber char(10),
- CountryId int foreign key references Countries(Id)
- )
- create table Products
- (
- Id int identity primary key,
- Name nvarchar(25) unique,
- Description nvarchar(250),
- Recipe nvarchar(max),
- Price decimal(4,2) CHECK(Price >= 0)--
- )
- create table Feedbacks
- (
- Id int identity primary key,
- Description nvarchar(255),
- Rate decimal(10,2) CHECK (Rate between 0 and 10),
- ProductId int foreign key references Products(Id),
- CustomerId int foreign key references Customers(Id)
- )
- create table Distributors
- (
- Id int identity primary key,
- Name nvarchar(25) unique,
- AddressText nvarchar(30),
- Summary nvarchar(200),
- CountryId int foreign key references Countries(Id)
- )
- create table Ingredients
- (
- Id int identity primary key,
- Name nvarchar(30),
- Description nvarchar(200),
- OriginCountryId int foreign key references Countries(Id),
- DistributorId int foreign key references Distributors(Id)
- )
- create table ProductsIngredients
- (
- ProductId int,
- IngredientId int,
- PRIMARY KEY (ProductId, IngredientId),
- CONSTRAINT FK_ProductsIngredients_Product FOREIGN KEY (ProductId) REFERENCES Products(Id),
- CONSTRAINT FK_ProductsIngredients_Ingredients FOREIGN KEY (IngredientId) REFERENCES Ingredients(Id)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement