Question: Write the SQL queries for the following (based upon the relational model below): List the immediate family contact details for all patients. List every staff
Write the SQL queries for the following (based upon the relational model below):
- List the immediate family contact details for all patients.
- List every staff person who provides specialist care on each ward.
- List the patient ID and the maximum dosage of the patient taking the highest dosage of a Pharmaceutical supply.
- List the details for the pharmaceutical supply that is most frequently ordered.
- List a count of patient appointments per week.
Staff (staffNo, firstName, lastName, address, phoneNo, position, weeklyHours, shift, specialistType)
Primary key staffNo
Ward (wardNo, wardName, phoneNo, location, numberOfBeds, staffNo)
Primary key wardNo
Foreign key chargeNurseNo references Staff(staffNo)
Bed (bedNo, wardNo)
Primary key bedNo, wardNo
Foreign key wardNo references Ward(wardNo)
LocalClinic (clinicNo, docName, docAddress, docPhoneNo)
Primary key clinicNo, docName
StaffSchedule (shift, weekNo, staffNo, wardNo)
Primary key staffNo, weekNo, wardNo
Foreign key staffNo references Staff(staffNo)
Foreign key wardNo references Ward(wardNo)
Supplier (supplierNo, supplierName, supplierAddress, supplierPhoneNo, supplierFaxNo)
Primary key supplierNo
GeneralSupply (itemNo, itemName, itemDesc, stockQuantity, reorderLevel, unitCost, supplierNo)
Primary key itemNo
Foreign key supplierNo references Supplier(supplierNo)
PharmSupply (drugNo, drugName, drugDesc, dosage, stockQuantity, reorderLevel, unitCost, supplierNo)
Primary key drugNo
Foreign key supplierNo references Supplier(supplierNo)
Requisition (reqNo, staffNo, wardNo, itemNo, drugNo, quantReq, orderDate, dateReceived)
Primary key reqNo
Foreign key chargeNurseNo references Staff(staffNo)
Foreign key wardNo references Ward(wardNo)
Foreign key itemNo references GeneralSupply(itemNo)
Foreign key drugNo references PharmSupply(drugNo)
Patient (patientNo, firstName, lastName, address, phoneNo, dob, maritalStatus, docName, clinicNo, immFamPhoneNumber)
Primary key patientNo
Foreign key docName, clinicNo references LocalDoctor(docName, clinicNo)
Foreign key immFamPhoneNo, patientNo references ImmFamContac (patientNo, immFamPhoneNo
ImmFamContact (immFamFirstName, immFamLastName, immFamRelationship, immFamAddress, immFamPhoneNo, patientNo)
Primary key patientNo, immFamPhoneNo
Foreign key patientNo references Patient(patientNo)
Appointment (apptNo, apptDate, apptTime, examRoom, patientNo, staffNo, staffLastName)
Primary key apptNo
Foreign key patientNo references Patient(patientNo)
Foreign key staffNo references Staff(staffNo)
Inpatient (patientNo, waitListDate, reqWard, datePlacedWard, expDurStay, dateLeftWard, bedNo, wardNo, staffNo)
Primary key patientNo, waitListDate, datePlacedWard
Foreign key patientNo references Patient(patientNo)
Foreign key bedNo references Bed(bedNo, wardNo)
Foreign key wardNo references Ward(wardNo)
Foreign key staffNo references Staff(staffNo)
Outpatient (patientNo, outApptDate, outApptTime)
Primary key patientNo, outApptDate
Foreign key patientNo references Patient(patientNo)
Medication (unitsPerDay, startDate, finishDate, patientNo, staffNo, drugNo)
Primary key drugNo, patientNo, staffNo, startDate
Foreign key drugNo references PharmSupply(drugNo)
Foreign key patientNo references Patient(patientNo)
Foreign key staffNo references Staff(staffNo)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
