Database Systems Section W03

User Generated

nablabzbhf2222

Programming

Harvard University

Description

Instructions below.

Unformatted Attachment Preview

Database Systems Section W05 1. List all Patients and what Bed they are assigned to SELECT p.id AS patient_id, p.name AS patient_name, p.address AS patient_address, b.bed_number FROM patient p JOIN bed b ON p.id = b.patient_id; 2. List all patients who had Treatments and what Treatment they received SELECT p.id AS patient_id, p.name AS patient_name, t.treatment_name FROM patient p JOIN treatment_history th ON p.id = th.patient_id JOIN treatment t ON th.treatment_id = t.id; 3. List all patients who had tests and what Test they had SELECT p.id AS patient_id, p.name AS patient_name, t.test_name FROM patient p JOIN test_history th ON p.id = th.patient_id JOIN test t ON th.test_id = t.id; 4. List the employees (doctors, nurses, etc.) who assisted each patient. SELECT p.id AS patient_id, p.name AS patient_name, per.id AS personnel_id, per.name AS personnel_name FROM patient p JOIN appointment a ON p.id = a.patient_id JOIN personnel per ON a.personnel_id = per.id; 5. List all patients in alphabetical order SELECT * FROM patient ORDER BY name; 6. List all patients who live in Atlanta and had a test completed SELECT p.id AS patient_id, p.name AS patient_name, t.test_name FROM patient p JOIN test_history th ON p.id = th.patient_id JOIN test t ON th.test_id = t.id WHERE p.address LIKE '%Atlanta%'; 7. List all patients who live in either Woodstock or Roswell who had a treatment completed. SELECT p.id AS patient_id, p.name AS patient_name, tr.treatment_name FROM patient p JOIN treatment_history th ON p.id = th.patient_id JOIN treatment tr ON th.treatment_id = tr.id WHERE p.address LIKE '%Woodstock%' OR p.address LIKE '%Roswell%'; Option 1 For this project - you will be writing a program (you may choose whatever programming language you want) to read in two of your database tables from Lab 5, and then print out the contents of each of the two tables separately. These MUST be database tables that have already been created and stored as input for your program. You may use either SQL code to select All of your tables and do a screen capture. Turn in a copy of your SQL code, and a copy of the screen captured tables. .
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

At...

Related Tags