0% found this document useful (0 votes)
8 views2 pages

E

This document outlines four different database design scenarios involving sales, library, and college databases. For each scenario, it provides the entity-relationship schema and asks to design the database tables with constraints, insert sample data, and write SQL queries to retrieve or manipulate data. Some example queries include counting customers by grade, finding salesmen with multiple customers, retrieving book details and available copies, and calculating student marks.

Uploaded by

leemong335
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

E

This document outlines four different database design scenarios involving sales, library, and college databases. For each scenario, it provides the entity-relationship schema and asks to design the database tables with constraints, insert sample data, and write SQL queries to retrieve or manipulate data. Some example queries include counting customers by grade, finding salesmen with multiple customers, retrieving book details and available copies, and calculating student marks.

Uploaded by

leemong335
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

II. Design an ER model for the order database.

Define the relationships based on


the given schema.
SALESMAN (Salesman_id, Name, City, Commission)
CUSTOMER (Customer_id, Cust_Name, City, Grade, Salesman_id)
ORDERS (Ord_No, Purchase_Amt, Ord_Date, Customer_id, Salesman_id)
Create tables based on the above schema, add constraints(PRIMARY KEY, FOREIGN KEY)
and
insert relevant data. Write SQL queries to
a. Count the customers with grades above Bangalore's average.
b. Find the name and numbers of all salesmen who had more than one customer.
c. List all salesmen and indicate those who have and don't have customers in their
cities(Use UNION
operation.)
d. Create a view that finds the salesman who has the customer with the highest
order of a day.
e. Demonstrate the DELETE operation by removing the salesman with id 1000. All his
orders must
also be deleted. (Use Trigger to remove the orders)

III. Design an ER model for the library database. Define the relationships based on
the given
schema.
BOOK (Book_id, Title, Publisher_Name, Pub_Year) BOOK_AUTHORS (Book_id,
Author_Name)
PUBLISHER (Name, Address, Phone)
BOOK_COPIES (Book_id, Branch_id, No-of_Copies)
BOOK_LENDING (Book_id, Branch_id, Card_No, Date_Out, Due_Date)
LIBRARY_BRANCH (Branch_id, Branch_Name, Address)
Create tables based on the above schema, add constraints(PRIMARY KEY, FOREIGN KEY)
and
insert relevant data.
Write SQL queries to
a. Retrieve details of all books in the library - id, title, name of publisher,
authors,
number of copies in each branch, etc.
b. Get the particulars of borrowers who have borrowed more than 3 books, but from
Jan 2021 to Jun
2021
d. Retrieve all books published by an author.
e. Delete a book in the BOOK table. Update the contents of other tables to reflect
this data
manipulation operation. (Use trigger to update the contents of other tables)
f. Create a view of all books and the number of copies that are currently available
in the Library.

IV. Design an ER model for the college database. Define the relationships based on
the given
schema.
STUDENT (USN, SName, Address, Phone, Gender)
SEMSEC (SSID, Sem, Sec)
CLASS (USN, SSID)
SUBJECT (Subcode, Title, Sem, Credits)
IAMARKS (USN, Subcode, SSID, Test1, Test2, Test3, FinalIA)
Create tables based on the above schema, add constraints(PRIMARY KEY, FOREIGN KEY)
and
insert relevant data. Write SQL queries to
a. List all the student details studying in the fourth semester 'C' section.
b. Compute the total number of male and female students in each semester and in
each section.
c. Display semwise student details along with semester and section in ascending
order.
d. Create a view of Test1 marks of students for the given USN in all subjects.
e. Create a procedure to calculate the Final IA (average of 3 internals) of the
given USN and subject
and print the Final IA using out parameter.

You might also like