Demonstrate an advanced knowledge of stored procedures

Assignment Help PL-SQL Programming
Reference no: EM132385486

Assignment 2

AIMS AND OBJECTIVES:
• to perform queries on a relational database system using SQL;
• to demonstrate an advanced knowledge of stored procedures, stored functions and triggers.
Implement the following tasks using ORACLE SQL*Plus.

Task 1

Download the file NATURALTHERAPY.sql from the LMS site and run it on ORACLE SQL*Plus. This file contains all the CREATE and INSERT statements you will need for this assignment.

NOTE: YOU DO NOT NEED TO INSERT MORE DATA INTO THE TABLES.

The list of tables available for this assignment is the following:

MetabolicCategory (categoryNo, name)
FamilyDoc (GPNo, name, contactNo )
MedicalPractitioner (PractionerNo, name, contactNo, speciality)
Naturopath (NaturopathNo, name, contactNo, officeStartTime, officeEndTime, emailAddress)
RelevantCondition(conditionId, name) MedicalCondition(conditionId, name) Habits(conditionId, name)
Patient(patientId, name, gender, DoB, address, state,postcode, homePhone, businessPhone, maritalStatus, occupation, duration,unit, race, registrationDate , GPNo, NaturopathNo)
MetabolicFunction (functionNo, name, categoryNo)
Visit (visitNo, visitDate, time, amountPaid, receiptNo, service, medication, chiefComplaints, patientId)
PatientMetabolic (functionNo, patientId, score) PatientPractitioner (patientId, practionerNo) PatientRelCon (patientId, conditionId, notes)
PatientHabit (patientId, conditionId, year, average, unit, notes)
PatientMedCon (patientId, conditionId, notes)
RelevantConDetail (patientid, conditionId, specify)

NOTE: PK is printed bold and underlined, FK is printed italic, PK that is also FK is printed bold, italic, and underlined.
Using the tables provided above, provide SQL statements for the following queries.

(a) Display the number of patients referred to by each medical practitioner in the database.

(b) Find out which occupation has the greatest number of patients with high blood pressure.

(c) Display the area postcodes that have at least two patients under the age of 7 years old suffering from asthma.

(d) Display the details of the patient (i.e. Name, Gender, Address, Postcode, DOB) who smokes and has the highest (most severe) total of metabolic functions.

(e) Display the details of patients (i.e. Name, Gender, Address, Postcode, DOB) who haven't visited the naturopath in the last 6 months and who are suffering from a severe heart problem (the total score > 9 for Heart in metabolic screening questionnaire).

(f) Display the details of patients (i.e. Name, Gender, Address, Postcode, DOB) who smoke, have diabetes and high blood pressure. List these patients in an increasing order of their age.

(g) For each patient who has at least an allergy, display the patient's name together with his/her metabolic functions that have the total score >3.

(h) Display the details of all patients in the database (i.e. Name, Gender, Address, Postcode, DOB) together with the referring family doctor of that patient (if any).

(i) Display the average number of patients registered into the database each month.

(j) Display the most popular naturopath that has been visited by the patients.

Task 2

Provide the implementation of the following stored procedures and function. For submission, please include both the PL/SQL code and an execute procedure/SQL statement to demonstrate the functionality.

(a) Write a stored procedure that receives a date as input and displays as the output the list of patients who visited the naturopath on that day.

(b) Write a stored procedure that accepts as input a particular medical problem (from the past medical history), and as the output displays the number of patients suffering from that problem, grouped by the 3 age groups (children 0 - 12 years, teenagers over 12 - 20 years, and adult >20 years).

(c) Write a stored function that uses a patient's id as input and calculates the total amount paid to date by that patient. You also need to show an SQL statement to display the total amount paid by all of the patients in the database.

Task 3

Provide the implementation of the following triggers. For submission, please include both the PL/SQL code and an insert statement to demonstrate the trigger functionality.

(a) A trigger that is activated if the combination of a patient's name, DOB and living address (including address, state, postcode) already exists in the database.
(b) A trigger that is activated whenever a new medication given to a patient matches any one of the patient's allergy list.

Reference no: EM132385486

Questions Cloud

COIT12207 - Internet Applications Assignment Problem : COIT12207 - Internet Applications Assignment Help and Solution, Assessment Help - CQ University, Australia - Creating an online Temperature convertor
Quantitative Research Methods Assignment Problem : Quantitative Research Methods Assignment - Describe the complete sample as well as each experimental condition separately
GHL6017 People Resourcing and Development Assignment : GHL6017 People Resourcing and Development Assignment help and solution Gulf College, Assessment help, Case Study: Changes in HRD at Hansen Group
Summarize and interpret each composite distribution : Summarize and interpret each composite distribution by presenting a box plot (also known as a 5-point summary) for the variable
Demonstrate an advanced knowledge of stored procedures : Demonstrate an advanced knowledge of stored procedures, stored functions and triggers, Display the number of patients referred to by each medical practitioner
Write a report to management identifying any issues : Write a brief description on the Company, identifying the industry they were in, their turnover, how long they had been in business and history of organisation
ACCT5391C Implement an insolvency program Assignment : FNSACC611 - ACCT5391C Implement an insolvency program Assignment help and solution, RMIT University, Assessment help - Who obtained the Supreme Court order
HRM09103 Organisational Change Management Assignment : HRM09103 Organisational Change Management Assignment help and solution, Edinburgh Napier University, Assessment help - evaluate the use of motivation theories.
MGT602 Business Decision Analytics Assignment : MGT602 Business Decision Analytics Assignment help and solution, Decision Style Analysis Reflective report, Assessment help, Torrens University.

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  Create a database model

Create a database model and Submit the table creation statements for the Database Model.

  Write pl-sql procedures and functions

Write PL/SQL procedures and functions to populate and query that database

  Sql questions

Write a query to display using the employees table the EMPLOYEE_ID, FIRST_NAME, LAST_NAME and HIRE_DATE of every employee who was hired after to 1 January, 1995.

  Run the lab_03_01.sql script

Run the lab_03_01.sql script in the attached file to create the SAL_HISTORY table. Display the structure of the SAL_HISTORY table.

  Write sql queries

Write a query to display the last name, department number, and salary of any employee whose department number and salary both match the department number and salary of any employee who earns a commission.

  Explaining sql insert statement to insert new row in cds

Write down a SQL insert statement to insert new row in "CDS" table.

  Write down name of actors in ascending order

Write down actors (or actress, your choice, but not both) who have won at least two (2) Academy Awards for best actor/actress. Provide the actor name, movie title & year. Order the result by actor name."

  What is an sql injection attack

What is an SQL injection attack? Explain how it works, and what precautions must be taken to prevent SQL injection attacks.What are two advantages of encrypting data stored in the database?

  Determine resonant frequency in series rlc resonant circuit

Given the series RLC resonant circuit in the figure, operating at variable frequency, determine: The resonant frequency ω o ,  The circuit’s quality factor Q , The cut-off frequencies, f 1  & f 2  and the bandwidth BW

  Query that uses cube operator to return lineitemsum

Write summary query which uses CUBE operator to return LineItemSum (which is the sum of InvoiceLineItemAmount) group by Account(an alias for AccountDesciption).

  Query to show customers were missing for existing orders

As DBA, your manager called a meeting and asked why there are so many orders for customers that don't exist in the customer table. Write query which would shows which customers were missing for existing orders. Use a join or a subquery.

  Sql query into a relational algebra statement

Turn this SQL query into a relational algebra statement? SELECT Request.reqfor, Ordering.invamt, Ordering.invnbr, Ordering.invdat

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd