Question: Need help with the following below: For this lab you will be using SQL SELECT statements to query your database tables. You will be turning
Need help with the following below:
For this lab you will be using SQL SELECT statements to query your database tables. You will be turning in the results of the following queries:
List all Patients and what Bed they are assigned to Join two tables patient and bed
List all patients who had Treatments and what Treatment they received Join three tables Patient, Treatment, and PatientTreatment
List all patients who had tests and what Test they had Join three tables Patient, Test, and PatientTest
List the employees doctors nurses, etc. who assisted each patient Join three tables: Patient, Personnel, and PatientPersonnel
List all patients in alphabetical order
List all patients who live in Atlanta and had a test completed Join three tables Patient, PatientTest, test
List all patients who live in either Woodstock or Roswell who had a treatment completed Join three tables Patient, PatientTreatment, treatment
If you don't have data in your created tables that will allow you to create these queries add appropriate data to your tables before doing the queries.
Please submit two files, one contains your queries and other one contains all screen shots of running queries. Work submitted in more than two files will not be evaluated.
Previous code:
Create the PATIENT table
CREATE TABLE PATIENT
PatientID INT PRIMARY KEY,
FirstName VARCHAR
LastName VARCHAR
;
Create the BED table
CREATE TABLE BED
BedID INT PRIMARY KEY,
BedNumber INT,
RoomNumber INT
;
Create the PERSONNEL table
CREATE TABLE PERSONNEL
PersonnelID INT PRIMARY KEY,
FirstName VARCHAR
LastName VARCHAR
Position VARCHAR
;
Create the DEPARTMENT table
CREATE TABLE DEPARTMENT
DepartmentID INT PRIMARY KEY,
DepartmentName VARCHAR
;
Create the TREATMENT table
CREATE TABLE TREATMENT
TreatmentID INT PRIMARY KEY,
TreatmentName VARCHAR
Cost DECIMAL
;
Create the TEST table
CREATE TABLE TEST
TestID INT PRIMARY KEY,
TestName VARCHAR
Result VARCHAR
;
Create the ASSOCIATIVE ENTITY tables
CREATE TABLE PatientTest
PatientID INT,
TestID INT,
TestDate DATE,
PRIMARY KEY PatientID TestID
FOREIGN KEY PatientID REFERENCES PATIENTPatientID
FOREIGN KEY TestID REFERENCES TESTTestID
;
CREATE TABLE PatientTreatment
PatientID INT,
TreatmentID INT,
TreatmentDate DATE,
PRIMARY KEY PatientID TreatmentID
FOREIGN KEY PatientID REFERENCES PATIENTPatientID
FOREIGN KEY TreatmentID REFERENCES TREATMENTTreatmentID
;
CREATE TABLE PatientPersonnel
PatientID INT,
PersonnelID INT,
AssignedDate DATE,
PRIMARY KEY PatientID PersonnelID
FOREIGN KEY PatientID REFERENCES PATIENTPatientID
FOREIGN KEY PersonnelID REFERENCES PERSONNELPersonnelID
;
Insert data into the PATIENT table
INSERT INTO PATIENT PatientID FirstName, LastName
VALUES
'John', 'Doe'
'Jane', 'Smith'
'Michael', 'Johnson';
Insert data into the BED table
INSERT INTO BED BedID BedNumber, RoomNumber
VALUES
;
Insert data into the PERSONNEL table
INSERT INTO PERSONNEL PersonnelID FirstName, LastName, Position
VALUES
'Emily', 'Smith', 'Nurse'
'David', 'Johnson', 'Doctor'
'Jennifer', 'Williams', 'Technician';
Insert data into the DEPARTMENT table
INSERT INTO DEPARTMENT DepartmentID DepartmentName
VALUES
'Cardiology'
'Neurology'
'Orthopedics';
Insert data into the TREATMENT table
INSERT INTO TREATMENT TreatmentID TreatmentName, Cost
VALUES
'Physical Therapy',
'Medication',
'Surgery', ;
Insert data into the TEST table
INSERT INTO TEST TestID TestName, Result
VALUES
'Blood Test', 'Normal'
'MRI Scan', No abnormalities detected'
Xray', 'Fracture detected';
Insert data into the PatientTest table
INSERT INTO PatientTest PatientID TestID, TestDate
VALUES
;
Insert data into the PatientTreatment table
INSERT INTO PatientTreatment PatientID TreatmentID, TreatmentDate
VALUES
;
Insert data into the PatientPersonnel table
INSERT INTO PatientPersonnel PatientID PersonnelID, AssignedDate
VALUES
;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
