Question: Need help wth screenshots for the Running queries below: For this lab you will be using SQL SELECT statements to query your database tables. You

Need help wth screenshots for the Running queries 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:
1. List all Patients and what Bed they are assigned to (Join two tables patient and bed).
2. List all patients who had Treatments and what Treatment they received (Join three tables Patient, Treatment, and Patient-Treatment)
3. List all patients who had tests and what Test they had (Join three tables Patient, Test, and Patient-Test).
4. List the employees (doctors, nurses, etc.) who assisted each patient (Join three tables: Patient, Personnel, and Patient-Personnel).
5. List all patients in alphabetical order
6. List all patients who live in Atlanta and had a test completed (Join three tables Patient, Patient-Test, test).
7. List all patients who live in either Woodstock or Roswell who had a treatment completed (Join three tables Patient, Patient-Treatment, 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(50),
LastName VARCHAR(50)
);
-- 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(50),
LastName VARCHAR(50),
Position VARCHAR(50)
);
-- Create the DEPARTMENT table
CREATE TABLE DEPARTMENT (
DepartmentID INT PRIMARY KEY,
DepartmentName VARCHAR(50)
);
-- Create the TREATMENT table
CREATE TABLE TREATMENT (
TreatmentID INT PRIMARY KEY,
TreatmentName VARCHAR(50),
Cost DECIMAL(10,2)
);
-- Create the TEST table
CREATE TABLE TEST (
TestID INT PRIMARY KEY,
TestName VARCHAR(50),
Result VARCHAR(100)
);
-- Create the ASSOCIATIVE ENTITY tables
CREATE TABLE Patient_Test (
PatientID INT,
TestID INT,
TestDate DATE,
PRIMARY KEY (PatientID, TestID),
FOREIGN KEY (PatientID) REFERENCES PATIENT(PatientID),
FOREIGN KEY (TestID) REFERENCES TEST(TestID)
);
CREATE TABLE Patient_Treatment (
PatientID INT,
TreatmentID INT,
TreatmentDate DATE,
PRIMARY KEY (PatientID, TreatmentID),
FOREIGN KEY (PatientID) REFERENCES PATIENT(PatientID),
FOREIGN KEY (TreatmentID) REFERENCES TREATMENT(TreatmentID)
);
CREATE TABLE Patient_Personnel (
PatientID INT,
PersonnelID INT,
AssignedDate DATE,
PRIMARY KEY (PatientID, PersonnelID),
FOREIGN KEY (PatientID) REFERENCES PATIENT(PatientID),
FOREIGN KEY (PersonnelID) REFERENCES PERSONNEL(PersonnelID)
);
-- Insert data into the PATIENT table
INSERT INTO PATIENT (PatientID, FirstName, LastName)
VALUES
(1, 'John', 'Doe'),
(2, 'Jane', 'Smith'),
(3, 'Michael', 'Johnson');
-- Insert data into the BED table
INSERT INTO BED (BedID, BedNumber, RoomNumber)
VALUES
(1,101,1),
(2,102,1),
(3,201,2);
-- Insert data into the PERSONNEL table
INSERT INTO PERSONNEL (PersonnelID, FirstName, LastName, Position)
VALUES
(1, 'Emily', 'Smith', 'Nurse'),
(2, 'David', 'Johnson', 'Doctor'),
(3, 'Jennifer', 'Williams', 'Technician');
-- Insert data into the DEPARTMENT table
INSERT INTO DEPARTMENT (DepartmentID, DepartmentName)
VALUES
(1, 'Cardiology'),
(2, 'Neurology'),
(3, 'Orthopedics');
-- Insert data into the TREATMENT table
INSERT INTO TREATMENT (TreatmentID, TreatmentName, Cost)
VALUES
(1, 'Physical Therapy', 150.00),
(2, 'Medication', 50.00),
(3, 'Surgery', 5000.00);
-- Insert data into the TEST table
INSERT INTO TEST (TestID, TestName, Result)
VALUES
(1, 'Blood Test', 'Normal'),
(2, 'MRI Scan', 'No abnormalities detected'),
(3,'X-ray', 'Fracture detected');
-- Insert data into the Patient_Test table
INSERT INTO Patient_Test (PatientID, TestID, TestDate)
VALUES
(1,1,'2024-03-25'),
(2,2,'2024-03-26'),
(3,3,'2024-03-27');
-- Insert data into the Patient_Treatment table
INSERT INTO Patient_Treatment (PatientID, TreatmentID, TreatmentDate)
VALUES
(1,1,'2024-03-25'),
(2,2,'2024-03-26'),
(3,3,'2024-03-27');
-- Insert data into the Patient_Personnel table
INSERT INTO Patient_Personnel (PatientID, PersonnelID, AssignedDate)
VALUES
(1,1,'2024-03-25'),
(2,2,'2024-03-26'),
(3,3,'2024-03-27');

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!