Sunteți pe pagina 1din 9

DBMS LAB QUESTIONS

1. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign
key constraints: Product (Prodid, Prodesc, Price, Stock)
Purchase (Purid, Proid, qty, supname)
Sales (Saleid, Proid, qty, custname)
a. Update the Stock of all products by 10.
b. Display products whose stock is <15 and order it by stock.
c. Display list of product details (Prodid, Prodesc, Price)
supplied by a particular supplier(ABC).
d. Product ids and Sum of quantity purchased
e. Product details (Prodid, Prodesc, Price) of products which are purchased as well as sold.
f. Create a procedure which accepts a prodid and displays all the sales and purchase records of it.
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Queries (a-e) (10 x 5 =50) marks
Procedure (f) (20) marks

2. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Product (Prodid, Prodesc, Price, Stock)
Purchase (Purid, Proid, qty)
a. Add a column customer name in Purchase table.
b. Productids which are not at all purchased.
List of product details (Prodid, Prodesc, Price) purchased by a particular customer. (MATHEW).
c. The number of customers who made the purchases
d. List of the productids and total quantity purchased
e. Product ids of the products which are purchased more than 5 times
f. Create a procedure to print the Prodid and qty when the Purid is given as the parameter.
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Queries (a-e) (10 x 5 =50) marks
Procedure (f) (20) marks

3. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Age, phno)
Loan (Loanid, Amount, Custid, Emi)
a. Customerids who have not taken Loan
b. Loan details (Loanid, Amount, Custid ) of Loan taken by a particular customer(JOHN)
c. The Total number of Loans aviailed
d. List of the customerids and total Loan amount taken
e. Customer ids who have taken less than 2 Loans
f. Create a procedure to print the Amount and Custid when the Loanid is given as the parameter.
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Queries (a-e) (10 x 5 =50) marks
Procedure (f) (20) marks
4. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Age, phno)
HLoan (HLoanid, Amount, Custid)
VLoan (VLoanid, Amount, Custid)
a. Update the HLoan amount by reducing 5000 rupees which is a special discount offer.
b. Number of VLoan taken by a particular customer id.
c. Customer details (Custid, Custname, Age, phno) who have taken HLoan
d. List of the customerids and total VLoan amount taken
e. Customer details (Custid, Custname, Age, phno) who have taken both Hloan and VLoan
f. Create a procedure to print the Amount and HLoanid when the Custid is given as the parameter.
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Queries (a-e) (10 x 5 =50) marks
Procedure (f) (20) marks

5. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Addr, phno,panno)
Loan (Loanid, Amount, Interest,Custid)
Account (Accd, Accbal, Custid)
a. Add a column CUSDOB in customer table.
b. Select the customers whose name ends with SINGH and order by custid
c. Display the customerids and sum of his account balances
d. Display the accounts of customerids C01,C02,C03
e. Select the customername,id of customers whose number of accounts is greater than
f. Create a procedure to print the Loan details when Customer name is given as the parameter.
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Queries (a-e) (10 x 5 =50) marks
Procedure (f) (20) marks

6. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Product (Prodid, Prodesc, Price, Stock)
Purchase (Purid, Proid, qty, supname)
Sales (Saleid, Proid, qty, custname)
a. Display supname when a particular product id is given (DAL23).
b. List of names who are both supplier as well as customer.
c. Create a Trigger which reduces the stock of Product that is been inserted in sales and update the
stock when purchase is made
d. Create a view which displays Product ids and sum of quantity in sales.
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (10) marks
Queries (b-d) (20 x 3 =60) marks
7. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Product (Prodid, Prodesc, Price, Stock,Reord)
Sales (Salesid, Proid, qty)
a. Display Prodesc of products of particular Sales(SA234).
b. Display the amount (price * qty) of Products in each Sales.
c. Create a Trigger which reduces the stock of Product that is been inserted in sales and print if it is
out of stock (stock <Reord)
d. Create a view which displays Proid, Prodesc and sum of quantity in sales.
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (10) marks
Queries (b-d) (20 x 3 =60) marks

8. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Age, phno)
Loan (Loanid, Amount, Custid, Emi)
a. Display the total Emi that need to be paid by customer with a particular Custname(LEENA)
b. Add a column nol and update the column values with sum of Loans taken by him
c. Create a Trigger which updates the nol value on insertion and deletion of Loan for a customer.
d. Create a View with Custname and sum of Loan Amount

Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (10) marks
Queries (b-d) (20 x 3 =60) marks

9. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Age, phno)
HLoan (HLoanid, Amount, Custid)
VLoan (VLoanid, Amount, Custid)
a. Display Custname name with both HLoan and VLoan
b. List of the customerids and total VLoan amount taken
c. Create a Trigger which displays the HLoan details when values in HLoan is inserted, do the same
for VLoan also.
d. Create a view with Custid and Custname with sum of Loan Amount(both HLoan and VLoan)
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (10) marks
Queries (b-d) (20 x 3 =60) marks
10. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Addr, phno,panno)
Loan (Loanid, Amount, Interest, Custid)
Account (Accd, Accbal, Custid)
a. Display the sum of Accbal of a Particular Custname(LEENA)
b. Update the interest with 1% when Accbal of the Custid >50% of Loan Amount
c. Create a Trigger which checks whether the Accbal is 25% of amount to be inserted in Loan
d. Create a View with Accbal and Loan Amount of all Cutomers
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (10) marks
Queries (b-d) (20 x 3 =60) marks

11. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Addr, phno,panno)
Loan (Loanid, Amount, Interest, Custid)
Account (Accd, Accbal, Custid)
a. Display the Custname having both Loan and Account
b. Create an user defined function getBal which returns the Sum of Accbal of a particular Custid
passed as parameter
c. Create a procedure which prints the Customer details whose sum of Accbal >10000 using getBal
function created by user above (in b)
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (20) marks
Function (b) (25) marks
Procedure (c) (25) marks

12. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Addr, phno,panno)
Loan (Loanid, Amount, Interest, Custid, PrincipalPaid)
Account (Accd, Accbal, Custid)
a. Display the Custname doesnt hold any Account nor taken any Loan
b. Create an user defined function getBalance which returns the Balance Principal Loan Amount
Pending for a Particular Custid passed as parameter
c. Create a procedure which prints the Customer details whose have Balance Principal Loan Amount
Pending >0 using getBalance function created by user above (in b)
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (20) marks
Function (b) (25) marks
Procedure (c) (25) marks
13. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Addr, phno,panno)
Loan (Loanid, Amount, Interest, Custid, LoanDate)
a. Display number of Loans, the sum of Loan Amount of a Particular Custname(LEENA)
b. Create a Report (using Crystal Reports/ Any report generation tool) which displays Loan Taken
between From and To Dates

Marks:
Table creation and Data Insertion (15),Appropriate Constraints and Data Type (15)
Query (a) (20) marks ,Report (b) (50) marks

14. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Product (Prodid, Prodesc, Price, Stock, Reord)
Sales (Salesid, Proid, qty)
a. Display the total amount (price * qty) of Sales made so far
b. Create a Report (using Crystal Reports/ Any report generation tool) when Given with a Proid
generates the list of sales made with sum of quantity sold
Marks:
Table creation and Data Insertion (15) ,Appropriate Constraints and Data Type (15)
Query (a) (20) marks ,Report (b) (50) marks

15. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Addr, phno,panno)
Loan (Loanid, Amount, Interest, Custid, LoanDate)
a. Display number of Total Loan Amount taken on LoanDates and order by Loan Date then by Loan
Amount
b. Create a Form to make a Loan entry (using VB/ VC++/Java).
c. Loan can be entered only for available customer so display available Custid in the Form to Choose
one among them for Loan Entry
Marks:
Table creation and Data Insertion (15) ,Appropriate Constraints and Data Type (15)
Query (a) (20) marks ,Form (b) (40) marks ,Constraint ( c ) (10) marks

16. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Product (Prodid, Prodesc, Price, Stock, Reord)
Sales (Salesid, Proid, qty)
a. Double the Reord value of Products with Price >500 and Reord <50
b. Create a Form to make a Sale entry (using VB/ VC++/Java).
c. Sale can be entered only for available products so display available Prodid in the Form to Choose
one among them for Sale Entry
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (20) marks
Form (b) (40) marks
Constraint ( c ) (10) marks
17. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Product (Prodid, Prodesc, Price, Stock)
Sales (Salesid, Proid, qty)
a. Add a column Reord with a value of 50 for all the products.
b. Create
i. A Product Menu (using VB/ VC++/Java) with options
1. Add
2. Delete
3. Update
ii. A Sale Menu
1. to insert a Sale made
c. Implement Only Add Product menu operation with a Form (with db connectivity)
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (15) marks ,Menu Design (b) (30) marks ,Form (c) (25) marks

18. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Addr, phno)
Loan (Loanid, Amount, Interest, Custid, LoanDate)
a. Add a column nol(number of loans) and set its value calculating it from loan table.
b. Create
i. A Customer Menu (using VB/ VC++/Java) with options
1. Add
2. Delete
3. Update
ii. A Loan Menu
1. to insert Loan details
c. Implement Only Add Customer menu operation with a Form (with db connectivity)
Marks:
Table creation and Data Insertion (15) ,Appropriate Constraints and Data Type (15)
Query (a) (15) marks ,Menu Design (b) (20) marks ,Form (c) (35) marks

19. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Product (Prodid, Prodesc, Price, Stock)
Sales (Salesid, Proid, qty)
a. Add a column Reord with a value of 50 for all the products.
b. Create
i. A Sale Menu (using VB/ VC++/Java) with options
1. to insert a Sale made
2. Sales Report
c. Implement Only Sales Report menu operation listing Sales made so far. (using Crystal Reports/ Any
report generation tool)
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (15) marks
Menu Design (b) (20) marks
Report (c) (35) marks
20. Create Tables as follows by choosing appropriate data type and set the necessary primary and foreign key
constraints:
Customer (Custid, Custname, Addr, phno)
Loan (Loanid, Amount, Interest, Custid, LoanDate)
a. Add a column nol(number of loans) and set its value calculating it from loan table.
b. Create
i. A Loan Menu (using VB/ VC++/Java) with options
1. to insert Loan details
2. Loans Availed Report
c. Implement Only Loans Availed Report menu operation (using Crystal Reports/ Any report
generation tool)
Marks:
Table creation and Data Insertion (15)
Appropriate Constraints and Data Type (15)
Query (a) (15) marks
Menu Design (b) (20) marks
Report (c) (35) marks

1. Consider the following relations for a bus reservation system application: BUS (ROUTENO, SOURCE,
DESTINATION)

PASSENGER (PID, PNAME, DOB, GENDER)

BOOK_TICKET (PID, ROUTENO, JOURNEY_DATE, SEAT_NO)

The primary keys are underlined. Identify the foreign keys.

a. Implement the above schema enforcing primary key and foreign key constraints. (25)

b. Develop forms in for inserting records in the above relations. (35)

c. Develop a SQL query to list the details of passengers who have traveled more than three times on the
same route. (10)

d. Develop a Report that will display the following information: (30)

(For a given route no and journey date)

PID PNAM SEAT


E NO
2. Consider the following relations for a transport management system application: BUS (ROUTENO, SOURCE,
DESTINATION)

DRIVER (DID, DNAME, DOB, GENDER)

ASSIGN_ROUTE (DID, ROUTENO, JOURNEY_DATE)

The primary keys are underlined. Identify the foreign keys.

a. Implement the above schema enforcing primary key and foreign key constraints. (25)

b. Develop forms for inserting records in the above relations. (35)

c. Develop a SQL query to list the details of drivers who have traveled more than three times on the same
route. (10)

d. Develop a Report that will display the following information: (30)

(For a given journey date)

DID DNAME ROUTENO SOURCE DESTINA


TION

3. Consider the following relations for a transport management system application: DRIVER (DCODE,
DNAME, DOB, GENDER)
CITY (CCODE, CNAME)
TRUCK (TRUCKCODE, TTYPE)
TTYPE can take two values (L,H)
L-Light
H- Heavy
Each truck is assigned a unique truck code. There can be many trucks belonging to the same truck type.
DRIVE_TRUCK (TRUCKCODE, DCODE, DOT, CCODE)
DOT Date of Trip
The primary keys are underlined. Identify the foreign keys.

a. Implement the above schema enforcing primary key and foreign key constraints. (25)

b. Develop forms for inserting records in the above relations. (35)

c. Develop a SQL query to list the details of each driver and the number of trips traveled. (10)

d. Develop a Report that will display the following information: (30)

(For a given Date of Trip)

TRUCK CODE TYPE DCODE DNAME


4.Consider the following relational schema for a banking database application: CUSTOMER (CID, CNAME)
BRANCH (BCODE, BNAME)
ACCOUNT (ANO, ATYPE, BALANCE, CID, BCODE)
An account can be a savings account or a current account. Check ATYPE in S or C. A customer can
have both types of accounts.
TRANSACTION (TID, ANO, TTYPE, TDATE, TAMOUNT)
TTYPE CAN BE D OR W
D- Deposit; W Withdrawal
The primary keys are underlined. Identify the foreign keys.

a. Implement the above schema enforcing primary key and foreign key constraints. (25)

b. Develop forms for inserting records in the above relations. (35)

c. Develop a SQL query to list the details of branches where the number of accounts is less than the
average number of accounts in all branches. (10)

d. Develop a Report that will display the following information: (30)

5. Consider the following relational schema for a library management system: BOOK (BOOKID, TITLE,
PUBLISHERCODE, NO_OF_COPIES)
PUBLISHER (PUBLISHERCODE, PUBLISHER_NAME)
AUTHOR (AUTHORID, AUTHOR_NAME)
BOOK_AUTHOR (BOOKID, AUTHORID)
BORROWWER (CARDNO, NAME)
BOOK_LOAN (BOOK_ID, CARDNO, DATEOUT, DUEDATE, STATUS)
Implement a Check Constraint for STATUS (R Returned, T To be returned)
a. Develop DDL to implement the above Schema specifying appropriate data types for each attribute
enforcing primary key, check constraint and foreign key constraints. (25)
b. Populate the database with a rich data set. (10)
c. Develop a SQL query to list the details of authors who have authored more than three books. (5)
d. Develop a SQL query to list the details of borrowers who do not have any books checked out. (10)
e. Develop a SQL query to list the details of borrowers who have more than five books checked out.
(10)
f. Create a view that will keep track of the card number, card holders name and number of books
borrowed (Number of books with status T). (10)
g. Develop a database trigger that will not permit a borrower to borrow a book if there are eight books
borrowed by the borrower with status T (A borrower can borrow a maximum of eight books). (15)
h. Develop a database trigger that will not permit a borrower to borrow a book which he / she have
borrowed and the status of the book is T. (15)

S-ar putea să vă placă și