-
Notifications
You must be signed in to change notification settings - Fork 2
/
database-schema.sql
50 lines (44 loc) · 1.43 KB
/
database-schema.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
43
44
45
46
47
48
49
50
use java4web;
DROP TABLE IF EXISTS appointments, doctors, specialities, citizens, users;
CREATE TABLE `users` (
`id` bigint(10) unsigned NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`user_type` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `citizens` (
`id` bigint(10) unsigned NOT NULL,
`ssn` varchar(11) NOT NULL,
`mobile_number` varchar(255) NOT NULL,
`user_id` bigint(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
);
CREATE TABLE `specialities` (
`id` bigint(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `doctors` (
`id` bigint(10) unsigned NOT NULL,
`speciality_id` bigint(10) unsigned NOT NULL,
`user_id` bigint(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`speciality_id`) REFERENCES `specialities` (`id`),
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
);
CREATE TABLE `appointments` (
`id` bigint(10) unsigned NOT NULL,
`date` date DEFAULT NULL,
`citizen_id` bigint(10) unsigned NOT NULL REFERENCES `citizen` (`id`),
`doctor_id` bigint(10) unsigned NOT NULL REFERENCES `doctor` (`id`),
`description` varchar(255),
`notes` varchar(255),
PRIMARY KEY (`id`),
FOREIGN KEY (`citizen_id`) REFERENCES `citizens` (`id`),
FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`)
);