Repository navigation
Expand file tree
/
Copy pathTable Creation.sql
More file actions
107 lines (96 loc) · 3.23 KB
/
Copy pathTable Creation.sql
File metadata and controls
107 lines (96 loc) · 3.23 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
create database emr;
use emr;
#create statement for insurance information table
CREATE TABLE InsuranceInfo (
insurance_id INT PRIMARY KEY,
insurance_name VARCHAR(30) NOT NULL,
insurance_policy VARCHAR(40) NOT NULL,
coverage_amount INT
);
#create statement for patients information table
CREATE TABLE PatientsInfo (
patient_id INT PRIMARY KEY AUTO_INCREMENT,
First_Name VARCHAR(60) NOT NULL,
Last_Name VARCHAR(60) NOT NULL,
Address VARCHAR(100) NOT NULL,
Phone_number VARCHAR(40) NOT NULL,
insurance_id INT,
email varchar(40) NOT NULL,
password varchar(40) NOT NULL,
FOREIGN KEY (insurance_id) REFERENCES InsuranceInfo(insurance_id)
);
#create statement for dentist information table
CREATE TABLE DentistInfo (
Dentist_id INT PRIMARY KEY AUTO_INCREMENT,
Dentist_name VARCHAR(50) NOT NULL,
Qualification VARCHAR(40) NOT NULL,
Phone_number VARCHAR(20) NOT NULL,
Email VARCHAR(100) NOT NULL,
Password varchar(40) NOT NULL
);
#create statement for appointment information table
CREATE TABLE AppointmentInfo (
appointment_id INT PRIMARY KEY AUTO_INCREMENT,
Patient_id INT NOT NULL,
Dentist_id INT NOT NULL,
appointment_date DATE NOT NULL,
appointment_time TIME NOT NULL,
FOREIGN KEY (Patient_id) REFERENCES PatientsInfo(patient_id),
FOREIGN KEY (Dentist_id) REFERENCES DentistInfo(Dentist_id)
);
#create statement for procedures information table
CREATE TABLE ProceduresInfo (
Procedure_id INT PRIMARY KEY AUTO_INCREMENT,
Name_of_the_procedure VARCHAR(100) NOT NULL,
Cost VARCHAR(20) NOT NULL,
Procedure_details VARCHAR(400) NOT NULL,
time_requires TIME
);
#create statement for billing information table
CREATE TABLE BillingInvoice (
invoice_id INT PRIMARY KEY AUTO_INCREMENT,
patient_id INT NOT NULL,
appointment_id INT NOT NULL,
patient_name VARCHAR(40) NOT NULL,
Treatment_name VARCHAR(100) NOT NULL,
Treatment_Description VARCHAR(100) NOT NULL,
Insurance_payment VARCHAR(20) NOT NULL,
Patient_payment VARCHAR(20) NOT NULL,
Balance_due VARCHAR(20) NOT NULL,
payment_due_date DATE NOT NULL,
FOREIGN KEY (patient_id) REFERENCES PatientsInfo(patient_id),
FOREIGN KEY (appointment_id) REFERENCES AppointmentInfo(appointment_id)
);
#create statement for prescription information table
CREATE TABLE PrescriptionInfo (
Prescription_ID INT PRIMARY KEY AUTO_INCREMENT,
Patient_id INT NOT NULL,
Dentist_id INT NOT NULL,
Date_Prescribed VARCHAR(20) NOT NULL,
Medication_Name VARCHAR(20) NOT NULL,
Dosage VARCHAR(20) NOT NULL,
Start_Date DATE NOT NULL,
End_Date DATE NOT NULL,
FOREIGN KEY (Patient_id) REFERENCES PatientsInfo(patient_id),
FOREIGN KEY (Dentist_id) REFERENCES DentistInfo(Dentist_id)
);
#create statement for medicine information table
CREATE TABLE MedicineInfo (
Medicine_ID INT PRIMARY KEY AUTO_INCREMENT,
Medicine_Name VARCHAR(40) NOT NULL,
Medicine_Company VARCHAR(30) NOT NULL,
Medicine_Dosage VARCHAR(40) NOT NULL,
Patient_id INT,
Dentist_id INT,
FOREIGN KEY (Patient_id) REFERENCES PatientsInfo(patient_id),
FOREIGN KEY (Dentist_id) REFERENCES DentistInfo(Dentist_id)
);
CREATE TABLE Log (
log_id INT PRIMARY KEY AUTO_INCREMENT,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
user varchar(50) NOT NULL,
table_name VARCHAR(30) NOT NULL,
operation_type VARCHAR(30) NOT NULL,
old_value VARCHAR(200),
new_value VARCHAR(200)
);