Answered step by step
Verified Expert Solution
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:
Patientspid name, address, telephone, carecentreid
Carecentrescid name, location, nursechargeid
Treatmentstid patientid physicianid treatmentname, date
Nursesnid name, carecentreid certificatetype, telephone, salary
Physiciansphid name, pagernumber, 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 NURSESUMMARY D C TOTALS AVERAGES
AS SELECT cid, COUNT SUM salary AVG salary
FROM Carecentres, Nurses
WHERE nursechargeid nid and certificatetype 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.
Q SELECT
FROM NURSESUMMARY;
Q SELECT D C
FROM NURSESUMMARY
WHERE TOTALS ;
Q SELECT D AVERAGES
FROM NURSESUMMARY
WHERE C SELECT C FROM NURSESUMMARY WHERE D;
Q UPDATE NURSESUMMARY
SET D
WHERE D;
Q DELETE FROM NURSESUMMARY
WHERE C ;
Create a view that displays the following information for each patient.
Patient Number
Patient Name
Care Centre Name
Name of NurseinCharge
Treatment ID
Treatment Name
Physician ID
Date
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started