Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following subset of relations from the RVH database: Patients ( pid , name, address, telephone, care _ centre _ id ) Care _

Consider the following subset of relations from the RVH database:
Patients(pid, name, address, telephone, care_centre_id)
Care_centres(cid, name, location, nurse_charge_id)
Treatments(tid, patient_id, physician_id, treatment_name, date)
Nurses(nid, name, care_centre_id, certificate_type, telephone, salary)
Physicians(phid, name, pager_number, specialization, salary)
Use PostgreSQL (or the DBMS selected for your labs) to complete the following tasks.
Create the tables that correspond to these relations in your PostgreSQL database.
If not automatically created by the DBMS, create indexes corresponding to the primary and foreign keys.
Populate these tables with some sample data and write SQL queries that show the content of each table after entering the data.
For some strategic decisions, the president of the hospital needs summary data about the care centres. For each care centre, the president needs to know the number of nurses holding an RN certificate as well as their total and average salaries. Does the following view answer the presidents request? If not, write the correct view that will satisfy the presidents request.
CREATE VIEW NURSE_SUMMARY (D, C, TOTAL_S, AVERAGE_S)
AS SELECT cid, COUNT (*), SUM (salary), AVG (salary)
FROM Care_centres, Nurses
WHERE nurse_charge_id = nid and certificate_type like RN
GROUP BY cid;
State which of the following queries and updates would be allowed in this view. If a particular query or update would be allowed, show what the corresponding query or update on the base relations would look like and give its result when applied to the database.
Q1. SELECT *
FROM NURSE_SUMMARY;
Q2. SELECT D, C
FROM NURSE_SUMMARY
WHERE TOTAL_S >100000;
Q3. SELECT D, AVERAGE_S
FROM NURSE_SUMMARY
WHERE C >(SELECT C FROM NURSE_SUMMARY WHERE D=4);
Q4. UPDATE NURSE_SUMMARY
SET D=3
WHERE D=4;
Q5. DELETE FROM NURSE_SUMMARY
WHERE C >4;
Create a view that displays the following information for each patient.
Patient Number
Patient Name
Care Centre Name
Name of Nurse-in-Charge
Treatment ID
Treatment Name
Physician ID
Date

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions