DBMS Excercise
DBMS Excercise
[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))
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:
[PCC-CS591] [2021-22]
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.
[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.
[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
[PCC-CS591] [2021-2022]
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
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.
[PCC-CS591] [2021-2022]
Assignment-IV
PCC-CS591
Database Management System Lab
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
CONSTRAINT:
Suprativ Saha
Asst. Prof., Dept. of CSE, BWU
BRAINWARE UNIVERSITY
[PCC-CS591] [2021-2022]
CONSTRAINT:
1. Insert the following data to the appropriate table using SQL command.
A) Table Name : Member
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
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.
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.
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]