Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. create table Countries
  2. (
  3. Id int identity primary key,
  4. Name nvarchar(50) unique
  5. )
  6.  
  7.  
  8.  
  9. create table Customers
  10. (
  11. Id int identity primary key,
  12. FirstName nvarchar(25),
  13. LastName nvarchar(25),
  14. Gender char(1) CHECK (Gender in ('M', 'F')),
  15. Age int,
  16. PhoneNumber char(10),
  17. CountryId int foreign key references Countries(Id)
  18.  
  19.  
  20. )
  21. create table Products
  22. (
  23. Id int identity primary key,
  24. Name nvarchar(25) unique,
  25. Description nvarchar(250),
  26. Recipe nvarchar(max),
  27. Price decimal(4,2) CHECK(Price >= 0)--
  28.  
  29. )
  30.  
  31. create table Feedbacks
  32. (
  33. Id int identity primary key,
  34. Description nvarchar(255),
  35. Rate decimal(10,2) CHECK (Rate between 0 and 10),
  36. ProductId int foreign key references Products(Id),
  37. CustomerId int foreign key references Customers(Id)
  38. )
  39.  
  40. create table Distributors
  41. (
  42. Id int identity primary key,
  43. Name nvarchar(25) unique,
  44. AddressText nvarchar(30),
  45. Summary nvarchar(200),
  46. CountryId int foreign key references Countries(Id)
  47. )
  48.  
  49. create table Ingredients
  50. (
  51. Id int identity primary key,
  52. Name nvarchar(30),
  53. Description nvarchar(200),
  54. OriginCountryId int foreign key references Countries(Id),
  55. DistributorId int foreign key references Distributors(Id)
  56.  
  57. )
  58.  
  59.  
  60. create table ProductsIngredients
  61. (
  62. ProductId int,
  63. IngredientId int,
  64.  
  65. PRIMARY KEY (ProductId, IngredientId),
  66.  
  67. CONSTRAINT FK_ProductsIngredients_Product FOREIGN KEY (ProductId) REFERENCES Products(Id),
  68. CONSTRAINT FK_ProductsIngredients_Ingredients FOREIGN KEY (IngredientId) REFERENCES Ingredients(Id)
  69. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement