0% found this document useful (0 votes)
23 views13 pages

DBMS Excercise

The document outlines a series of assignments for a Database Management System Lab course at Brainware University. It includes tasks related to creating and manipulating database tables for student records, sales information, cricket match statistics, and library management. Each assignment requires the implementation of SQL commands for data definition, manipulation, and querying based on specified requirements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views13 pages

DBMS Excercise

The document outlines a series of assignments for a Database Management System Lab course at Brainware University. It includes tasks related to creating and manipulating database tables for student records, sales information, cricket match statistics, and library management. Each assignment requires the implementation of SQL commands for data definition, manipulation, and querying based on specified requirements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

BRAINWARE UNIVERSITY

[PCC-CS591] [2021-22]
B.Tech Computer Science & Engineering
Assignment-1
Database Management System Lab
PCC-CS591

1. In a university the following two tables are maintained for handling their students.
STUD_MEMBER ( Roll_no varchar2(16),
Name varchar2(20),
Sem number(1),
Contact_no number(10),
Gender varchar2(1),
Dept_id number(2))

DEPARTMENT (Dept_id number(2),


Dept_name varchar2(20))

Write the following DDL and DML and DQLs

1. Create a new user (username: your name) and give all privileges.
2. Create STUD_MEMBER table where Name and Gender must not be NULL.
3. Make Roll_no as primary key.
4. The semester number must be greater than 0 and less than 9
5. Create DEPARTMENT table.
6. Make Dept_id as the primary key using Alter command.
7. Make Dept_id of STUD_MEMBER as a FK which references Dept_id of
DEPARTMENT relation.
8. Add a new column ‘Dept_loc varchar2(10)’ into the DEPARTMENT table.
9. Try to insert a record into the STUD_MEMBER table and write your observation.
10. Rename the ‘Contact_no’ of STUD_MEMBER to ‘Mobile_No’
11. Populate the DEPARTMENT as per the following table:

Dept_ID Dept_Name Dept_loc


1 Information Technology Kolkata
2 Electrical Barasat
3 Civil Barasat
4 Mechanical Kolkata
5 Electronics Barasat
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-22]

12. Populate the STUD_MEMBER as per the following table:

Roll_No Name Dept_ID Semester Mobile_No Gender


BWU/BIT/19/01 Ankur Das 1 1 2721210011 M
BWU/BIT/19/02 Kamal Saha 1 1 2321222211 M
BWU/BIT/19/03 Ankita Bnerjee 1 1 1121213311 F
BWU/BEE/19/01 Kamal Nandy 2 3 1231233344 F
BWU/BCE/19/08 Amit Saha 3 3 4536677667 M
BWU/BEE/19/014 Avijit Ghosh 2 1 3232327643 M
BWU/BEE/19/09 Ganesh Sill 2 3 1242447644 M
BWU/BCE/19/05 Shweta Thakur 3 1 6463426789 F
BWU/BCE/19/012 Pooja Patra 3 3 3286562345 F
BWU/BEE/19/015 Kamal Haldar 2 3 2574225678 F
BWU/BME/19/06 Kiran Das 5 1 7541242345 F

13. Display the names and contact numbers of all student members.
14. Create another table STUD_DETAILS whose structure is same as STUD_MEMBER
along with all the data.
15. Change the Contact_No field of STUD_DETAILS to Ph_No.
16. Update the phone number of Pooja Patra from 3286562345 to 03325345666
17. Try to insert another student without supplying any value of roll number
18. Display the names and roll numbers of all students of Information Technology.
19. Display names of all Departments.
20. Display information of student members whose name begins with the letter “A”.
21. Display all details of Male members only.
22. Display data of student members who are currently in semester 3.
23. Display data of student female members in alphabetical order.
24. Find the name of the department where ‘Amit Saha’ belongs to.
25. Find all the students of ‘Kolkata’ branch
26. Display all the students of Information Technology department.
27. Display the name(s) of the students whose name starts with ‘A’ and at least 5 character
lengths.
28. Find only the numeric digit of the roll no field of the student Avijit Ghosh.
29. Try to delete ‘Electronics’ department from department table.
30. How do you delete ‘Electronics’ department from department table.

Date of Submission: 08/09/2021


BRAINWARE UNIVERSITY

[PCC-CS591] [2021-22]

Assignment –II
B.Tech CSE Sec A
PCC-CS591
Database Management System Lab

