0% found this document useful (0 votes)
3 views3 pages

SQL Hospital Database

The document creates a database called HOSPITAL and within it creates several tables (Patient, Consultation, Employee, Area, Invoice) with their respective fields. It then inserts example data into each of the created tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

SQL Hospital Database

The document creates a database called HOSPITAL and within it creates several tables (Patient, Consultation, Employee, Area, Invoice) with their respective fields. It then inserts example data into each of the created tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Create database HOSPITAL

USE HOSPITAL

Create table Patient(


PATIENT_DPI int,
Name varchar(50)
Last name varchar(50)
Address n varchar(50),
Entry_Date
PRIMARY KEY (PATIENT_DPI)
);

Create table Consulta(


int
PATIENT_DPI int,
EMPLOYEE_ID int,
ID_AREA varchar(50)
Consultation date
Condition varchar(50)
Status_Query
PRIMARY KEY (ID_CONSULTA)
);

Create table Employee(


Employee_ID int
Name varchar(50),
Last name varchar(50),
Position varchar(50)
ID_AREA varchar(50)
Tel internal phone,
Floating salary,
int
PRIMARY KEY (Employee_ID)
);

Create table Area(


ID_AREA int,
Name varchar(50)
PRIMARY KEY (ID_AREA)
);

Create table Invoice(


int
int
Name varchar(50)
Direction n varchar(50),
Date date,
Telephone no int,
Nit int,
Total float
PRIMARY KEY (INVOICE_ID)
);

select * from Patient


select * from Consulta
select * from Employee
select * from Area
select * from Invoice
--INSERT DATA INTO THE PATIENT TABLE--
INSERT INTO Patient(DPI_PATIENT, Name, LastName, Address n,
Entry_Date)Values
896

INSERT INTO Patient(DPI_PATIENT, First Name, Last Name, Address n,


Date_Entry)Values
547
456 Santa Rosa, Guatemala, 2021-03-03
789
9101
0102
0103
6597
7458 Mixco, Guatemala

Insert DATA FROM THE CONSULTATION TABLE

INSERT INTO Consultation(ID_CONSULTATION, PATIENT_DPI, EMPLOYEE_ID, AREA_ID,


Consultation_Date
01

INSERT INTO Consultation(ID_CONSULTATION, PATIENT_ID, EMPLOYEE_ID, AREA_ID ,


Consultation_Date
03
04
05
06 n','PENDING')
('07','0102','202001','03','2021-03-05','Alteraci in the frequency
card here','PENDING')
('08','0103','202004','02','2021-03-06','S Symptoms of the system
nervous','PENDING)
09
('10','7458','202002','01','2021-04-04','Complication at the drainage level
biliary','PENDING'

--INSERT EMPLOYEE TABLE DATA--


INSERT INTO Employee (Employee_ID, Name, Last_Name, Position, AREA_ID, Phone phone
Salary, ID_SUB) VALUES
202001 Jer Doctor Surgeon
5500

INSERT INTO Employee (Employee_ID, First_Name, Last_Name, Position, AREA_ID, Phone phone
Salary, ID_SUB) VALUES
202003 a.', '03', '98567412'
6000, 01
202004 a and obstetrics or
toxicology a.', '04', '98745123', '7000', '01')
202005
'65847129', '6500', '02'),
202006 a', '03', '85471234',
'6500', '03')
202007 a', '01'
'78456312', '7000', '05'),
202008 a', '02', '96547123',
7000
202009 a.', '03', '87456321', '5500', '06')
2020010 a.', '03', '23568974'
600

--INSERT DATA INTO THE AREA TABLE--


INSERT INTO Area(ID_AREA, Name) VALUES
01
INSERT INTO Area(ID_AREA, Name) VALUES
NICOS')
('05','RADIODIAGN STICO')
SURGERY A ORTOP DICA AND TRAUMATOLOGY A'),
07 CARDIOLOGIST A'),
('08',' ANESTHESIOLOGIST A')
('09', GYNECOLOGIST A AND OBSTETRICS')
10 DIGESTIVE)

--INSERT DATA INTO THE INVOICES TABLE--


INSERT INTO Invoice(ID_INVOICE, ID_CONSULTATION, Name, Address n no,
Nit,Total) VALUES
20200001
02','59846532','89654712','8000
INSERT INTO Invoice(ID_INVOICE, ID_CONSULTATION, Name, Address n no,
Nit,Total) VALUES
20200002
05','87459654','65874562','1500')
20200003
02','87457457','23568741','2000')
20200004
03','89745231','65478941','2500')
20200005
02','87456321','74521423','6000')
20200006
04','5645745','35214245','500'),
20200007
07','74562318','32547891','600'),
20200008
04','6574585','25478941','8002'),
20200009
04','85452145','65748541','6500')

select Employee.ID_EMPLOYEE, Employee.Name, Area.ID_AREA


from Employee
inner join Area on Employee.ID_EMPLOYEE = Area.ID_AREA

You might also like