20MCA28P Practical III RDBMS LAB

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1

Department of P. G. Studies and Research in


Computer Science, Gulbarga University,
Kalaburagi
M.C.A. II Semester
20MCA28P Practical-III: RDBMS LAB

Note: Create the following Tables, insert at least 10 rows into the table and
display the output with appropriate values.

I. Consider the following schema for Library Database:

BOOK (Book_id, Title, Publisher_Name, Pub_Year)


BOOK_AUTHORS (Book_id, Author_Name)
PUBLISHER (Name, Address, Phone)
LIBRARY_BRANCH (Branch_id, Branch_Name, Address)
BOOK_COPIES (Book_id, Branch_id, No-of_Copies)
CARD (Card_No)
BOOK_LENDING (Book_id, Branch_id, Card_No, Date_Out, Due_Date)

Write SQL queries to:

1. To Insert ten records and display book, book_author and publisher table.
2. To Display Book_id,Title and Author_name.
3. To Display Publisher Name, Address and Phone number.
4. To Display Book_Id,Branch_id and Card_number.
5. To Display all Book_id and Branch_id and No_of_Copies.
6. To Display Branch_id and Branch_name.
7. Retrieve details of all books in the library – id, title, name of publisher, authors,
number of copies in each branch, etc.
8. Get the particulars of borrowers who have borrowed more than 3 books, but from
Jan 2017 to Jun 2017.
9. Delete a book in BOOK table. Update the contents of other tables to reflect this
data manipulation operation.
10.Partition the BOOK table based on year of publication. Demonstrate its working
with a simple query.
11.Create a view of all books and its number of copies that are currently available in
the Library.

1
2

II. Consider the following schema for Order Database:


SALESMAN (Salesman_id, Name, City, Commission)
CUSTOMER (Customer_id, Cust_Name, City, Grade, Salesman_id)
ORDERS (Ord_No, Purchase_Amt, Ord_Date, Customer_id, Salesman_id)

Write SQL queries to:


1. To insert ten records and to display salesman, customer and Orders Table
2. To Display Salesman_id, Name, and City.
3. To Display Salesman_Id and Customer_id.
4. To Display Order_no, Ord_Date, Customer_id, Salesman_id.
5. Count the no_of_salesman and no_of_customer in salesman and customer table
6. Count the customers with grades above Bangalore’s average.
7. Find the name and numbers of all salesmen who had more than one customer.
8. List all salesmen and indicate those who have and don’t have customers in their
cities (Use UNION operation.)
9. Create a view that finds the salesman who has the customer with the highest
order of a day.
10. Demonstrate the DELETE operation by removing salesman with id 1000. All his
orders must also be deleted.

III. Consider the schema for College Database:


STUDENT (USN, SName, Address, Phone, Gender)
SEMSEC (SSID, Sem, Sec)
CLASS (USN, SSID)
SUBJECT (Subcode, Title, Sem, Credits)
IAMARKS (USN, Subcode, SSID, Test1, Test2, Test3, FinalIA)

Write SQL queries to:


1. To insert ten records and to display STUDENT, SEMSEC, CLASS, SUBJECT,
and IAMARKS Tables.
2. To Display USN, SName, Address.
3. To Display USN and SSID.
4. To Display USN, SSID, SUBCODE.
5. To Display Test1, Test2 and Test3 Marks.
6. To count total no_of_students.
7. List all the student details studying in fourth semester ‘C’ section.
8. Compute the total number of male and female students in each semester and in
each section.
9. Create a view of Test1 marks of student USN ‘1BI15CS101’ in all subjects.

2
3

IV. Consider the following schema for Employee Database:

Employee (Emp_no, Emp_name,Emp_address, Emp_city, Acc_no)


ACCOUNT (Acc_no,Acc_name,Acc_type, Open_date, Bal_amount)

Write SQL query to:


1. To insert data into the created table and display the output.
2. To Generate the yearly report (from first January of a year to 31st December of
a year)

V. Consider the schema for SALARY Database:

SALARY (Empno, Name, Deptid, Basic, HRA, Deduction, Tax)


Write SQL query to create Salary table, insert data into the table and display
the output.

Write SQL query to:

1. Write SQL query to retrieve the number of records in the table.


2. Write SQL query to retrieve the number of employees in Department ‘D1’
3. Write SQL query to retrieve the number of employees in
Department ‘D1’ & whose Basic pay is less than 6000.
4. Write SQL query to retrieve the number of distinct Department (eliminating
duplicates).
5. Write SQL query to find the total pay of all employees.
6. Write SQL query to list the Average pay of all employees in the
Department ‘D1’ whose HRA is greater than 1000.00.
7. Write SQL query to find the average pay of employee in different departments.
8. Write SQL query to find the names of all the employees whose basic pay
is greater than the average basic pay.
9. Write SQL query to find the name of the employees whose basic pay is maximum.
10.Write SQL query to retrieve the Department Id, average, maximum and
minimum basic pay of all the Departments.
11.Write SQL query to retrieve the Department Id, average, maximum and
minimum of the net pay of all the Departments.
12. Write SQL query to retrieve the Department Id, average, maximum and
minimum basic pay of all the Departments other than ‘D1’.

3
4

VI. PL/SQL Programs

1. Write a PL/SQL program to perform Arithmetic operations using operators.


2. Write a PL/SQL program to display n Natural numbers.
3. Write a PL/SQL program to display 1 to 100 Even and odd numbers.
4. Write a PL/SQL program to display 1 to 100 prime numbers.
5. Write a PL/SQL program largest of n numbers, input by the user.
6. Write a PL/SQL program to perform relational operations using relation
operators.
7. Write a PL/SQL program to compute sum of given ‘n’ integers.
8. Write a PL/SQL program to sort the numbers in ascending order.
9. Write a PL/SQL program to sort the numbers in descending order.
10.Write a PL/SQL program to sort your name ascending and descending order.
11.Write a PL/SQL program biggest of three numbers input by the user.
12.Write a PL/SQL program to compute Area and Circumference of a circle.
13.Write a PL/SQL program to compute Area of Rectangle.
14.Write a PL/SQL program to check the given string is palindrome or not.
15.Write a PL/SQL program to compute the addition of two matrices.
16.Write a PL/SQL program to check whether a given number is prime or not.
17.Write a PL/SQL program to reverse a given string.
18.Write a program to display the Fibonacci series for n given terms.

You might also like