A database is being constructed for storing sales information system. A product can be described with a
unique product number, product name, selling price, manufacturer name. The product can sale to a
particular client and each client have its own unique client number, client name, client addresses, city, pin
code, state and total balance to be required to paid. Each client order to buy product from the salesman.
In the order, it has unique sales order number, sales order date, client number, salesman number
(unique), billed whole payment by the party or not and its delivery date. The salesman has the name,
addresses, city, pin code, state, salary of the sales man, delivery date, and total quantity ordered, product
rate.

Create the above tables using the following statements:

A. Create table product (product_id varchar(10) primary key, product_name varchar(20),


manufacturer_name char(20),product_rate number(9,4), sell_price umber(9,4),
product_description varchar(25));
B. Create table client (client_id varchar(10) primary key, client_name char(20),address varchar(15),
city char(15), pin number(8), state char(15),bal_due number(9,4));
C. Create table salesman (salesman_id varchar(10) primary key, salesman_name char(20),address
varchar(15), city char(15), pin number(8), state char(15), salary number(9,4));
D. Create table sales_order_details (sales_order_no varchar(10) primary key, sales_order_date date,
client_id varchar(10) references client(client_id), salesman_id varchar(10) references
salesman(salesman_id) , bill_payby_party char(5), delivery_date date, product_rate number(9,4)
, tot_quantity_order number(8), cancel_date date default NULL);

Q.1.1. Write the SQL queries for the following –


(a) Retrieve the list of names and the cities of all the clients.
(b) List the various products available.
(c) Find the names of all clients having ‘a’ as the second letter in their names.
(d) List all the clients who are located in TEZPUR.
(e) Find the products whose selling price is greater than 2000 and less than or equal to 5000
(f) Add a new column NEW_PRICE into the product_master table.
(g) Rename the column product_rate of Sales_Order_Details to new_product_rate.
(h) List the products in sorted order of their description.
(i) Display the order number and date on which the clients placed their order.
(j) Delete all the records having delivery date before 25th August, 2008.
(k) Change the delivery date of order number ON01008 to 16-08-08
(l) Change the bal_due of client_no CN01003 to 1200
(m)Find the product with description as ‘HDD1034’ and ‘DVDRW’
(n) List the names, city and state of the clients not in the state of ‘ASSAM’
(o) List of all orders that were canceled in the of March.
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-22]
Last Date of Submission: 22/09/2020
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-2022]

Assignment-III
PCC-CS591
Database Management System Lab

1. Create a user with your name, and then solve the following problem under the user.
(a) Match
M a tc h_Id Team1 Team2 Ground Play_Date Winner

(b) Player
P l a ye r _Id Lname Fname Country Yborn Bplace Ftest

(c) Bowling
Match_Id Player_Id Novers Maidens Nrun_rcv Nwickets

(d) Batting
Match_Id Player_Id Nrun_sc

2. Add the following constraints


 BOWLING(Match_Id) references MATCH(Match_Id)
 BOWLING (Player_Id) references PLAYER(Player_Id)
 BATTING(Match_Id) references MATCH(Match_Id)
 BATTING (Player_Id) references PLAYER(Player_Id)

3. Insert the following data


(a)Data for Match table
Match_Id Team1 Team2 Ground Play_Date Winner
2475 Austrilia India Melbourn 10-FEB-08 Team2
2576 India Srilanka Adeliaide 19-FEB-08 Team1
2677 Austrilia India Sydney 02-MAR-08 Team1
2778 Austrilia Srilanka Brisbane 04-MAR-08 Team2
2879 Srilanka India Colombo 27-AUG-08 Team2

(b)Data for Player table


Player_Id Lname Fname Country Yborn Bplace Ftest

49001 Tendulkar Sachin India 1973 Mumbai 1986


49002 Dravid Rahul India 1973 Indore 1996
59001 Vass Chaminda Srilanka 1974 Mattumagala 1994
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-2022]

59002 Jayasuriya Sanath Srilanka 1969 Matara 1991


69001 Lee Brett Austrilia 1976 Wollongong 1999
69002 Symonds Andrew Austrilia 1975 Birminghum 2004

(c)Data for Bowling table


Match_Id Player_Id Novers Maidens Nrun_rcv Nwickets

2576 59001 8 3 58 1
2677 69001 10 1 27 3
2879 49002 7 0 44 0
2576 49001 3 2 15 1
2778 59001 7 1 20 5

(d) Data for Batting table


Match_Id Player_Id Nrun_sc

2677 49001 60
2778 59002 71
2879 59001 60
2778 69002 17
2879 59002 45
2576 49001 36
2475 49002 72

1.
a) Find the ground of the matches batted by player whose Fname is starting from ‘S’.
b) Find Id’s of player that have bowled in the match 2576 but not have batted.
c) Find the batting average of each Indian player along with the Player_Id
d) Find the name of that player who has bowled highest number of overs and also find the
ground where he has bowled.

2.
a) Find the total run scored by a player who played First Test in 1991.
b) Find the name and the number of wickets taken by the youngest player in the data base.
c) Find the names of the players who batted in only one match.
d) Find the name of the player who has taken the highest wickets in a particular match and
also find the ground where the player has taken the wickets.
3.
a) Find the ground where Sachin Tendulkar has scored his highest run.
b) Find out the name of a Srilankan bowler who has delivered at least 2 maiden overs.
c) Find the Number of wickets of that player whose Birth place in Mattumagala.
d) Find the names of the players who played in more than one matches.

Last Date of Submission: 27/10/2021


BRAINWARE UNIVERSITY

[PCC-CS591] [2021-2022]

Assignment-IV
PCC-CS591
Database Management System Lab

A) Table Name : Member

COLUMN NAME DATA TYPE DESCRIPTION


Member_Id Number(5) Unique Member ID
Member_Name Varchar2(30) Name of the Library member
Member_address Varchar2(50) Address of the member
Acc_Open_Date Date Date of membership
Membership_type Varchar2(20) Type of the membership such as ‘Lifetime’,’
Annual’, ‘Half Yearly’,’ Quarterly’
Fees_paid Number(4) Membership fees paid
Max_Books_Allowed Number(2) Total Number of books that can be issued to the
member.
Penalty_Amount Number(7,2) Penalty amount due

CONSTRAINT:
a. Member_Id – Primary Key
b. Member_Name – NOT NULL
c. Membership_type - ‘Lifetime’,’ Annual’, ‘Half Yearly’,’ Quarterly’
d. Max_books_allowed <7
e. Penalty_amt maximum 1000

B) Table Name : BOOKS

COLUMN NAME DATA TYPE DESCRIPTION


Book_No Number(6) Book identification number
Book_Name VarChar2(30) Name of the book
Author_name Varchar2(30) Author of the book
Cost Number(7,2) Cost of the book
Category Char(10) Category like Science , Fiction etc.

CONSTRAINT:

a. Book_No – Primary Key


b. Book_Name – Not Null
c. Category – Science, Database, System, Others.

C) Table Name : ISSUE

COLUMN NAME DATA TYPE DESCRIPTION


Lib_Issue_Id Number(10) Library Book Issue No

Suprativ Saha
Asst. Prof., Dept. of CSE, BWU
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-2022]

Book_No Number(6) The ID of book, which is issued


Member_Id Number(5) Member that issued the book
Issue_Date Date Date of Issue
Return_date Date Return date

CONSTRAINT:

a. Lib_Issue_Id -Primary key


b. Book_No - foreign key
c. Member_id - foreign key

1. Insert the following data to the appropriate table using SQL command.
A) Table Name : Member

MEMB MEMBER_NA MEMBER_ ACC_OPEN MEMBERSH FEES_ MAX_BOOKS_ PENALTY_


ER_ID ME ADDRESS _DATE IP_TYPE PAID ALLOWED AMOUNT
1 Sayantan Sinha Pune 10-Dec-10 Lifetime 2000 6 50
2 Abhirup Sarkar Kolkata 19-jan-11 Annual 1400 3 0
3 Ritesh Bhuniya Gujarat 20-feb-11 Quarterly 350 2 100
4 Paresh sen Tripura 21-mar-11 Half yearly 700 1 200
5 Sohini Haldar Birbhum 11-apr-11 Lifetime 2000 6 10
6 Suparna Biswas Kolkata 12-apr-11 Half Yearly 700 1 0
7 Suranjana Basu Purulia 30-june-11 Annual 1400 3 50
8 Arpita Roy Kolkata 31-july-11 Half yearly 700 1 0

B) Table Name : BOOKS

BOOK_NO BOOK_NAME AUTHOR_NAME COST CATEGORY


