0% found this document useful (0 votes)
148 views

DBMS Lab Questions

This document contains 13 questions related to database concepts like schema design, ER diagrams, DDL, DML, functions, procedures, triggers, and cursors. Each question defines a problem and provides requirements to write SQL statements related to the given concept. The questions involve creating tables, inserting data, running queries with joins, aggregates, and set operations. Views, stored procedures and functions are also created to demonstrate those concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views

DBMS Lab Questions

This document contains 13 questions related to database concepts like schema design, ER diagrams, DDL, DML, functions, procedures, triggers, and cursors. Each question defines a problem and provides requirements to write SQL statements related to the given concept. The questions involve creating tables, inserting data, running queries with joins, aggregates, and set operations. Views, stored procedures and functions are also created to demonstrate those concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Q1: DATABASE SCHEMA DESIGN

PROBLEM DEFINITION.

To design a normalised database schema for the following requirement

REQUIREMENT

A library wants to maintain the record of books, members, book issue, book return and fines
collected for late returns in a database. The database can be loaded with book information. A
student can register with the library to be a member. Books can be issued to students with a
valid library membership. A student can keep an issued book with him/her for a maximum
period of two weeks from the date of issue, beyond which a fine will be charged. Fine is
calculated based on the delay in days of return. For 07 days Rs 10, For 7-30 days: Rs.100 and
for days above 30: Rs 10 will be charged per day.

SCHEMA

BOOK (BookId, Title, Language Id, MRP, Publisher Id, Published Date Volume, Status)

AUTHOR (Author-Id, Name, Email, Phone Number, Status

BOOK AUTHOR (Book Id, Author Id)

PUBLISHER (Publisher Id, Name, Address)

MEMBERS(Member Id, Name, Branch Code, Roll Number Phone Number, Email Id, Date
of Jain, Status)

BOOK ISSUE (Issue Id, Date of Issue, Book Id, Member Expected Date of Return, status)

BOOK RETURN (Issue Id, Actual. Date Of Return, Late Days, Late Fee)

LANGUAGES (Language Id, Name)

LATE FEE RULE (From Days, To Days, Amount)

CONCLUSION: The program has executed successfully and output is obtained.


Q2: FAMILARISATION OF E-R DIAGRAM
PROBLEM DEFINITION

To create an ER diagram for the given database design

THEORETICAL BACKGROUND (draw the symbols for each)

-Entity or strong entity

-weak entity

-relationship

-attribute

-key attribute

-multivalued attribute

-composite attribute

-derived attribute

CONCLUSION: The program has executed successfully and output is obtained.


Q3: FAMILARISATION OF DDL COMMANDS
PROBLEM DEFINITION
To study the Data Definition Language Statements

REQUIREMENT
a) Create and insert data into below tables
i) BOOK (BookId, Title, Language Id, MRP, Publisher Id, Published Date
Volume, Status) AUTHOR (Author-Id, Name, Email, Phone Number, Status

ii)BOOK AUTHOR (Book Id, Author Id)

iii)PUBLISHER (Publisher Id, Name, Address)

iv)MEMBERS (Member Id, Name, Branch Code, Roll Number Phone


Number, Email Id, Date of Jain, Status)

v) BOOK ISSUE (Issue Id, Date of Issue, Book Id, Member Expected Date of
Return, status)

vi)BOOK RETURN (Issue Id, Actual. Date Of Return, Late Days, Late Fee)

vii)LANGUAGES (Language Id, Name)

viii)LATE FEE RULE (From Days, To Days, Amount)

b)Execute drop table with and without foreign key

c)Execute alter table command in tables with and without data

CONCLUSION: The program has executed successfully and output is obtained.


Q4: FAMILARISATION OF DML COMMANDS

PROBLEM DEFINITION:
To study Data Manipulation Language statements

REQUIREMENT:
Q1:
Student (name, std_no, class,major)
Course (C_name, C_no, credit hours, dept)
Prerequisite (Cno, prereq_no)
Location (section_identifier, c_no, sem, year,instructor)
Gradereport (Std_no, section_id, grade)
1. Create and insert data into tables as shown above.
2. Find student with STD_NO='CE 301'
3. List all courses under Civil department.
4. Find the prerequisite of C_NO='ME 301'
5. Find the instructor who handles the course EEE 303
6. Update Grade A to O of student with STD_NO='EEE 308'
7. Find the grade of the student with STD_NO='EEE 308'
8. Update the Credit Hours of Course name Machine Learning to 10
9. Delete the student with STD_NO='EEE 303'
Q2:
Worker (worker id, first name, last name, salary, joining_date, department)
Bonus(workers_ref_ld, bonus_date, bonus_amount)
Title (worker_ref-id, worker_title, effect_from)
1. Create and insert data into tables as shown above.
2. Fetch First_Name in Upper case
3. Fetch Unique Values of Department from worker Table.
4. Fetch Unique Values of Department from department Table and find its length.
5. Fetch details from worker excluding First names 'VIBUL','SATHISH'
6. Print the details of Worker with Department Admin
7. Print the details of Workers whose first name have letter H and have 6 characters.
8. Fetch the count of employees in Admin Department

