Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following relations: 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,

Consider the following relations:

  • 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.

  1. For some strategic decisions, the president of the hospital needs summary data about the care centres. For each care centre, s/he 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. (7 marks)

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;

  1. 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. (5 marks)

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;

  1. Use PostgreSQL or the database system you used for the Labs to create a view that displays the following information for each Patient: (10 marks)

Patient Number

Patient Name

Care Center Name

Name of Nurse-in-charge

Treatment ID

Treatment Name

Physician ID

Date

(Only the part f Please)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

Students also viewed these Databases questions

Question

2 The main characteristics of the market system.

Answered: 1 week ago