Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.85 KB | None | 0 0
  1. -- There is a list of all the dishes they prepare
  2. CREATE TABLE dish (
  3.     id serial PRIMARY KEY,
  4.     name text,
  5.     description text
  6. );
  7.  
  8. -- There is a list of all of its costumers
  9. CREATE TABLE costumer (
  10.     id serial PRIMARY KEY,
  11.     first_name text,
  12.     last_name text
  13. );
  14.  
  15. -- There is a list of the menu of the day
  16. CREATE TABLE menu (
  17.     id serial PRIMARY KEY,
  18.     published DATE DEFAULT CURRENT_DATE
  19. );
  20.  
  21. -- The list of the dishes of the menu
  22. CREATE TABLE menu_dish (
  23.     menu_id INTEGER REFERENCES menu(id) ON DELETE CASCADE ON UPDATE CASCADE,
  24.     dish_id INTEGER REFERENCES dish(id) ON DELETE CASCADE ON UPDATE CASCADE,
  25.     PRIMARY KEY (menu_id, dish_id)
  26. );
  27.  
  28. -- The list of the orders
  29. CREATE TABLE ORDER (
  30.     id serial PRIMARY KEY,
  31.     costumer_id INTEGER REFERENCES costumer(id) ON DELETE CASCADE ON UPDATE CASCADE,
  32.     ordered TIMESTAMP WITH TIME ZONE DEFAULT now()
  33. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement