Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

BAHRIA UNIVERSITY, (Karachi Campus)

Department of Software Engineering


Open Ended Lab -1
Semester Spring 2021

Course Title: Advanced Database Management system Course Code:


Course Instructor: Engr. Muhammad Faisal Class: BSE-6(B)
Lab Instructor: Engr. Ramsha Mashood Name: _Sadia Afzal_______
Max. Marks: 30 Marks Reg no: __57238_________
Time: Till 11:59pm Date: 29-5-2021
Note:

 Plagiarism is not allowed, if found you will get zero marks.


 Try to submit the task on LMS in given Time.
 Include your name or enrollment no on footer.
 Your File name should be in the given format:
o [Class Section] [Complete Name] ADBMSOEL1
o i.e., BSE6A Usman Ali ADBMSOEL1

QUESTION 01: (15Marks)


A system in which data of Patient, data of donor, data of blood bank would be saved and will be
interrelation with each other

DATA OF PATIENT – Patient Name, Patient Id, Patient Blood Group, Patient Disease, Account
Creation date , Date of Birth
DATA OF DONOR – Donor Name, Donor Id, Donor Blood Group, Donor Medical report, Donor
Address, Donor Contact number, Date of Birth , Donation Count, Donation Date, Account Creation
date
DATA OF BLOOD BANK – Blood Bank Name, Blood Bank Address, Blood bank Donors name,
Blood Bank Contact Number, Blood Bank Address

Try to implement such scenario in a database and normalize or de-normalize it if needed, create an
object for patient diseases and implement following functions and procedure in a single
application using any method :
1. Show all donor and patient record.
2. Create a function which will increase donation count if user give donation.
3. Create a table of doctor which will hold doctor (Doctor Name, Doctor Id, and Doctor
Qualification) and it will hold reference of patient.
4. Create a procedure which will display Donor name, Account Creation Date, no day’s user
register, no of months up till now from donation date.
5. Create a function in which show list of hospitals using Varray.
Objects:
I have create Patient Info Object that contains all the common attributes needed
for Donor table and Patient Table

I have create Address Object that is used in every table / varray where the Address
is needed.

I have created Patient Disease object that is used inside the Patient table.

Tables:
I have create Patient table that uses Person Info object and Patient disease object.
I have create Donor table that uses Person Info object and Address object.

I have created Blood Bank Table that uses Address object

Insert Values:
Insert some dummy data in Patient Table

Insert some dummy data in Donor Table


Task # 1: Show all donor and patient record.

Donor Table:

Code:
select d.DonorInfo.PatientID,
d.DonorInfo.PatientName,d.DonorInfo.BloodGroup,d.DonorInfo.contact,d.DonorInfo.DOB,
d.DonorInfo.AccountCreationDate,
MedicalReport, d.DonorAddress.Houseno, d.DonorAddress.street,d.DonorAddress.city,
DonationCount, Donation from Donor d;

Patient Table:

Code:
select p.PInfo.PatientID,
p.PInfo.PatientName,p.PInfo.BloodGroup,p.PInfo.contact,p.PInfo.DOB,
p.PInfo.AccountCreationDate,
p.PDisease.Dname, p.PDisease.DType from Patient p;
Task # 2: Create a function, which will increase donation count if user give
donation.

Code:

Call the Function:

Output:
Task # 3: Create a table of doctor which will hold doctor (Doctor Name, Doctor
Id, and Doctor Qualification) and it will hold reference of patient.

Task # 4: Create a procedure which will display Donor name, Account Creation
Date, no day’s user register, no of months up till now from donation date.

Code:
Output:

Task # 5: Create a function in which show list of hospitals using Varray.


Solution:

We have:
 First Created Hospital_Type Object
 Then, Created Array of Hospital_Type Object
 And in last, Inserted and displayed values in varray

Code:
Output:

QUESTION 02: (15Marks)


Consider a company having 3 different departments A, B and C .All departments have
employees of different strength they used to give company an outstanding profit , that company
wants to have an application which will store employee record and departments detail. It will
be an Oracle based application which will also show company profit done by department A
and marketing percentage of department B. While production of Department C.
Company manager also ask developer to view, edit and delete employees and departments
record. Implement the oracle based application using any technique.

