Paste Search Dynamic
Recent pastes
CREATE TABLE recipes
  1. -- recipes
  2. create table recipes (
  3. recipe_id INT not null,
  4. recipe_name varchar(30) not null,
  5. PRIMARY KEY (recipe_id),
  6. unique (recipe_name)
  7. );
  8.  
  9. insert into recipes
  10. (recipe_id, recipe_name)
  11. (1,"Tacos"),
  12. (2,"Tomato Soup"),
  13. (3,"Grilled Cheese");
  14.  
  15.  
  16. -- quick check
  17. select recipe_name
  18. from recipes;
  19.  
  20.  
  21. -- ingredients
  22. create table ingredients (
  23. ingredient_id INT not null,
  24. ingredient_name varchar(30) not null,
  25. ingredient_price INT not null,
  26. PRIMARY KEY (ingredient_id),
  27. unique (ingredient_name)
  28. );
  29.  
  30. insert into ingredients
  31. (ingredient_id, ingredient_name, ingredient_price)
  32. (1, "Beef", 5),
  33. (2, "Lettuce", 1),
  34. (3, "Tomatoes", 2),
  35. (4, "Taco Shell", 2),
  36. (5, "Cheese", 3),
  37. (6, "Milk", 1),
  38. (7, "Bread", 2);
  39.  
  40.  
  41. --  recipe_ingredients
  42. create table recipe_ingredients (
  43. recipe_id int not null,
  44. ingredient_id INT not null,
  45. amount INT not null,
  46. PRIMARY KEY (recipe_id,ingredient_id)
  47. );
  48.  
  49. insert into recipe_ingredients
  50. (recipe_id, ingredient_id, amount)
  51. (1,1,1),
  52. (1,2,2),
  53. (1,3,2),
  54. (1,4,3),
  55. (1,5,1),
  56. (2,3,2),
  57. (2,6,1),
  58. (3,5,1),
  59. (3,7,2);
  60.  
  61.  
  62. from recipes
  63. order by recipe_id;
Parsed in 0.032 seconds