Dbms Lab Questions
Dbms Lab Questions
The primary keys are underlined. Identify the foreign keys and draw schema diagram
Create the above mentioned tables and populate the tables
Note: Read all questions and populate values accordingly.
a. Include constraint that DOB of passenger should be after 2010
b. Display the passengers who had booked the journey from Bangalore to Chennai on 03- NOV-2014
c. List the details of passengers who have traveled more than three times on the same route.
d. Create a view that displays the RouteNo, source, destination and journey_date whichmoves
from Chennai to Pune.
e. Create an index on PID in passenger table.
Consider the following relations for a boat management application for a beach resort:
SAILOR (SID, NAME, DOB, GENDER)
BOAT (BID, BTYPE, BNAME, COLOR)
BTYPE can take two values (D, S)
D – Deluxe and S –Super Deluxe
SAILS (SID, BID, DOT, SHIFT)
DOT – Date of Trip
SHIFT can take two values – FN or AN
A sailor is assigned a boat on a day. A sailor is permitted to sail the boat for only one shift one
day.
The primary keys are underlined. Identify the foreign keys and draw schema diagram
Create the above mentioned tables and populate the tables
Note: Read all questions and populate values accordingly.
Include constraints for BTYPE and SHIFT as mentioned above
a. Develop a SQL query to list the details of boats whose type is Super Deluxe and Color is Red.
b. Develop a view that will keep track of sailor id, sailor name, date of trip, boat id, boat type, boat name
and shift.
c. Create synonym for sailor table.
Consider the following relational schema for a Product Sales database application:
Product (Prodid, Prodesc, Price, Stock)
Purchase (Purid, Proid, qty, supplierName)
Sales (Saleid, Proid, qty, custname)
The primary keys are underlined. Identify the foreign keys and draw schema diagram
Create the above mentioned tables and populate the tables
Note: Read all questions and populate values accordingly.
a. Include the constraint on Saleid that it starts with letter ‘S’.
b. Display the ProdID and the sum of quantity purchased for each product.
c. Create a view that keeps track of Prodid, price, Purid, qty and customerName who made the
purchase.
d. Create a sequence named Product_Sequence that gets incremented by 10 and use it for
inserting Prodid values in Product table.
Consider the following relational schema for a Books Ordering database application:
Books (isbn, title, author, stock_qty, price, pub_year)
Customers (cust_id, cust_name, address)
Orders (order_no, cust_id, order_date) where cust_id refs Customers(cust_id)
Order_list (order_no, isbn, qty, ship_date) where order_no refs Orders(order_no),
isbn refs Books (isbn)
The primary keys are underlined. Identify the foreign keys and draw schema diagram
Create the above mentioned tables and populate the tables
Note: Read all questions and populate values accordingly.
a. Include the constraint on Cust_id that it starts with letter ‘C’.
b. Display the custid and Custname who have ordered more than 3 books on the same date
c. Display the CustId and CustName who have ordered very few number of books.
d. Create a view that keeps track of books that are ordered on 05-NOV-2014. Display isbn, title,
author, order_no, quantity and order_date.
Consider the following relational schema for Products Order database application:
Products (p_id, p_name, retail_price, qty_on_hand)
Orders (order_id, order_date)
Order_details (order_number, product_number, qty_ordered)
Where: order_number references order_id, product_number references p_id
The primary keys are underlined. Identify the foreign keys and draw schema diagram
Create the above mentioned tables and populate the tables
Note: Read all questions and populate values accordingly.
a. Include the constraint on orderid that it starts with letter ‘O’.
b. Display the ProdID and the sum of quantity ordered for each product.
c. Create a view that keeps track of P_id, price, order_id, qty_ordered and ordered_date.
Consider the insurance database given below.
PERSON(driver_id, name, address)
CAR(regno, model,year )
ACCIDENT(report_number,accd_date,location)
OWNS(driver_id,regno)
PARTICIPATED(driver_id,regno,report_number,damage_amount)
Create the above tables by properly specifying the primary keys and foreign keys and enter at least
five tuples for each relation.
a. Update the damage amount for the car with specific regno in the accident with report number 12 to
25000.
b. Add a new accident to the database.
c. Find the total number of people who owned cars that were involved in accidents in the year 2008
d. Find the number of accidents in which cars belonging to a specific model were involved.
Create the above tables by properly specifying the primary keys and foreign keys and enter at least
five tuples for each relation.
a. List the names of employees whose name contain substring ‘LA’.
b. List the details of employees of salary are greater than or equal to the average salary of employee
table.
c. Create a view which consists of details of all ‘SALESMAN’.
Consider the following database of student enrollment in courses and books adopted forthat
course.
STUDENT(regno, name, major, bdate)
COURSE(courseno, cname, dept)
ENROLL(regno, courseno, sem, marks)
BOOK_ADOPTION(courseno, sem, book_isbn)
TEXT(book_isbn,book_title,publisher, author)
Create the above tables by properly specifying the primary keys and foreign keys
and enter at least five tuples for each relation.
a. Add a new text book to the database and make this book to be adopted by some
department.
b. Produce a list of text books ( includes courseno , book_isbn , book_title ) in the
alphabetical order for courses offered by the 'CS' department that use more than
two books.
c. List any department that has all its books published by a specific publisher.
Create the above tables by properly specifying the primary keys and foreign keys and
enter at least five tuples for each relation.
a. Give the details of the authors who have 2 or more books in the catalog and the price of
the books is greater than the average price of the books in the catalog and the year of
publication is after 2000.
b. Find the author of the book that has maximum sales.
c. Demonstrate how you increase the price of books published by a specific publisher by
10%.
Create the above tables by properly specifying the primary keys and foreign keys and
enter at least five tuples for each relation.
a. Find all the customers who have at least two accounts at the main branch.
b. Find all the customers who have an account at all the branches located in a specific
city.
c. Demonstrate how you delete all account tuples at every branch located in a specific
city.
Create the above tables by properly specifying the primary keys and foreign keys and
enter at least five tuples for each relation.
a. List the employees who joined before 1981.
b. List the total information of employee table along with dname and location of all
employees working under ‘Accounting’ and ‘Research’ in the descending order of
deptno.
Create the above tables by properly specifying the primary keys and foreign keys and
enter at least five tuples for each relation.
a. Display all item name along with the quantity sold.
b. Display item name and price as single column like “<item> price is <price>”
c. Display invoices, customer name and item names together (use join).
d. Find the customers who are not from “Chennai” (use set operator).
Create the above tables by properly specifying the primary keys and foreign keys and
Enter at least five tuples for each relation.
a. List the employees who annual salary is between 22000 and 25000
b. List the employees names along with their manager names.
c. List the dept who employees maximum no of ‘CLERK’s.
Create the above tables by properly specifying the primary keys and foreign keys and
enter at least five tuples for each relation.
a. List the employees whose salary is greater than at least one of the employees of
deptno 30
b. List the name, job, salary of employees in the department with the highest average salary.
c. List the employees who are working either as manager or analyst with salary ranging
from 2000 and 5000.