101 Let us C Denis Ritchie 450 Others
102 Oracle – Complete Ref Loni 550 Database
103 Visual Basic 10 BPB 700 Others
104 Mastering SQL Loni 450 Database
105 PL SQL-Ref Scott Urman 750 Database
106 UNIX Sumitava Das 300 System
107 Optics Ghatak 600 Science
108 Data Structure G.S. Baluja 350 Others

C) Table Name : ISSUE


LIB_ISSUE_ID BOOK_NO MEMBER_ID ISSUE_DATE RETURN_DATE
7001 101 1 10-jan-11 10-jan-11
7002 102 2 25-jan-11 29-jan-11
7003 104 1 1-Feb-11 15-Mar-11
7004 104 2 15-Mar-11 04-Apr-11
7005 101 4 04-Apr-11 04-Apr-11
7006 108 5 12-apr-11 1-Aug-11
7007 101 8 1-Aug-11 1-Aug-11

Suprativ Saha
Asst. Prof., Dept. of CSE, BWU
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-2022]

Part-I
1. Retrieve the Name of Book and Cost who has Maximum cost.
2. Calculate the Minimum cost, Average cost and Total cost value in BOOKS table and
Rename the resulting attributes.
3. Retrieve the Name and ID of Members who’s issued book between 26th January 2011
and 14th April 2011.
4. Retrieve Book Name, Author Name and Category whose Category is not ‘OTHERS’.
5. Retrieve the Book name and Author Name where 5th letter of the Author name is ’t’.
6. How many Books are available whose Cost is greater than 350.
7. How many different Authors name are available in BOOKS table.
8. Calculate the following Numeric functions:
a. What is the absolute value of -167.
b. Calculate 8^6.
c. Round up to 2 decimal points (134.56789).
d. What is the square root of 144
e. Floor and Ceil value of 13.15.
9. Extract Year, Month, Day from System Date.
10. What is the greatest value between 4, 5 and 17.
11. What is the Least value between '4', '5' and '17' and Express why resulting value of last
two queries are same.
12. Extract 4 letters from 3th position of this word 'INFOSYS'.
13. What is the ASCII value of 'a' and 'S'.
14. What is Length of this word 'INFOSYS' AND change 'S' with 'T'.
15. Retrieve the Names and Address of the Members who belong to Kolkata.
16. Retrieve the Name of Books, where Cost prices are between 300 and 500.
17. List the Name of the Members whose Membership type is “HALF YEARLY”.
18. List the Name of the Members who open their account in the year of 2011.
19. Retrieve the Penalty Amount of the Members who has taken the book “LET US C”.
Suprativ Saha
Asst. Prof., Dept. of CSE, BWU
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-2022]

20. Retrieve the no of Max books allowed to a Member, who has issued books on January.
21. Give the Names of the Members who have not issued any books.
22. Give the Name and Category of the books whose cost is not recorded.
23. List all the books that are written by Author ‘’Loni’’ and has Price less than 600.
24. List the Issue details for the Books that are not returned yet.
25. List all the Books that belong to any one of the following categories Science, Database.

26. List all the Members in the descending order of Penalty due on them.
27. List all the Books in ascending order of category and descending order of price.
28. List all the Books that contain word ‘SQL’ in the Name of the Book.
29. List all the Members whose Name starts with S.
30. List all the Members whose Name starts with S or A and contains letter T in it.
31. List the Entire Book name in INIT CAP and Author Name in UPPER case in the
descending order of the Book Name.
32. List the data in the book table with category data displayed as ‘D’ for Database, ‘S’ for
Science, ‘R’ for RDBMS and ‘O’ for all the others.
33. List all the Members that became the Member in the year 2011.

Suprativ Saha
Asst. Prof., Dept. of CSE, BWU
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-2022]

Part-II

1. List the various CATEGORIES and COUNT OF BOOKS in each category.

2. List the BOOK_NO and the NUMBER OF TIMES the Book is issued in the descending
order of COUNT.

3. Display the MEMBER ID and the NO OF BOOKS for each member that has issued more
than 1 books.

4. Display the MEMBER ID, BOOK NO and NO OF TIMES the same book is issued by the
MEMBER in the descending order of count.

5. Select all information of Book with 2nd Maximum Cost.

6. Copy the MEMBER, BOOKS and ISSUE tables and MEMBER_COPY, BOOKS_COPY,
ISSUE_COPY respectively.

7. Create a table named QUERY1 with two attributes as BOOK_NO, ISSUE_DATE and
copy all information about BOOK_NO and ISSUE_DATE from ISSUE table to QUERY1
table.

