-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectQuery.sql
77 lines (67 loc) · 2.28 KB
/
ProjectQuery.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
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
CREATE TABLE [ad189641].[Patient] (
[PatId] INT NOT NULL IDENTITY(101, 1),
[PatName] VARCHAR (30) NULL,
[Age] INT NULL,
[Weight] INT NULL,
[Gender] VARCHAR (120) NULL,
[Address] VARCHAR (120) NULL,
[PhoneNumber] Decimal NULL,
[Disease] VARCHAR (120) NULL,
PRIMARY KEY CLUSTERED ([PatId] ASC),
DoctorID int FOREIGN KEY REFERENCES ad189641.Doctor(DoctorID)
);
CREATE TABLE [ad189641].[Doctor] (
DoctorID int NOT NULL IDENTITY(101, 1),
DoctorName varchar,
Dept varchar,
PRIMARY KEY CLUSTERED ([DoctorId] ASC)
);
CREATE TABLE [ad189641].[Lab] (
LabID int NOT NULL IDENTITY(101, 1),
TestDate date,
TestType varchar,
PatientType Varchar,
PRIMARY KEY CLUSTERED ([LabId] ASC),
PatID int FOREIGN KEY REFERENCES ad189641.Patient(PatID),
DoctorID int FOREIGN KEY REFERENCES ad189641.Doctor(DoctorID)
);
alter table ad189641.Lab drop column DoctorName
select * from ad189641.Lab
drop table ad189641.RoomData
create table ad189641.RoomData(
RoomNo int Not Null IDENTITY(101, 1),
TreatmentDate date,
DoctorID int FOREIGN KEY REFERENCES ad189641.Doctor(DoctorID),
LabID int FOREIGN KEY REFERENCES ad189641.Lab(LabID)
PRIMARY KEY CLUSTERED ([RoomNo] ASC),
);
create table ad189641.Outpatient(
PatID int FOREIGN KEY REFERENCES ad189641.Patient(PatID),
TreatmentDate date,
DoctorID int FOREIGN KEY REFERENCES ad189641.Doctor(DoctorID),
LabID int FOREIGN KEY REFERENCES ad189641.Lab(LabID)
PRIMARY KEY CLUSTERED ([PatId] ASC),
);
create table ad189641.Inpatient(
PatID int FOREIGN KEY REFERENCES ad189641.Patient(PatID),
RoomNo int FOREIGN KEY REFERENCES ad189641.RoomData(RoomNo),
DoctorID int FOREIGN KEY REFERENCES ad189641.Doctor(DoctorID),
LabID int FOREIGN KEY REFERENCES ad189641.Lab(LabID),
AdmissionDate date,
DischargeDate date,
AmountPerDay decimal
);
create table ad189641.BillData(
BillNo int NOT NULL IDENTITY(101, 1),
PatID int FOREIGN KEY REFERENCES ad189641.Patient(PatID),
PatientType varchar,
DoctorID int FOREIGN KEY REFERENCES ad189641.Doctor(DoctorID),
DoctorFees bigint,
RoomCharge bigint,
OperationCharges bigint,
MedicineFees bigint,
TotalDays bigint,
LabFees bigint,
Amount bigint,
PRIMARY KEY CLUSTERED ([BillNo] ASC),
);