Advertisement
Guest User

restaurant-data.sql

a guest
Mar 21st, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DROP SCHEMA IF EXISTS testing CASCADE;
  2. CREATE SCHEMA testing;
  3. -- GRANT ALL PRIVILEGES ON SCHEMA testing TO restaurant;
  4.  
  5. CREATE TABLE ingredient (
  6.   code          CHAR(8) PRIMARY KEY,
  7.   name          VARCHAR(127) UNIQUE,
  8.   calories      FLOAT,
  9.   cost_per_unit NUMERIC(7, 2),
  10.   is_kosher     BOOLEAN
  11. );
  12. CREATE TABLE recipe (
  13.   name         VARCHAR(63) PRIMARY KEY,
  14.   instructions TEXT,
  15.   servings     INT,
  16.   course       VARCHAR(15),
  17.   season       VARCHAR(15)
  18. );
  19. CREATE TABLE recipe_ingredient (
  20.   ingredient CHAR(8) REFERENCES ingredient ON UPDATE CASCADE ON DELETE SET NULL,
  21.   recipe     VARCHAR(63) REFERENCES recipe ON UPDATE CASCADE ON DELETE CASCADE,
  22.   amount     NUMERIC(12, 6)
  23. );
  24. CREATE TABLE inventory (
  25.   ingredient  CHAR(8) REFERENCES ingredient ON UPDATE CASCADE ON DELETE SET NULL,
  26.   amount      NUMERIC(14, 6)
  27. );
  28. CREATE TABLE orders (
  29.   order_number  SERIAL PRIMARY KEY,
  30.   recipe        VARCHAR(63) REFERENCES recipe ON UPDATE CASCADE ON DELETE CASCADE,
  31.   quantity      INTEGER,
  32.   filled        TIMESTAMP NULL
  33. );
  34.  
  35. GRANT ALL PRIVILEGES ON ingredient, recipe, recipe_ingredient TO restaurant;
  36.  
  37. INSERT INTO ingredient VALUES ('11111111', 'Sliced Bread', 1000, 2.99, TRUE);
  38. INSERT INTO ingredient VALUES ('11111112', 'Roasted Chicken', 200, 7.49, TRUE);
  39. INSERT INTO ingredient VALUES ('11111113', 'Mayonnaise', 3200, 3.45, TRUE);
  40. INSERT INTO ingredient VALUES ('11111114', 'Ham', 450, 6.79, FALSE);
  41. INSERT INTO ingredient VALUES ('11111115', 'Cheese', 500, 3.00, TRUE);
  42. INSERT INTO ingredient VALUES ('11111116', 'Mustard', 150, 1.75, TRUE);
  43. INSERT INTO ingredient VALUES ('11111117', 'Potatoes (12)', 1000, 4.00, TRUE);
  44. INSERT INTO ingredient VALUES ('11111118', 'Lettuce', 75, 2.99, TRUE);
  45. INSERT INTO ingredient VALUES ('11111119', 'Ground Beef', 600, 4.59, TRUE);
  46. INSERT INTO ingredient VALUES ('11111120', 'Hamburger Buns', 400, 1.50, TRUE);
  47. INSERT INTO ingredient VALUES ('11111121', 'Salad Dressing', 4800, 3.99, TRUE);
  48. INSERT INTO ingredient VALUES ('11111122', 'Pie Crust', 1000, 1.50, TRUE);
  49. INSERT INTO ingredient VALUES ('11111123', 'Pumpkin Pie Filling', 2000, 2.99, TRUE);
  50. INSERT INTO ingredient VALUES ('11111124', 'Vanilla Ice Cream', 1600, 2.99, TRUE);
  51. INSERT INTO ingredient VALUES ('11111125', 'Chocolate Sauce', 6400, 5.00, TRUE);
  52. INSERT INTO ingredient VALUES ('11111126', 'Milk', 1600, 2.79, TRUE);
  53. INSERT INTO recipe VALUES ('Chicken Sandwich', 'Spread mayonnaise on a slice of bread. Place chicken on top, add a second slice of bread on top of that.', 1, 'Entree', 'Spring');
  54. INSERT INTO recipe VALUES ('Ham Sandwich', 'Spread mustard on two slices of bread. Place ham and cheese between them.', 1, 'Entree', 'Fall');
  55. INSERT INTO recipe VALUES ('French Fries', 'Slice potatoes and fry them.', 3, 'Side', 'All');
  56. INSERT INTO recipe VALUES ('Garden Salad', 'Assemble ingredients in a bowl and toss them together.', 8, 'Side', 'All');
  57. INSERT INTO recipe VALUES ('Hamburger', 'Form ground beef into patties. Cook patties to order. Place patties on bun. Serve open face', 1, 'Entree', 'All');
  58. INSERT INTO recipe VALUES ('Pumpkin Pie', 'Pour pie filling into pie crust. Bake at an appropriate temperature until done.', 8, 'Dessert', 'Fall');
  59. INSERT INTO recipe VALUES ('Ice Cream Sundae', 'Scoop ice cream into dish, and add chocolate sauce.', 1, 'Dessert', 'Spring');
  60. INSERT INTO recipe VALUES ('Milkshake', 'Add ice cream and milk to blender, and blend until smooth. Serve in a tall glass.', 2, 'Dessert', 'All');
  61. INSERT INTO recipe VALUES ('Ham and Mashed Potatoes', 'Roast ham in oven until hot. Boil potatoes until done, then mash and add milk to make them smooth.', 4, 'Entree', 'Spring');
  62. INSERT INTO recipe_ingredient VALUES ('11111111', 'Chicken Sandwich', .2);
  63. INSERT INTO recipe_ingredient VALUES ('11111112', 'Chicken Sandwich', .2);
  64. INSERT INTO recipe_ingredient VALUES ('11111113', 'Chicken Sandwich', .03125);
  65. INSERT INTO recipe_ingredient VALUES ('11111111', 'Ham Sandwich', .2);
  66. INSERT INTO recipe_ingredient VALUES ('11111114', 'Ham Sandwich', .2);
  67. INSERT INTO recipe_ingredient VALUES ('11111116', 'Ham Sandwich', .015625);
  68. INSERT INTO recipe_ingredient VALUES ('11111115', 'Ham Sandwich', .125);
  69. INSERT INTO recipe_ingredient VALUES ('11111117', 'French Fries', .1667);
  70. INSERT INTO recipe_ingredient VALUES ('11111118', 'Garden Salad', .125);
  71. INSERT INTO recipe_ingredient VALUES ('11111121', 'Garden Salad', .015625);
  72. INSERT INTO recipe_ingredient VALUES ('11111119', 'Hamburger', .25);
  73. INSERT INTO recipe_ingredient VALUES ('11111120', 'Hamburger', .25);
  74. INSERT INTO recipe_ingredient VALUES ('11111122', 'Pumpkin Pie', 1);
  75. INSERT INTO recipe_ingredient VALUES ('11111123', 'Pumpkin Pie', 1);
  76. INSERT INTO recipe_ingredient VALUES ('11111124', 'Pumpkin Pie', .0625);
  77. INSERT INTO recipe_ingredient VALUES ('11111124', 'Ice Cream Sundae', .0625);
  78. INSERT INTO recipe_ingredient VALUES ('11111125', 'Ice Cream Sundae', .03125);
  79. INSERT INTO recipe_ingredient VALUES ('11111124', 'Milkshake', .125);
  80. INSERT INTO recipe_ingredient VALUES ('11111126', 'Milkshake', .0625);
  81. INSERT INTO recipe_ingredient VALUES ('11111114', 'Ham and Mashed Potatoes', 1);
  82. INSERT INTO recipe_ingredient VALUES ('11111117', 'Ham and Mashed Potatoes', .5);
  83. INSERT INTO recipe_ingredient VALUES ('11111126', 'Ham and Mashed Potatoes', .0625);
  84.  
  85. -- Start with enough inventory to make 10 of everything
  86. INSERT INTO inventory
  87. SELECT ingredient, sum(amount) * 10
  88. FROM recipe_ingredient
  89. GROUP BY ingredient;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement