Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. User (user_id,user_name,first_name,last_name,e-mail,password)
  2.  
  3. Alergies(id,name)
  4.  
  5. User_Alegries (id,user_id^,allergy_id^)
  6.  
  7. Diet(diet_id,name)
  8.  
  9. User_Diets(id,user_id^,died_id^)
  10.  
  11. Ingridient (id,name)
  12.  
  13. Ingridient_Diet(id,ingridiet_id^,diet_id^)
  14.  
  15. Recipe(recipe_id,name,description,time_of_day,cook_time)
  16.  
  17. Recipe_User(id,recpe_id^,user_id^,is_favorite)
  18.  
  19. Steps(step_id,description,picture)
  20.  
  21. Recipe_Steps(id,recipe_id^,step_id^)
  22.  
  23. Allergy_Recipe(id,allergy_id^,recipe_id^)
  24.  
  25. Diets_Recipe(id,allergy_id^,recipe_id^)
  26.  
  27.  
  28.  
  29.  
  30.  
  31. CREATE TABLE Users (
  32.  
  33. User_id int NOT NULL PRIMARY KEY
  34.  
  35. user_name varchar(255),
  36.  
  37. first_name varchar(255),
  38.  
  39. last_name varchar(255),
  40.  
  41. email varchar(255)
  42.  
  43. password varchar(255)
  44.  
  45. );
  46.  
  47. CREATE TABLE Alergies (
  48.  
  49. id int NOT NULL PRIMARY KEY
  50.  
  51. name varchar(255),
  52.  
  53. );
  54.  
  55. CREATE TABLE Users_Alergies (
  56.  
  57. id int NOT NULL PRIMARY KEY
  58.  
  59. user_id int,
  60.  
  61. allergy_id int
  62.  
  63. FOREIGN KEY (user_id) REFERENCES Users(user_id)
  64.  
  65. FOREIGN KEY (alergy_id) REFERENCES Users(id)
  66.  
  67. );
  68.  
  69. CREATE TABLE Allergy_Recipes (
  70.  
  71. id int NOT NULL PRIMARY KEY
  72.  
  73. allergy_id int,
  74.  
  75. recipe_id int
  76.  
  77. FOREIGN KEY (allergy_id) REFERENCES Allergy(id)
  78.  
  79. FOREIGN KEY (recipe_id) REFERENCES Recipe(recipe_id)
  80.  
  81. );
  82.  
  83. CREATE TABLE Diet (
  84.  
  85. id int NOT NULL PRIMARY KEY
  86.  
  87. name varchar(255),
  88.  
  89. );
  90.  
  91. CREATE TABLE User_Diets (
  92.  
  93. id int NOT NULL PRIMARY KEY
  94.  
  95. user_id int,
  96.  
  97. diet_id int
  98.  
  99. FOREIGN KEY (user_id) REFERENCES Users(user_id)
  100.  
  101. FOREIGN KEY (diet_id) REFERENCES Diet(id)
  102.  
  103. );
  104.  
  105. CREATE TABLE Diets_Recipes (
  106.  
  107. id int NOT NULL PRIMARY KEY
  108.  
  109. diet_id int,
  110.  
  111. recipe_id int
  112.  
  113. FOREIGN KEY (diet_id) REFERENCES Diets(id)
  114.  
  115. FOREIGN KEY (recipe_id) REFERENCES Recipe(recipe_id)
  116.  
  117. );
  118.  
  119. CREATE TABLE Ingridient (
  120.  
  121. id int NOT NULL PRIMARY KEY
  122.  
  123. name varchar(255),
  124.  
  125. );
  126.  
  127. CREATE TABLE Ingridient_Diet (
  128.  
  129. id int NOT NULL PRIMARY KEY
  130.  
  131. ungridient_id int,
  132.  
  133. diet_id int
  134.  
  135. FOREIGN KEY (ingridient_id) REFERENCES Ingridient(id)
  136.  
  137. FOREIGN KEY (diet_id) REFERENCES Diet(id)
  138.  
  139. );
  140.  
  141. CREATE TABLE Recipe (
  142.  
  143. recipe_id int NOT NULL PRIMARY KEY
  144.  
  145. name varchar(255),
  146.  
  147. description TEXT,
  148.  
  149. time_of_day TIMESTAMP,
  150.  
  151. cook_time TIMESTAMP
  152.  
  153. );
  154.  
  155. CREATE TABLE Recipe_User (
  156.  
  157. id int NOT NULL PRIMARY KEY
  158.  
  159. user_id int,
  160.  
  161. recipe_id int
  162.  
  163. FOREIGN KEY (user_id) REFERENCES Users(user_id)
  164.  
  165. FOREIGN KEY (recipe_id) REFERENCES Recipe(recipe_id)
  166.  
  167. );
  168.  
  169. CREATE TABLE Steps (
  170.  
  171. Step_id int NOT NULL PRIMARY KEY
  172.  
  173. description TEXT,
  174.  
  175. picture varchar(255)
  176.  
  177. );
  178.  
  179. CREATE TABLE Recipe_Steps (
  180.  
  181. id int NOT NULL PRIMARY KEY
  182.  
  183. step_id int,
  184.  
  185. recipe_id int
  186.  
  187. FOREIGN KEY (step_id) REFERENCES Steps(step_id)
  188.  
  189. FOREIGN KEY (recipe_id) REFERENCES Recipe(recipe_id)
  190.  
  191. );
  192.  
  193.  
  194.  
  195.  
  196.  
  197. INSERT INTO Users VALUES(1,”Jej”,”Jovan”,”Mitrovski”,”jey@jey.com”, "bazi1234")
  198.  
  199. INSTERT INTO Alergies VALUES(1,”polen”)
  200.  
  201. INSERT INTO Users_Aleries VALUES(1,1,1)
  202.  
  203. INSERT INTO Diet VALUES(1,”hrono”)
  204.  
  205. INSERT INTO User_Diets VALUES(1,1,1)
  206.  
  207. INSERT INTO Ingridients VALUES(1,”jajce”)
  208.  
  209. INSERT INTO Ingridient_Diet VALUES(1,1,1)
  210.  
  211. INSERT INTO Recipe VALUES(1,”jajca”,”na oko”,282678900,767856787)
  212.  
  213. INSERT INTO Recipe_User VALUES(1,1,1)
  214.  
  215. INSERT INTO Steps VALUES(1,”se zemaat dve jajca”,”slika.jpg”)
  216.  
  217. INSERT INTO Recipe_Steps VALUES(1,1,1)
  218.  
  219. INSERT INTO Allergy_Recipe VALUES(1,1,1)
  220.  
  221. INSERT INTO Diets_Recipe VALUES(1,1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement