-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_meals_app.sql
42 lines (32 loc) · 1.36 KB
/
db_meals_app.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
drop DATABASE IF EXISTS db_meals_app;
CREATE DATABASE IF NOT EXISTS db_meals_app;
USE db_meals_app;
CREATE TABLE `meals`(
`id` int (10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar (255) NOT NULL,
`description` text NULL DEFAULT NULL,
`location` varchar (255) NOT NULL,
`max_reservation` int (10) unsigned NOT NULL,
`price` decimal,
`created_date` DATE NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `reservations`(
`id` int (10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar (255) NOT NULL,
`phonenumber` varchar (255) NOT NULL,
`email` varchar (255) NOT NULL,
`meal_id` int (10) unsigned NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `fk_reservation_meal` FOREIGN KEY (`meal_id`) REFERENCES `meals`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `reviews`(
`id` int (10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar (255) NOT NULL,
`description` text NULL DEFAULT NULL,
`stars` int (10) unsigned NOT NULL,
`meal_id` int (10) unsigned NOT NULL,
`created_date` DATE NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `fk_review_meal` FOREIGN KEY (`meal_id`) REFERENCES `meals` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;