Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in sql im trying to make a stored procedure that display the following data from the appointemt : id_number employee_id_number appointment_date CREATE TABLE Center( center_number

in sql

im trying to make a stored procedure that display the following data from the appointemt :

id_number

employee_id_number

appointment_date

CREATE TABLE Center( center_number varchar2 (24) PRIMARY KEY, center_name varchar2(40), center_address varchar2 (60) );

CREATE TABLE nurse( employee_id_number number (8) PRIMARY KEY, nurses_name varchar2(40) );

CREATE TABLE patient( id_number number (8) PRIMARY KEY, first_name varchar2(20), last_name varchar2(20), patient_age varchar2(10), disease_type varchar2(40) );

CREATE TABLE vaccine( vaccine_name varchar2(30) PRIMARY KEY );

CREATE TABLE appointment( appointment_date date, employee_id_number number (8), id_number number (8), CONSTRAINT a_fk1 FOREIGN KEY (employee_id_number) REFERENCES nurse(employee_id_number), CONSTRAINT a_fk2 FOREIGN KEY (id_number) REFERENCES patient(id_number) );

CREATE TABLE Dose( id_number number (8), vaccine_name varchar2(30), dose_date date,

CONSTRAINT d_fk1 FOREIGN KEY (id_number) REFERENCES patient(id_number), CONSTRAINT d_fk2 FOREIGN KEY (vaccine_name) REFERENCES vaccine(vaccine_name) );

--insertion to nurse table INSERT INTO nurse VALUES(21101220,'Raghad'); INSERT INTO nurse VALUES(12017198,'Sandra'); INSERT INTO nurse VALUES(40322544,'Deema'); INSERT INTO nurse VALUES(45099987,'Rawaf'); INSERT INTO nurse VALUES(85432100,'Haneen'); INSERT INTO nurse VALUES(71486637,'Mona');

--insertion to patient table INSERT INTO patient VALUES(78910742,'mohmmed','ahmed',25,'covid-19'); INSERT INTO patient VALUES(34115789,'basel','bader',35,'covid-19'); INSERT INTO patient VALUES(50403321,'sabah','sultan',15,'covid-19'); INSERT INTO patient VALUES(33723450,'turki','fahad',40,'covid-19'); INSERT INTO patient VALUES(10322141,'raneem','mohmmed',45,'covid-19'); INSERT INTO patient VALUES(31245900,'Ali','faisal',19,'covid-19'); INSERT INTO patient VALUES(42576334,'Shahad','adnan',20,'covid-19'); INSERT INTO patient VALUES(11350782,'Dana','Ali',30,'covid-19');

--insertion to appointment table INSERT INTO appointment VALUES('22-Apr-2022',40322544,33723450); INSERT INTO appointment VALUES('15-Oct-2022',21101220,78910742); INSERT INTO appointment VALUES('07-Aug-2022',85432100,34115789); INSERT INTO appointment VALUES('02-Nov-2022',45099987,10322141); INSERT INTO appointment VALUES('19-Dec-2022',12017198,50403321); INSERT INTO appointment VALUES('19-Dec-2022',71486637,31245900); INSERT INTO appointment VALUES('02-Nov-2022',12017198,42576334); INSERT INTO appointment VALUES('20-Jan-2022',21101220,11350782);

--insertion to vaccine table INSERT INTO vaccine VALUES('Pfizer'); INSERT INTO vaccine VALUES('Oxford'); INSERT INTO vaccine VALUES('Moderna'); INSERT INTO vaccine VALUES('Astrazeneca'); INSERT INTO vaccine VALUES('Sputnik');

--insertion to Dose table INSERT INTO Dose VALUES(78910742,'Oxford','15-Oct-2022'); INSERT INTO Dose VALUES(34115789,'Astrazeneca','07-Aug-2022'); INSERT INTO Dose VALUES(50403321,'Moderna','19-Dec-2022'); INSERT INTO Dose VALUES(33723450,'Sputnik','22-Apr-2022'); INSERT INTO Dose VALUES(10322141,'Pfizer','02-Nov-2022'); INSERT INTO Dose VALUES(31245900,'Oxford','19-Dec-2022'); INSERT INTO Dose VALUES(42576334,'Pfizer','02-Nov-2022'); INSERT INTO Dose VALUES(11350782,'Sputnik','20-Jan-2022');

--insertion to Center table INSERT INTO center VALUES('0594578674','Obhour-alshamaliah','Jeddah'); INSERT INTO center VALUES('0594218614','almanar','Riyadh'); INSERT INTO center VALUES('0594578698','aljouhraa','Dammam'); INSERT INTO center VALUES('0593912094','aljabriyah','yanbu'); INSERT INTO center VALUES('0599823199','alqadasiah','tabuk');

--Design and implement 5 queries SELECT * FROM patient where first_name ='mohmmed';

SELECT id_number,appointment_date FROM appointment ORDER BY appointment_date ASC;

SELECT COUNT(id_number) AS Patients ,dose_date FROM dose GROUP BY dose_date;

SELECT patient.id_number AS ID, patient.first_name AS Fname ,patient.last_name AS Lname, appointment.appointment_date AS appointments FROM patient JOIN appointment ON patient.id_number = appointment.id_number;

select employee_id_number , appointment_date from appointment where employee_id_number in (select employee_id_number from nurse where nurses_name ='Sandra');

CREATE OR REPLACE procedure p_ticket (p_id number, n_id number, p_date date) AS patient_ID patient.id_number%TYPE; nurse_ID nurse.employee_id_number%TYPE; app_date appointment.appointment_date%TYPE; CURSOR executive IS SELECT id_number,employee_id_number,appointment_date INTO patient_ID,nurse_ID,app_date FROM appointment WHERE id_number =78910742; BEGIN FOR f_patient IN executive loop dbms_output.put_line('Patient ID '||id_number||'Nurse ID '|| employee_id_number||'Date '||app_date); END LOOP; END p_ticket;

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

Building The Data Warehouse

Authors: W. H. Inmon

4th Edition

0764599445, 978-0764599446

Students also viewed these Databases questions

Question

Analyze the impact of labor unions on health care.

Answered: 1 week ago

Question

Assess three motivational theories as they apply to health care.

Answered: 1 week ago

Question

Discuss the history of U.S. labor unions.

Answered: 1 week ago