8. Create and store BOOK_NAME, AUTHOR_NAME and COST to QUERY2 table where
cost is greater than 300.

9. Insert BOOK_NAME, AUTHOR_NAME and COST to QUERY2 table where cost is less
than 300.

10. ADD an attribute name AVAILABLE with data type NUMBER (5) in the BOOKS_COPY
table and fill up the new attribute with data.

11. Change the Data type of CATEGORY attribute to VARCHAR2 (15) in BOOKS_COPY
table.

Last Date of Submission: 27/10/2021

Suprativ Saha
Asst. Prof., Dept. of CSE, BWU
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-2022]

Assignment-V
PCC-CS591
Database Management System Lab

1. Write a PL/SQL program where check a year leap year or not. Take a year as user input and
check it is leap year or not.
2. Write a PL/SQL program where take a string as input and print the reverse of it.
3. Create a table named CIRCLE with two attributes RADIUS number(3) and AREA
number(10,3), then write a PL/SQL program which can calculate area for every radius up to
10 and insert into the table. (Use while and for loop individually).
4. Write a PL/SQL program which can update cost value of corresponding book number of
the BOOKS_COPY Table.
✓ INPUT: BOOK_NO, NEW COST,
✓ CONDITION: Old cost value will less than 450 and new cost value will less
Than900 otherwise provide an error massage.
5. Take an input of any string and display each word in a separate line
6. Write a PL/SQL program which can update the cost of BOOKS_COPY table with 10 more
cost where cost is less than 500 and show how many rows are affected (Use Implicit Cursor
SQL%ROWCOUNT).
7. Write a PL/SQL program using Explicit Cursor which can display the all information of 5
books from BOOK_COPY table according to the higher cost.
8. Create a PL/SQL Trigger which can fire on MEMBER_COPY table and raise an
application error when delete a row from this table.
9. Create a PL/SQL Trigger which can fire on BOOK_COPY table and raise an application
error when you are going to update cost less than 200 against any book.
10. Create a table named CHANGE with three attribute Book_ID number(5), Change_Date
date, Change_type varchar(10); Then Write a PL/SQL Trigger which can fire on
BOOK_COPY table when you update or delete any particular Book and automatically
insert a row into CHANGE table with the value of changed Book_NO, sysdate and Type of
change (Update/Delete).
11. Write a data base trigger, which acts just like primary key and does not allow Duplicate
values.
12. Write a database trigger which fires if you try to insert, update, or delete after 7’o’ clock.
13. Create a data base trigger, which performs the action of the on delete cascade
14. Write a trigger to enforce the following constraints that “an employee should not get salary
greater than his/her manager.
[15-17 are not mandatory. Interested or Advanced learners may submit.]
15. Assume the following relations
CUSTOMER (SSN, Name, Surname, PhoneNum, Plan)
BRAINWARE UNIVERSITY

[PCC-CS591] [2021-2022]

PRICINGPLAN (Code, ConnectionFee, PricePerSecond )


PHONECALL (SSN, Date, Time, Caladium, Seconds)
BILL (SSN, Month, Year, amount )
i) Write a trigger that after each phone call updates the customer's bill.
ii) Write a trigger that at the end of each month discount the bills by Rs. 10.00 per call
to direct users of the company (that is, to numbers of registered users in the table
CUSTOMER) if the total monthly amount of the bill exceeds Rs. 500.
16. Assume the following relations
Highschooler (ID int, name text, grade int);
Friend (ID1 int, ID2 int);
Likes (ID1 int, ID2 int);
i) Write one or more triggers to maintain symmetry in friend relationships.
Specifically, if (A,B) is deleted from Friend, then (B,A) should be deleted too. If (A,
B) is inserted into Friend then (B, A) should be inserted too. Don't worry about
updates to the Friend table
ii) Write a trigger that automatically deletes students when they graduate, i.e., when
their grade is updated to exceed 12. In addition, write a trigger so when a student is
moved ahead one grade, then so are all of his or her friends.
iii) Write a trigger to enforce the following behavior: If A liked B but is updated to A
liking C instead, and B and C were friends, make B and C no longer friends. Don't
forget to delete the friendship in both directions, and make sure the trigger only runs
when the "liked" (ID2) person is changed but the "liking" (ID1) person is not
changed.

Last Date of Submission: 25/12/2021

You might also like