sms

DietDB

sms
Jun 2nd, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 21.04 KB | None | 0 0
  1. -- MySQL Workbench Forward Engineering
  2.  
  3. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  4. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  5. SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
  6.  
  7. -- -----------------------------------------------------
  8. -- Schema DietDB
  9. -- -----------------------------------------------------
  10. DROP SCHEMA IF EXISTS `DietDB` ;
  11.  
  12. -- -----------------------------------------------------
  13. -- Schema DietDB
  14. -- -----------------------------------------------------
  15. CREATE SCHEMA IF NOT EXISTS `DietDB` DEFAULT CHARACTER SET utf8 ;
  16. USE `DietDB` ;
  17.  
  18. -- -----------------------------------------------------
  19. -- Table `DietDB`.`FoodItems`
  20. -- -----------------------------------------------------
  21. DROP TABLE IF EXISTS `DietDB`.`FoodItems` ;
  22.  
  23. CREATE TABLE IF NOT EXISTS `DietDB`.`FoodItems` (
  24.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  25.   `name` VARCHAR(255) NOT NULL,
  26.   `fluid` TINYINT(1) NOT NULL,
  27.   `kcal` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'per 100g/100ml',
  28.   `carbohydrate` DOUBLE UNSIGNED NOT NULL DEFAULT 0 COMMENT 'per 100g/100ml',
  29.   `fat` DOUBLE UNSIGNED NOT NULL DEFAULT 0 COMMENT 'per 100g/100ml',
  30.   `protein` DOUBLE UNSIGNED NOT NULL DEFAULT 0 COMMENT 'per 100g/100ml',
  31.   PRIMARY KEY (`id`))
  32. ENGINE = InnoDB;
  33.  
  34. CREATE UNIQUE INDEX `name_UNIQUE` ON `DietDB`.`FoodItems` (`name` ASC);
  35.  
  36.  
  37. -- -----------------------------------------------------
  38. -- Table `DietDB`.`Servings`
  39. -- -----------------------------------------------------
  40. DROP TABLE IF EXISTS `DietDB`.`Servings` ;
  41.  
  42. CREATE TABLE IF NOT EXISTS `DietDB`.`Servings` (
  43.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  44.   `foodItem_id` INT UNSIGNED NOT NULL,
  45.   `name` VARCHAR(255) NOT NULL,
  46.   `units` DOUBLE UNSIGNED NOT NULL DEFAULT 0,
  47.   PRIMARY KEY (`id`, `foodItem_id`),
  48.   CONSTRAINT `fk_Servings_FoodItems1`
  49.     FOREIGN KEY (`foodItem_id`)
  50.     REFERENCES `DietDB`.`FoodItems` (`id`)
  51.     ON DELETE RESTRICT
  52.     ON UPDATE CASCADE)
  53. ENGINE = InnoDB;
  54.  
  55. CREATE INDEX `fk_Servings_FoodItems1_idx` ON `DietDB`.`Servings` (`foodItem_id` ASC);
  56.  
  57.  
  58. -- -----------------------------------------------------
  59. -- Table `DietDB`.`Sets`
  60. -- -----------------------------------------------------
  61. DROP TABLE IF EXISTS `DietDB`.`Sets` ;
  62.  
  63. CREATE TABLE IF NOT EXISTS `DietDB`.`Sets` (
  64.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  65.   `name` VARCHAR(255) NOT NULL,
  66.   PRIMARY KEY (`id`))
  67. ENGINE = InnoDB;
  68.  
  69. CREATE UNIQUE INDEX `name_UNIQUE` ON `DietDB`.`Sets` (`name` ASC);
  70.  
  71.  
  72. -- -----------------------------------------------------
  73. -- Table `DietDB`.`Set_has_FoodItems`
  74. -- -----------------------------------------------------
  75. DROP TABLE IF EXISTS `DietDB`.`Set_has_FoodItems` ;
  76.  
  77. CREATE TABLE IF NOT EXISTS `DietDB`.`Set_has_FoodItems` (
  78.   `set_id` INT UNSIGNED NOT NULL,
  79.   `foodItem_id` INT UNSIGNED NOT NULL,
  80.   `units` DOUBLE UNSIGNED NOT NULL,
  81.   PRIMARY KEY (`set_id`, `foodItem_id`),
  82.   CONSTRAINT `fk_Sets_has_FoodItems_Sets1`
  83.     FOREIGN KEY (`set_id`)
  84.     REFERENCES `DietDB`.`Sets` (`id`)
  85.     ON DELETE RESTRICT
  86.     ON UPDATE CASCADE,
  87.   CONSTRAINT `fk_Sets_has_FoodItems_FoodItems1`
  88.     FOREIGN KEY (`foodItem_id`)
  89.     REFERENCES `DietDB`.`FoodItems` (`id`)
  90.     ON DELETE RESTRICT
  91.     ON UPDATE CASCADE)
  92. ENGINE = InnoDB;
  93.  
  94. CREATE INDEX `fk_Sets_has_FoodItems_FoodItems1_idx` ON `DietDB`.`Set_has_FoodItems` (`foodItem_id` ASC);
  95.  
  96. CREATE INDEX `fk_Sets_has_FoodItems_Sets1_idx` ON `DietDB`.`Set_has_FoodItems` (`set_id` ASC);
  97.  
  98.  
  99. -- -----------------------------------------------------
  100. -- Table `DietDB`.`Meals`
  101. -- -----------------------------------------------------
  102. DROP TABLE IF EXISTS `DietDB`.`Meals` ;
  103.  
  104. CREATE TABLE IF NOT EXISTS `DietDB`.`Meals` (
  105.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  106.   `date` DATE NOT NULL,
  107.   `time` TIME NULL,
  108.   PRIMARY KEY (`id`))
  109. ENGINE = InnoDB;
  110.  
  111.  
  112. -- -----------------------------------------------------
  113. -- Table `DietDB`.`Meals_has_Sets`
  114. -- -----------------------------------------------------
  115. DROP TABLE IF EXISTS `DietDB`.`Meals_has_Sets` ;
  116.  
  117. CREATE TABLE IF NOT EXISTS `DietDB`.`Meals_has_Sets` (
  118.   `meal_id` INT UNSIGNED NOT NULL,
  119.   `set_id` INT UNSIGNED NOT NULL,
  120.   `amount` INT UNSIGNED NOT NULL DEFAULT 0,
  121.   PRIMARY KEY (`meal_id`, `set_id`),
  122.   CONSTRAINT `fk_Meals_has_Sets_Meals1`
  123.     FOREIGN KEY (`meal_id`)
  124.     REFERENCES `DietDB`.`Meals` (`id`)
  125.     ON DELETE RESTRICT
  126.     ON UPDATE CASCADE,
  127.   CONSTRAINT `fk_Meals_has_Sets_Sets1`
  128.     FOREIGN KEY (`set_id`)
  129.     REFERENCES `DietDB`.`Sets` (`id`)
  130.     ON DELETE RESTRICT
  131.     ON UPDATE CASCADE)
  132. ENGINE = InnoDB;
  133.  
  134. CREATE INDEX `fk_Meals_has_Sets_Sets1_idx` ON `DietDB`.`Meals_has_Sets` (`set_id` ASC);
  135.  
  136. CREATE INDEX `fk_Meals_has_Sets_Meals1_idx` ON `DietDB`.`Meals_has_Sets` (`meal_id` ASC);
  137.  
  138.  
  139. -- -----------------------------------------------------
  140. -- Table `DietDB`.`Meals_has_FoodItems`
  141. -- -----------------------------------------------------
  142. DROP TABLE IF EXISTS `DietDB`.`Meals_has_FoodItems` ;
  143.  
  144. CREATE TABLE IF NOT EXISTS `DietDB`.`Meals_has_FoodItems` (
  145.   `meal_id` INT UNSIGNED NOT NULL,
  146.   `foodItem_id` INT UNSIGNED NOT NULL,
  147.   `amount` INT UNSIGNED NOT NULL DEFAULT 0,
  148.   PRIMARY KEY (`meal_id`, `foodItem_id`),
  149.   CONSTRAINT `fk_Meals_has_FoodItems_Meals1`
  150.     FOREIGN KEY (`meal_id`)
  151.     REFERENCES `DietDB`.`Meals` (`id`)
  152.     ON DELETE RESTRICT
  153.     ON UPDATE CASCADE,
  154.   CONSTRAINT `fk_Meals_has_FoodItems_FoodItems1`
  155.     FOREIGN KEY (`foodItem_id`)
  156.     REFERENCES `DietDB`.`FoodItems` (`id`)
  157.     ON DELETE RESTRICT
  158.     ON UPDATE CASCADE)
  159. ENGINE = InnoDB;
  160.  
  161. CREATE INDEX `fk_Meals_has_FoodItems_FoodItems1_idx` ON `DietDB`.`Meals_has_FoodItems` (`foodItem_id` ASC);
  162.  
  163. CREATE INDEX `fk_Meals_has_FoodItems_Meals1_idx` ON `DietDB`.`Meals_has_FoodItems` (`meal_id` ASC);
  164.  
  165.  
  166. -- -----------------------------------------------------
  167. -- Table `DietDB`.`Meals_has_Servings`
  168. -- -----------------------------------------------------
  169. DROP TABLE IF EXISTS `DietDB`.`Meals_has_Servings` ;
  170.  
  171. CREATE TABLE IF NOT EXISTS `DietDB`.`Meals_has_Servings` (
  172.   `meal_id` INT UNSIGNED NOT NULL,
  173.   `serving_id` INT UNSIGNED NOT NULL,
  174.   `foodItem_id` INT UNSIGNED NOT NULL,
  175.   `amount` INT UNSIGNED NOT NULL DEFAULT 1,
  176.   PRIMARY KEY (`meal_id`, `serving_id`, `foodItem_id`),
  177.   CONSTRAINT `fk_Meals_has_Servings_Meals1`
  178.     FOREIGN KEY (`meal_id`)
  179.     REFERENCES `DietDB`.`Meals` (`id`)
  180.     ON DELETE RESTRICT
  181.     ON UPDATE CASCADE,
  182.   CONSTRAINT `fk_Meals_has_Servings_Servings1`
  183.     FOREIGN KEY (`serving_id` , `foodItem_id`)
  184.     REFERENCES `DietDB`.`Servings` (`id` , `foodItem_id`)
  185.     ON DELETE RESTRICT
  186.     ON UPDATE CASCADE)
  187. ENGINE = InnoDB;
  188.  
  189. CREATE INDEX `fk_Meals_has_Servings_Servings1_idx` ON `DietDB`.`Meals_has_Servings` (`serving_id` ASC, `foodItem_id` ASC);
  190.  
  191. CREATE INDEX `fk_Meals_has_Servings_Meals1_idx` ON `DietDB`.`Meals_has_Servings` (`meal_id` ASC);
  192.  
  193. USE `DietDB` ;
  194.  
  195. -- -----------------------------------------------------
  196. -- Placeholder table for view `DietDB`.`ServingsView`
  197. -- -----------------------------------------------------
  198. CREATE TABLE IF NOT EXISTS `DietDB`.`ServingsView` (`serving_id` INT, `foodItem_id` INT, `foodItem_name` INT, `serving_name` INT, `units` INT, `fluid` INT, `kcal` INT, `carbohydrate` INT, `fat` INT, `protein` INT);
  199.  
  200. -- -----------------------------------------------------
  201. -- Placeholder table for view `DietDB`.`SetsView`
  202. -- -----------------------------------------------------
  203. CREATE TABLE IF NOT EXISTS `DietDB`.`SetsView` (`set_id` INT, `set_name` INT, `kcal` INT, `carbohydrate` INT, `fat` INT, `protein` INT);
  204.  
  205. -- -----------------------------------------------------
  206. -- Placeholder table for view `DietDB`.`MealsView_Servings`
  207. -- -----------------------------------------------------
  208. CREATE TABLE IF NOT EXISTS `DietDB`.`MealsView_Servings` (`meal_id` INT, `kcal` INT, `carbohydrate` INT, `fat` INT, `protein` INT);
  209.  
  210. -- -----------------------------------------------------
  211. -- Placeholder table for view `DietDB`.`MealsView_FoodItems`
  212. -- -----------------------------------------------------
  213. CREATE TABLE IF NOT EXISTS `DietDB`.`MealsView_FoodItems` (`meal_id` INT, `kcal` INT, `carbohydrate` INT, `fat` INT, `protein` INT);
  214.  
  215. -- -----------------------------------------------------
  216. -- Placeholder table for view `DietDB`.`MealsView_Sets`
  217. -- -----------------------------------------------------
  218. CREATE TABLE IF NOT EXISTS `DietDB`.`MealsView_Sets` (`meal_id` INT, `kcal` INT, `carbohydrate` INT, `fat` INT, `protein` INT);
  219.  
  220. -- -----------------------------------------------------
  221. -- Placeholder table for view `DietDB`.`MealsView`
  222. -- -----------------------------------------------------
  223. CREATE TABLE IF NOT EXISTS `DietDB`.`MealsView` (`meal_id` INT, `date` INT, `time` INT, `kcal` INT, `carbohydrate` INT, `fat` INT, `protein` INT);
  224.  
  225. -- -----------------------------------------------------
  226. -- Placeholder table for view `DietDB`.`Days`
  227. -- -----------------------------------------------------
  228. CREATE TABLE IF NOT EXISTS `DietDB`.`Days` (`date` INT, `kcal` INT, `carbohydrate` INT, `fat` INT, `protein` INT);
  229.  
  230. -- -----------------------------------------------------
  231. -- View `DietDB`.`ServingsView`
  232. -- -----------------------------------------------------
  233. DROP VIEW IF EXISTS `DietDB`.`ServingsView` ;
  234. DROP TABLE IF EXISTS `DietDB`.`ServingsView`;
  235. USE `DietDB`;
  236. CREATE  OR REPLACE VIEW `ServingsView` AS
  237.     SELECT
  238.         s.id as serving_id,
  239.         i.id as foodItem_id,
  240.         i.`name` as foodItem_name,
  241.         s.`name` as serving_name,
  242.         units,
  243.         fluid,
  244.         (kcal*units)/100 as kcal,
  245.         (carbohydrate*units)/100 as carbohydrate,
  246.         (fat*units)/100 as fat,
  247.         (protein*units)/100 as protein
  248.     FROM
  249.         servings s
  250.             JOIN
  251.         FoodItems i ON i.id = FoodItem_id;
  252.  
  253. -- -----------------------------------------------------
  254. -- View `DietDB`.`SetsView`
  255. -- -----------------------------------------------------
  256. DROP VIEW IF EXISTS `DietDB`.`SetsView` ;
  257. DROP TABLE IF EXISTS `DietDB`.`SetsView`;
  258. USE `DietDB`;
  259. CREATE  OR REPLACE VIEW `SetsView` AS
  260.     SELECT
  261.         s.id AS set_id,
  262.         s.`name` AS set_name,
  263.         SUM((kcal*units)/100) AS kcal,
  264.         SUM((carbohydrate*units)/100) AS carbohydrate,
  265.         SUM((fat*units)/100) AS fat,
  266.         SUM((protein*units)/100) AS protein
  267.     FROM
  268.         Sets s
  269.             JOIN
  270.         Set_has_FoodItems h ON h.set_id = s.id
  271.             JOIN
  272.         FoodItems i ON h.foodItem_id = i.id
  273.     GROUP BY s.id;
  274.  
  275. -- -----------------------------------------------------
  276. -- View `DietDB`.`MealsView_Servings`
  277. -- -----------------------------------------------------
  278. DROP VIEW IF EXISTS `DietDB`.`MealsView_Servings` ;
  279. DROP TABLE IF EXISTS `DietDB`.`MealsView_Servings`;
  280. USE `DietDB`;
  281. CREATE  OR REPLACE VIEW `MealsView_Servings` AS
  282.     SELECT
  283.         m.id AS meal_id,
  284.         SUM(kcal * amount) AS kcal,
  285.         SUM(carbohydrate * amount) AS carbohydrate,
  286.         SUM(fat * amount) AS fat,
  287.         SUM(protein * amount) AS protein
  288.     FROM
  289.         Meals m
  290.             JOIN
  291.         Meals_has_Servings h ON h.meal_id = m.id
  292.             JOIN
  293.         ServingsView v ON h.serving_id = v.serving_id
  294.             AND h.foodItem_id = v.foodItem_id
  295.     GROUP BY m.id;
  296.  
  297. -- -----------------------------------------------------
  298. -- View `DietDB`.`MealsView_FoodItems`
  299. -- -----------------------------------------------------
  300. DROP VIEW IF EXISTS `DietDB`.`MealsView_FoodItems` ;
  301. DROP TABLE IF EXISTS `DietDB`.`MealsView_FoodItems`;
  302. USE `DietDB`;
  303. CREATE  OR REPLACE VIEW `MealsView_FoodItems` AS
  304.     SELECT
  305.         m.id AS meal_id,
  306.         SUM((kcal/100)*amount) AS kcal,
  307.         SUM((carbohydrate/100)*amount) AS carbohydrate,
  308.         SUM((fat/100)*amount) AS fat,
  309.         SUM((protein/100)*amount) AS protein
  310.     FROM
  311.         Meals m
  312.             JOIN
  313.         Meals_has_FoodItems h ON h.meal_id = m.id
  314.             JOIN
  315.         FoodItems i ON h.foodItem_id = i.id
  316.     GROUP BY m.id;
  317.  
  318. -- -----------------------------------------------------
  319. -- View `DietDB`.`MealsView_Sets`
  320. -- -----------------------------------------------------
  321. DROP VIEW IF EXISTS `DietDB`.`MealsView_Sets` ;
  322. DROP TABLE IF EXISTS `DietDB`.`MealsView_Sets`;
  323. USE `DietDB`;
  324. CREATE  OR REPLACE VIEW `MealsView_Sets` AS
  325.     SELECT
  326.         m.id AS meal_id,
  327.         SUM(kcal * amount) AS kcal,
  328.         SUM(carbohydrate * amount) AS carbohydrate,
  329.         SUM(fat * amount) AS fat,
  330.         SUM(protein * amount) AS protein
  331.     FROM
  332.         Meals m
  333.             JOIN
  334.         Meals_has_Sets h ON h.meal_id = m.id
  335.             JOIN
  336.         SetsView v ON h.set_id = v.set_id
  337.     GROUP BY m.id;
  338.  
  339. -- -----------------------------------------------------
  340. -- View `DietDB`.`MealsView`
  341. -- -----------------------------------------------------
  342. DROP VIEW IF EXISTS `DietDB`.`MealsView` ;
  343. DROP TABLE IF EXISTS `DietDB`.`MealsView`;
  344. USE `DietDB`;
  345. CREATE  OR REPLACE VIEW `MealsView` AS
  346.     SELECT
  347.         m.id AS meal_id,
  348.         m.`date`,
  349.         m.`time`,
  350.         ifnull(a.kcal, 0) + ifnull(b.kcal, 0) + ifnull(c.kcal, 0) AS kcal,
  351.         ifnull(a.carbohydrate, 0) + ifnull(b.carbohydrate, 0) + ifnull(c.carbohydrate, 0) AS carbohydrate,
  352.         ifnull(a.fat, 0) + ifnull(b.fat, 0) + ifnull(c.fat, 0) AS fat,
  353.         ifnull(a.protein, 0) + ifnull(b.protein, 0) + ifnull(c.protein, 0) AS protein
  354.     FROM
  355.         Meals m
  356.             LEFT JOIN
  357.         MealsView_FoodItems a ON a.meal_id = m.id
  358.             LEFT JOIN
  359.         MealsView_Sets b ON b.meal_id = m.id
  360.             LEFT JOIN
  361.         MealsView_Servings c ON c.meal_id = m.id
  362.     GROUP BY m.id;
  363.  
  364. -- -----------------------------------------------------
  365. -- View `DietDB`.`Days`
  366. -- -----------------------------------------------------
  367. DROP VIEW IF EXISTS `DietDB`.`Days` ;
  368. DROP TABLE IF EXISTS `DietDB`.`Days`;
  369. USE `DietDB`;
  370. CREATE  OR REPLACE VIEW `Days` AS
  371.     SELECT
  372.         m.`date`,
  373.         SUM(kcal) AS kcal,
  374.         SUM(carbohydrate) AS carbohydrate,
  375.         SUM(fat) AS fat,
  376.         SUM(protein) AS protein
  377.     FROM
  378.         Meals m
  379.             JOIN
  380.         MealsView v ON v.meal_id = m.id
  381.     GROUP BY m.`date`;
  382.  
  383. SET SQL_MODE=@OLD_SQL_MODE;
  384. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  385. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  386.  
  387. -- -----------------------------------------------------
  388. -- Data for table `DietDB`.`FoodItems`
  389. -- -----------------------------------------------------
  390. START TRANSACTION;
  391. USE `DietDB`;
  392. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (1, 'Jajka', 0, 143, 1, 10, 13);
  393. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (3, 'Chleb, jasny', 0, 266, 48, 4, 11);
  394. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (4, 'Carnivor, proszek', 0, 357.1429, 21.9780, 0, 63.1868);
  395. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (5, 'Alpro, sojowe, nie słodzone', 1, 32, 0.2, 1.8, 3.3);
  396. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (6, 'Chleb, Karoliny', 0, 213, 51.2, 1.7, 5.6);
  397. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (7, 'Pomidory, cherry', 0, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
  398. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (8, 'Marchewki, mini', 0, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
  399. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (9, 'Oliwki, zielone', 0, DEFAULT, DEFAULT, DEFAULT, DEFAULT);
  400. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (10, 'Parówki, Słowianki', 0, 197, 0.5, 15, 15);
  401. INSERT INTO `DietDB`.`FoodItems` (`id`, `name`, `fluid`, `kcal`, `carbohydrate`, `fat`, `protein`) VALUES (11, 'Kurczak, udo, pieczony', 0, 211, 0, 12, 24);
  402.  
  403. COMMIT;
  404.  
  405.  
  406. -- -----------------------------------------------------
  407. -- Data for table `DietDB`.`Servings`
  408. -- -----------------------------------------------------
  409. START TRANSACTION;
  410. USE `DietDB`;
  411. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (2, 1, 'M', 51);
  412. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (1, 1, 'S', 38);
  413. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (3, 1, 'L', 56);
  414. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (4, 1, 'XL', 65);
  415. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (6, 4, 'Miarka', 36.4);
  416. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (8, 6, 'Kromka', DEFAULT);
  417. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (9, 7, 'Kubełek z Lidla', DEFAULT);
  418. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (10, 8, 'Woreczek z Lidla', DEFAULT);
  419. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (11, 9, 'Woreczek z Lidla', DEFAULT);
  420. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (12, 3, 'Kromka', 25);
  421. INSERT INTO `DietDB`.`Servings` (`id`, `foodItem_id`, `name`, `units`) VALUES (13, 10, 'Sztuka', 34);
  422.  
  423. COMMIT;
  424.  
  425.  
  426. -- -----------------------------------------------------
  427. -- Data for table `DietDB`.`Sets`
  428. -- -----------------------------------------------------
  429. START TRANSACTION;
  430. USE `DietDB`;
  431. INSERT INTO `DietDB`.`Sets` (`id`, `name`) VALUES (1, 'Carnivoir shake');
  432. INSERT INTO `DietDB`.`Sets` (`id`, `name`) VALUES (2, 'test');
  433.  
  434. COMMIT;
  435.  
  436.  
  437. -- -----------------------------------------------------
  438. -- Data for table `DietDB`.`Set_has_FoodItems`
  439. -- -----------------------------------------------------
  440. START TRANSACTION;
  441. USE `DietDB`;
  442. INSERT INTO `DietDB`.`Set_has_FoodItems` (`set_id`, `foodItem_id`, `units`) VALUES (1, 4, 36.4);
  443. INSERT INTO `DietDB`.`Set_has_FoodItems` (`set_id`, `foodItem_id`, `units`) VALUES (1, 5, 500);
  444. INSERT INTO `DietDB`.`Set_has_FoodItems` (`set_id`, `foodItem_id`, `units`) VALUES (2, 1, 25);
  445. INSERT INTO `DietDB`.`Set_has_FoodItems` (`set_id`, `foodItem_id`, `units`) VALUES (2, 3, 36);
  446.  
  447. COMMIT;
  448.  
  449.  
  450. -- -----------------------------------------------------
  451. -- Data for table `DietDB`.`Meals`
  452. -- -----------------------------------------------------
  453. START TRANSACTION;
  454. USE `DietDB`;
  455. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (1, '2016-06-01', '8:00');
  456. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (2, '2016-06-01', '13:00');
  457. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (3, '2016-06-01', '14:00');
  458. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (4, '2016-06-01', '15:00');
  459. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (5, '2016-06-01', '17:00');
  460. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (6, '2016-06-01', '22:00');
  461. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (7, '2016-06-02', '8:00');
  462. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (8, '2016-06-02', '14:00');
  463. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (9, '2016-06-02', '17:00');
  464. INSERT INTO `DietDB`.`Meals` (`id`, `date`, `time`) VALUES (10, '2016-06-02', '22:30');
  465.  
  466. COMMIT;
  467.  
  468.  
  469. -- -----------------------------------------------------
  470. -- Data for table `DietDB`.`Meals_has_Sets`
  471. -- -----------------------------------------------------
  472. START TRANSACTION;
  473. USE `DietDB`;
  474. INSERT INTO `DietDB`.`Meals_has_Sets` (`meal_id`, `set_id`, `amount`) VALUES (1, 1, 1);
  475. INSERT INTO `DietDB`.`Meals_has_Sets` (`meal_id`, `set_id`, `amount`) VALUES (6, 1, 1);
  476. INSERT INTO `DietDB`.`Meals_has_Sets` (`meal_id`, `set_id`, `amount`) VALUES (7, 1, 1);
  477. INSERT INTO `DietDB`.`Meals_has_Sets` (`meal_id`, `set_id`, `amount`) VALUES (10, 1, 1);
  478.  
  479. COMMIT;
  480.  
  481.  
  482. -- -----------------------------------------------------
  483. -- Data for table `DietDB`.`Meals_has_FoodItems`
  484. -- -----------------------------------------------------
  485. START TRANSACTION;
  486. USE `DietDB`;
  487. INSERT INTO `DietDB`.`Meals_has_FoodItems` (`meal_id`, `foodItem_id`, `amount`) VALUES (8, 11, 175);
  488.  
  489. COMMIT;
  490.  
  491.  
  492. -- -----------------------------------------------------
  493. -- Data for table `DietDB`.`Meals_has_Servings`
  494. -- -----------------------------------------------------
  495. START TRANSACTION;
  496. USE `DietDB`;
  497. INSERT INTO `DietDB`.`Meals_has_Servings` (`meal_id`, `serving_id`, `foodItem_id`, `amount`) VALUES (2, 9, 7, 1);
  498. INSERT INTO `DietDB`.`Meals_has_Servings` (`meal_id`, `serving_id`, `foodItem_id`, `amount`) VALUES (3, 10, 8, 1);
  499. INSERT INTO `DietDB`.`Meals_has_Servings` (`meal_id`, `serving_id`, `foodItem_id`, `amount`) VALUES (4, 11, 9, 1);
  500. INSERT INTO `DietDB`.`Meals_has_Servings` (`meal_id`, `serving_id`, `foodItem_id`, `amount`) VALUES (4, 12, 3, 1);
  501. INSERT INTO `DietDB`.`Meals_has_Servings` (`meal_id`, `serving_id`, `foodItem_id`, `amount`) VALUES (5, 2, 1, 5);
  502. INSERT INTO `DietDB`.`Meals_has_Servings` (`meal_id`, `serving_id`, `foodItem_id`, `amount`) VALUES (9, 8, 6, 4);
  503. INSERT INTO `DietDB`.`Meals_has_Servings` (`meal_id`, `serving_id`, `foodItem_id`, `amount`) VALUES (9, 13, 10, 5);
  504.  
  505. COMMIT;
Add Comment
Please, Sign In to add comment