Code:
create table dept_A(
dept_name varchar2(25),
dept_id number(5),
dep_strength number,
company_profits float
);

insert into dept_A values('Sales And Profits', d_sequence.nextval, 55, 15855.32)


insert into dept_B values('Marketing', d_sequence.nextval, 90, 72);
insert into dept_C values('Production', d_sequence.nextval, 80, 85);

insert into Employees values(e_sequence.nextval, 'Sadia', 'Sales And Profits', 22, '1027 E. Philadelphia
St')

select * from dept_A

create table dept_B(


dept_name varchar2(25),
deinsert into dept_A values('Sales And Profits', d_sequence.nextval, 55, 15855.32);
insert into dept_B values('Marketing', d_sequence.nextval, 90, 72);
insert into dept_C values('Production', d_sequence.nextval, 80, 85);

insert into Employees values(e_sequence.nextval, 'Sadia', 'Sales And Profits', 22, '1027 E. Philadelphia
St')
pt_id number(5),
dep_strength number,
marketing_percentage float
);

create table dept_C(


dept_name varchar2(25),
dept_id number(5),
dep_strength number,
production float);

create table Employees(


emp_id number(7),
emp_name varchar2(25),
emp_dept varchar2(35),
emp_age number,
emp_address varchar(50)
);
insert into dept_A values('Sales And Profits', d_sequence.nextval, 55, 15855.32);
insert into dept_B values('Marketing', d_sequence.nextval, 90, 72);
insert into dept_C values('Production', d_sequence.nextval, 80, 85);

insert into Employees values(e_sequence.nextval, 'Sadia', 'Sales And Profits', 22, '1027 E. Philadelphia
St')

create or replace package productivity as

procedure delete_employee(e_id number);


procedure list_deptC;
procedure list_productivity;

end productivity;

create or replace package body productivity as

procedure delete_employee(e_id number)


is
begin
dbms_output.put_line('Sadia Afzal 02-131182-022');
delete from Employees where emp_id = e_id;
end delete_employee;

procedure delete_dept_A(d_id number)


is

procedure list_employees
is
cursor abc is select * from Employees;
begin
dbms_output.put_line('Sadia Afzal 02-131182-022');

for i in abc
loop
dbms_output.put_line('Employee Name :- ' || i.emp_name || ' Employee ID :- ' || i.emp_id || ' Employee
Department :- ' || i.emp_dept);
end loop;

end list_employees;

procedure list_deptA
is
cursor abc is select * from dept_A;
begin
dbms_output.put_line('Sadia Afzal 02-131182-022');
for i in abc
loop
dbms_output.put_line('Department Name :- ' || i.dept_name || ' Department ID :- ' || i.dept_id || '
Department Strength :- ' || i.dep_strength);
end loop;
end list_deptA;

procedure list_deptB
is
cursor abc is select * from dept_B;
begin
dbms_output.put_line('Sadia Afzal 02-131182-022');
for i in abc
loop
dbms_output.put_line('Department Name :- ' || i.dept_name || ' Department ID :- ' || i.dept_id || '
Department Strength :- ' || i.dep_strength);
end loop;
end list_deptB;

procedure list_deptC
is
cursor abc is select * from dept_C;
begin
dbms_output.put_line('Sadia Afzal 02-131182-022');
for i in abc
loop
dbms_output.put_line('Department Name :- ' || i.dept_name || ' Department ID :- ' || i.dept_id || '
Department Strength :- ' || i.dep_strength);
end loop;
end list_deptC;

procedure list_productivity
is
cursor abc is select * from dept_A;
cursor pqr is select * from dept_B;
cursor xyz is select * from dept_C;

Begin
dbms_output.put_line('Sadia Afzal 02-131182-022');
for i in abc
loop
dbms_output.put_line('Profits Generated By Department A :- ' || i.company_profits);
end loop;

for l in pqr
loop
dbms_output.put_line('Marketing Percentage of Department B :- ' || l.marketing_percentage);
end loop;

for k in xyz
loop
dbms_output.put_line('Production generated from Department C :- ' || k.production);
end loop;
end list_productivity;

end productivity;

You might also like