Professional Documents
Culture Documents
Set 2
Set 2
Fourth Semester
(Regulations 2017)
Aim & Procedure Queries & Output & Viva-Voce Record Total
Program Result
20 30 30 10 10 100
3. Create the Company database with the following tables and do the following:
Administration(employee_salary, development _cost, fund_amount,
turn_over,bonus)
Emp_details (emp_no, emp_name, DOB, address, doj, mobile_no, dept_no,
salary).
i. Calculate the total and average salary amount of the employees of each
department.
select sum(salary) as tot_salary,avg(salary) as avg_salary from
emp_details group by dept_no;
Page 3 of 9
4. Create the student database with the following tables and do the
following: assessment(reg_no,name, mark1, mark2, mark3, total)
dept_details (dept_no, dept_name, location).
create table BOATS(bid number primary key, bname varchar(20), colour varchar(10));
insert into BOATS values(201,'b1','blue');
insert into BOATS values(202,'b2','green');
insert into BOATS values(203,'b3','red');
declare
tot_amt number;
cursor p is
select pcode,qty from order_product;
begin
for product in p
loop
tot_amt:=tot_amt+product.qty*(select unit_price from product where
pcode=product.pcode);
end loop;
dbms_output.put_line('tot:'||tot_amt);
end;
/
10. Consider the following database of student enrollment in courses and books adopted
for that course.
STUDENT(regno, name, major, bdate)
COURSE(courseno, cname, dept)
ENROLL(regno, courseno, sem, marks)
create table student(regno number primary key, name varchar(10), major varchar(10),
bdate date);
create table course(courseno number primary key, cname varchar(10), dept
varchar(10));
create table enroll(regno number, courseno number, sem number(1), marks
number,foreign key(regno,courseno) references student(regno),course(courseno));
i. Display the total number of students register for more than two courses in a
department specified.
select count(regno) from course natural join enroll group by courseno having
dept='cse' and count(courseno)>2;
ii. Display the students who have secured the highest mark in each course
select name from student where regno in (select regno from enroll
where mark =max(mark));
iii. List the youngest student of each course in all departments.
iv. Develop PL/SQL Cursor that selects marks of a particular student in a
specified semester.
declare cursor s for select mark from enroll where regno=101 and
sem=3;
11.
The following are maintained by a book dealer.
AUTHOR(author_id, name, city, country)
PUBLISHER(publisher_id, name, city, country)
CATALOG(book_id, title, author_id, publisher_id , category_id, year, price)
Page 7 of 9
CATEGORY(category_id, description)
ORDER_DETAILS(order_no, book_id, quantity)
create table author(author_id number primary key, name varchar(10), city varchar(10),
country varchar(10));
create table catalog(book_id number primary key, title varchar(10), author_id number,
publisher_id number, category_id number, year number, price number, foreign
key(author_id,publisher_id,category_id) references
author(author_id),publisher(publisher_id),category(category_id));
create table order_details(order_no number primary key, book_id number foreign key
references catalog(book_id), quantity number);
i. List the author of the book that has minimum sales.
select name from author natural join catalog where book_id in (select book_id
from order_details where quantity=min(quantity));
ii. Display total number of books in each category.
select category_id,count(category_id) from catolog where group by
category_id;
iii. Develop a PL/SQL procedure that updates the price of the book by 10%
those with maximum sales.
create procedure price_increase as
declare
bookid number;
begin
select book_id into bookid where quantity=max(quantity);
update catalog set price=price+(price*0.10) where book_id=bookid;
commit;
end;
/
12. Create the student database with the following tables and do the
following: mark_details(reg_no,name, mark1, mark2, mark3, total)
dept_details (dept_no, dept_name, HOD)
stud_details(reg_no,name, dob, address)