-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdatabase creation.txt
155 lines (116 loc) · 3.48 KB
/
database creation.txt
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# email_id and P_id has been added to auth_patient table
# email_id and doctor_id has been added to auth_doctor table
create database project;
use project;
create table Patient (
P_id int primary key AUTO_INCREMENT ,
first_name varchar(50) ,
last_name varchar(50) ,
address varchar(50) ,
gender varchar(10) ,
phone int
);
alter table Patient add column email varchar(50);
create table Doctor (
doctor_id int primary key AUTO_INCREMENT ,
first_name varchar(50) ,
last_name varchar(50) ,
rating numeric(2,1)
);
create table Patient_Doctor (
pat_doc_id int primary key AUTO_INCREMENT ,
doctor_id int ,
P_id int ,
foreign key(P_id) references Patient(P_id) ,
foreign key(doctor_id) references Doctor(doctor_id)
);
create table Patient_department(
pd_id int primary key AUTO_INCREMENT ,
dept_name varchar(50),
P_id int ,
foreign key(P_id) references Patient(P_id)
);
create table Auth_patient(
auth_id int primary key AUTO_INCREMENT,
email varchar(50),
password varchar(50) ,
P_id int ,
foreign key(P_id) references Patient(P_id)
);
create table Med_Bills(
bill_id int primary key AUTO_INCREMENT,
P_id int ,
amount float ,
foreign key(P_id) references Patient(P_id)
);
create table Auth_doctor(
auth_id int primary key AUTO_INCREMENT,
email varchar(50),
password varchar(50),
doctor_id int ,
foreign key(doctor_id) references Doctor(doctor_id)
);
create table Bill_details(
bill_det_id int primary key AUTO_INCREMENT,
bill_id int ,
type varchar(50) ,
reason varchar(50) ,
foreign key(bill_id) references Med_Bills(bill_id)
);
create table slots(
slot_id int primary key AUTO_INCREMENT,
time_start time,
time_end time
);
# D_id taken as doctor_id
create table Appointments(
appoint_id int primary key AUTO_INCREMENT ,
P_id int ,
doctor_id int ,
slot_id int ,
Time time ,
foreign key(P_id) references Patient(P_id) ,
foreign key(doctor_id) references Doctor(doctor_id) ,
foreign key(slot_id) references slots(slot_id)
);
create table unavailable(
unav_id int primary key AUTO_INCREMENT,
doctor_id int ,
slot_id int ,
day varchar(50),
foreign key(doctor_id) references Doctor(doctor_id) ,
foreign key(slot_id) references slots(slot_id)
);
create table available(
av_id int primary key AUTO_INCREMENT,
doctor_id int ,
slot_id int ,
day varchar(50),
foreign key(doctor_id) references Doctor(doctor_id) ,
foreign key(slot_id) references slots(slot_id)
);
create table Doctor_department(
dp_id int primary key AUTO_INCREMENT,
doctor_id int ,
dept_name varchar(50) ,
foreign key(doctor_id) references Doctor(doctor_id)
);
create table Prescription(
pres_id int primary key AUTO_INCREMENT ,
P_id int ,
Doctor_id int ,
bill_id int , #Med_Bills changed to bill_id
amount int ,
time time ,
Symptoms text ,
Diagnosis text ,
foreign key(doctor_id) references Doctor(doctor_id) ,
foreign key(P_id) references Patient(P_id) ,
foreign key(bill_id) references Med_Bills(bill_id)
);
create table Reviews(
review_id int primary key AUTO_INCREMENT,
doctor_id int ,
text text ,
foreign key(doctor_id) references Doctor(doctor_id)
);