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

2 Commands Sqlite

The document describes two SQL schema - one for a customer, shipment, truck, and city database and another for a company, student, interview, and offer database. It provides the schema definitions including any constraints and then lists a number of queries to run on each database to return specific data.

Uploaded by

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

2 Commands Sqlite

The document describes two SQL schema - one for a customer, shipment, truck, and city database and another for a company, student, interview, and offer database. It provides the schema definitions including any constraints and then lists a number of queries to run on each database to return specific data.

Uploaded by

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

1) Using python and “sqlite” implement the following,

Write the SQL Commands to create a database for the following relational
schema:
Customer (Cust-Id, Cust-Name, Annual-Revenue, Cust-Type)
Note - Cust-Id must be between 100 and 10,000
Annual-Revenue defaults to 20,000
Cust-type must be "manufacturer", "wholesaler" or "retailer"

Shipment (ShipmentNo, CustId, Weight, TruckNo, Destination, Ship-Date)


Note - CustId references customer, TruckNo references Truck and on deletion
set to NULL, Destination References City.
Weight must be under 1000 and defaults to 10

Truck (TruckNo, DriverName)

City (CityName, Population)


Cust-type must be "delhi" or "mumbai" or "kolkata" or "chennai" or "srinagar"
or "hyderabad"

a) Create the database, described above and insert sufficient data in all the relations

b) Express the following queries in SQL


1) List cities that have not received any shipment.

2) List Truck ids that have sent shipment to every city

3) For each customer, what is the average weight of a package sent by that
customer.
4) For each city, what is the maximum weight of a package sent to that city?

5) Give names of customers who have sent packages (shipments) to


Hyderabad, Chennai and Mumbai.

6) List the name and annual revenue of customers whose shipments have been
delivered by truck driver named 'Ramesh'.

7) For each city, with population over 50,000 what is the minimum weight of
a package sent to that city?

8) For those truck numbers, which have taken part in more than 3 shipments, list
the truck numbers, driver names, and the average weight of the shipments.

9) Find those cities having population more than that of the


population of "chennai".

2) Using python and “sqlite” implement the following,


1) Consider the following schema,
COMPANY(CNAME, CLOCATION)
STUDENT(ROLLNO, NAME, DEGREE)
INTERVIEW(CNAME, ROLLNO, INTDATE)
OFFER(CNAME, ROLLNO, SALARY)

Note - SALARY must be between 10000 and 20,000 and defaults to 15000

DEGREE must be "MSCIT" or "MSCCS" or "MSCPH" or "MSCMH"

1) Create the database, described above and insert sufficient data in


all the relations.
(Assume suitable primary key and foreign key constraints)

2) List the roll numbers and names of those students, who attended
at least one interview but did not receive any job offers.

3) List the roll numbers of those students, who received offers from
all companies.

4) List the name and roll numbers of students who did not appear
for any interview.

5) For each department, find the average salary offered to the students
of that department.

6) List the roll numbers and names of those students, who got
offers from all the companies in which they appeared for interview.

7) List for each degree, in which more than five students were offered
jobs, the name of the degree and the average offered salary of the
students in this degree programme.

8) List the name and roll number of students, who received maximum
number of job offers.(The result may be the same as the result of query 3
if a student(s) has received offered from all the companies)

You might also like