-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_design.sql
More file actions
43 lines (38 loc) · 1.18 KB
/
database_design.sql
File metadata and controls
43 lines (38 loc) · 1.18 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
CREATE TABLE Users (
UserID INT PRIMARY KEY AUTO_INCREMENT,
Username VARCHAR(50) NOT NULL,
PasswordHash VARCHAR(255) NOT NULL,
Role ENUM('Patient', 'Doctor') NOT NULL,
Email VARCHAR(100) UNIQUE NOT NULL,
CreatedDate DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE Patients (
PatientID INT PRIMARY KEY AUTO_INCREMENT,
UserID INT,
HealthData TEXT,
InsuranceID INT,
FOREIGN KEY (UserID) REFERENCES Users(UserID),
FOREIGN KEY (InsuranceID) REFERENCES Insurance(InsuranceID)
);
CREATE TABLE Doctors (
DoctorID INT PRIMARY KEY AUTO_INCREMENT,
UserID INT,
Specialization VARCHAR(100),
FOREIGN KEY (UserID) REFERENCES Users(UserID)
);
CREATE TABLE Insurance (
InsuranceID INT PRIMARY KEY AUTO_INCREMENT,
PolicyNumber VARCHAR(50) UNIQUE,
Provider VARCHAR(100),
CoverageDetails TEXT
);
CREATE TABLE Appointments (
AppointmentID INT PRIMARY KEY AUTO_INCREMENT,
PatientID INT,
DoctorID INT,
AppointmentDate DATETIME,
Status ENUM('Scheduled', 'Completed', 'Cancelled'),
FOREIGN KEY (PatientID) REFERENCES Patients(PatientID),
FOREIGN KEY (DoctorID) REFERENCES Doctors(DoctorID)
);
-- Using MySQL as the DBMS