CONCLUSION: The program has executed successfully and output is obtained.


Q5: IMPLEMENTATION OF VARIOUS AGGREGATE FUNCTIONS IN SQL
PROBLEM DEFINITION
To get familiarise with various aggregate functions in SQL.

REQUIREMENT
PRODUCTS (P_ID, NAME, BRAND, CATEGORY, YEAR, PRICE)
1. Find the average price of all products in the products table.
2. List the number of products whose price is greater than 500.
3. Find the highest price of all products.
4. Find the lowest price of all products.

CONCLUSION: The program has executed successfully and output is obtained.


Q6: IMPLEMENTATION OF ORDER BY, GROUP BY- HAVING CLAUSE

PROBLEM DEFINITION
To get familiarise with order by, group by- having clause.

REQUIREMENT
EMPLOYEES(EMP_ID, NAME, DOJ, DESIGNATION, SALARY,DEPT)
ORDERS (ORD_ID, PROD_ID, PRICE, QUANTITY, DISCOUNT)
PRODUCT(PROD_ID, PROD_NAME, SUPPLIER_ID, CATEGORY_ID, UNIT_PRICE)

1. Find the sum of Salary paid to each Department from Employee table.
2. List the salary of Employee in alphabetic order of Employee name.
3. List the employee name based on decreasing order of salary from Employee table.
4. Find the no. of employee in each department from employee table.
5. Find the no. of employee in each department and sum of salary paid to each department
from Employee table.
6. Find the no. of employee in each department and sum of salary paid to each department
and designation from Employee table.
7. Find the sum of Salary paid to CS department from Employee table.
8. Find the no. of employee from each department where at least 2 are present.
9. Find the sale order where total sale> Rs. 2000 from orders table.
10. Find all orders that have at least 5 from orders table.
11. Find most expensive product in each category from product table.
12. Find the most expensive product that have price> 3000 from product table.
13. Find least expensive product in each category from product table.

CONCLUSION: The program has executed successfully and output is obtained.


Q7: IMPLEMENTATION OF SET OPERATIONS, JOIN QUERIES
PROBLEM DEFINITION
To implement set operations and join queries in DML statements

REQUIREMENT
i) Get the number of books written by a given author.
ii) Get the list of publishers and the number of books published by each publisher.
iii) Get the name of authors who jointly wrote more than one book.
iv) Get the list of books that are issued but not returned.
v) Get the List of students who read only Malayalam books.
vi) Get the total fine collected.
vii) Get the list of students who have overdue.
viii) Calculate the fine collected (as of today) to be collected from each overdue book.
vii) List the members who have joined after JANUARY 2021 but has not taken any book.

II) Borrower (cust_name, loan number)


Depositor (cust_name, account_number)
Customer(cust_name,street_no,cust_city)

1. Create and insert data into tables as shown above.


2. List all Customers who have either account, loan or both.
3. List all customers who have account but not loan.
4. List all customers who have both loan and account.

CONCLUSION: The program has executed successfully and output is obtained.


Q8:
FAMILARISATION OF TCL COMMANDS

PROBLEM DEFINITION
To study Transaction Control Language statements

REQUIREMENT
Basic knowledge of TCL statements Commit, Savepoint, Rollback, Abort.

CONCLUSION: The program has executed successfully and output is obtained.


Q9: CREATION OF VIEWS

PROBLEM DEFINITION
To get familiarise with the creation and usage of views in SQL.

REQUIREMENT
1. Create a view for sales preorder showing order number and total price.

2. Create a view big sales order from the existing view sales preorder to display those
orders with price greater than 6000

3. Create a view by joining orders and customer tables to display the total cost
corresponding to each customer orders.

4. Create a view to display above average products from product table.

CONCLUSION: The program has executed successfully and output is obtained.


Q10: CREATION OF PROCEDURES

PROBLEM DEFINITION
To get familiarise with the creation and usage of Procedures

REQUIREMENT
1. Procedure to display book details.

2. Procedure to update the MRP in Book table.

3. Procedure to display the maximum price in Book.

CONCLUSION: The program has executed successfully and output is obtained.


Q11: CREATION OF TRIGGERS

PROBLEM DEFINITION
To get familiarise with the creation and usage of Trigger

REQUIREMENT
Create table emp (ssn int,ename varchar(20),salary int, exper int);Create trigger before
insertion of tuples into employee table.

CONCLUSION: The program has executed successfully and output is obtained.


Q12: CREATION OF FUNCTIONS

PROBLEM DEFINITION
To get familiarise with the creation and usage of Functions.

REQUIREMENT
1. Create a function to calculate no of years from return table.

2. Create function to print GRADES of students

CONCLUSION: The program has executed successfully and output is obtained.


Q13: CREATION OF CURSOR

PROBLEM DEFINITION
To get familiarise with the creation and usage of Cursor.

REQUIREMENT
1. Create procedure to create email_list

A. Create a cursor to get email from each author.

CONCLUSION: The program has executed successfully and output is obtained.

You might also like