-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotesDB.sql
More file actions
32 lines (29 loc) · 1.22 KB
/
notesDB.sql
File metadata and controls
32 lines (29 loc) · 1.22 KB
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
create database if not exists notesDB;
use notesDB;
CREATE TABLE `users` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`gender` varchar(45) NOT NULL,
`birthdate` date NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email_UNIQUE` (`email`)
)
CREATE TABLE `notes` (
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`body` varchar(255) NOT NULL,
`user_id` int NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_notes_1_idx` (`user_id`),
CONSTRAINT `fk_notes_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
)
CREATE TABLE `contacts` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`email` varchar(255) NOT NULL,
`message` varchar(1000) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
)