-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppointmentBookingTable.sql
More file actions
93 lines (80 loc) · 2.42 KB
/
AppointmentBookingTable.sql
File metadata and controls
93 lines (80 loc) · 2.42 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
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
create database `appointmentbookingdoctor`;
use appointmentbookingdoctor;
create table `roles`(
roleId INT AUTO_INCREMENT,
nameRole varchar(50),
primary key(roleId)
);
create table `patients`(
patientId int not null key AUTO_INCREMENT,
firstName varchar(50),
lastName varchar(50),
email varchar(50),
phone varchar(10),
gender bit,
password varchar(50),
roleId int,
FOREIGN KEY (roleId) REFERENCES roles (roleId) ON DELETE CASCADE on update cascade
);
create table `specialities`(
specialityId int not null key AUTO_INCREMENT,
speciallityName varchar(50)
);
create table `doctors`(
doctorId int not null key AUTO_INCREMENT,
firstName varchar(50),
lastName varchar(50),
phone varchar(10),
DOB date,
gender bit,
address varchar(50),
password varchar(50),
specialityId int,
foreign key (specialityId) references specialities (specialityId)
ON DELETE CASCADE on update cascade,
roleId int,
FOREIGN KEY (roleId) REFERENCES roles(roleId) ON DELETE CASCADE on update cascade
);
create table `scheduleTimings`(
scheduleTimingId int key not null AUTO_INCREMENT,
bookDate date,
atBegin Time,
atEnd Time,
doctorId int,
status bit ,
foreign key (doctorId) references doctors(doctorId) ON DELETE CASCADE on update cascade
);
create table appointments(
appointmentId int key not null AUTO_INCREMENT,
scheduleTimingId int,
patientId int,
foreign key (scheduleTimingId) references scheduleTimings(scheduleTimingId)
ON DELETE CASCADE on update cascade,
foreign key (patientId) references patients(patientId)
ON DELETE CASCADE on update cascade
);
create table `admins`(
adminId int not null key AUTO_INCREMENT,
userName varchar(50),
password varchar(50),
roleId int,
FOREIGN KEY (roleId) REFERENCES roles(roleId) ON DELETE CASCADE on update cascade
);
alter table admins
modify password varchar(100);
SHOW TABLEs;
select * from patients;
call SHOW_ALL_BY_TABLE_NAME('doctors');
SHOW FULL TABLES IN appointmentbookingdoctor WHERE TABLE_TYPE LIKE 'VIEW';
create view adminsView
as
select adminId,userName, password, nameRole from admins a
inner join roles r on r.roleId = a.roleId;
select * from admins;
call Add_Scheduletiming_Proc('2021-09-03','09:30:00','10:00:00',1);
select * from scheduleTimings;
select * from doctors;
select checkExistTiming('2021-09-03','08:30','9:29',1);
call Add_Scheduletiming_Proc('2021-09-03','08:30','9:29',49);
call Update_Scheduletimings_Proc(51,'2021-11-15','18:00','19:30');
update scheduleTimings set status =1 where scheduleTimingId =48