Advertisement
Guest User

Untitled

a guest
Feb 9th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.06 KB | None | 0 0
  1. CREATE TABLE `users` (
  2.     `username` VARCHAR(10) NOT NULL,
  3.     `password` VARCHAR(32) NOT NULL,
  4.     CONSTRAINT pkUsers PRIMARY KEY(`username`)
  5. ) ENGINE=InnoDB;
  6.  
  7. CREATE TABLE `recipes` (
  8.     `id` INT NOT NULL AUTO_INCREMENT,
  9.     `name` VARCHAR(20) NOT NULL,
  10.     CONSTRAINT pkRecipes PRIMARY KEY(`id`)
  11. ) ENGINE=InnoDB;
  12.  
  13. CREATE TABLE `ingredients` (
  14.     `id` INT NOT NULL AUTO_INCREMENT,
  15.     `name` VARCHAR(20) NOT NULL,
  16.     CONSTRAINT pkIngredients PRIMARY KEY(`id`)
  17. ) ENGINE=InnoDB;
  18.  
  19. CREATE TABLE `userCabinet` (
  20.     `user_id` VARCHAR(10) NOT NULL,
  21.     `ingredient_id` INT NOT NULL,
  22.     CONSTRAINT fkCabUser FOREIGN KEY(`user_id`) REFERENCES `users`(`username`),
  23.     CONSTRAINT fkCabIngrdt FOREIGN KEY(`ingredient_id`) REFERENCES `ingredients`(`id`)
  24. ) ENGINE=InnoDB;
  25.  
  26. CREATE TABLE `recipeComponents` (
  27.     `recipe_id` INT NOT NULL,
  28.     `ingredient_id` INT NOT NULL,
  29.     CONSTRAINT fkCmpntRecipe FOREIGN KEY(`recipe_id`) REFERENCES `recipes`(`id`),
  30.     CONSTRAINT fkCmpntIngrdt FOREIGN KEY(`ingredient_id`) REFERENCES `ingredients`(`id`)
  31. ) ENGINE=InnoDB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement