VTU (VISHVESHWARAYA TECHNOLOGICAL UNIVERSITY)
Computer Science and Engineering 5th Semester DBMS Laboratory
Computer Science and Engineering 5th Semester DBMS Laboratory
(As of now I have uploaded only the schemas)
This blog will be updated to include all types of VTU materials.
Get your QUERY PROCESSOR copy here.
Download the DBMS Lab Notes, Syllabus here.
5th Semester DBMS Lab Notes
Free Download of DBMS Lab Notes here:
All programs have been worked under MySql.
1. Consider the Insurance database given below. The primary keys are
underlined and the data types are specified:
PERSON (driver – id #: String, name: string, address: string)
CAR (regno: string, model: string, year: int)
ACCIDENT (report-number: int, accd-date: date, location: string)
OWNS (driver-id #:string, Regno:string)
PARTICIPATED (driver-id: string, Regno:string, report-number:int,
damage amount:int)
(i) Create the above tables by properly specifying the primary keys and
the foreign keys.
(ii) Enter at least five tuples for each relation.
(iii) Demonstrate how you
a. Update the damage amount to 25000 for the car with a specific
Regno in the ACCIDENT table with report number 12.
b. Add a new accident to the database.
(iv) Find the total number of people who owned cars that were involved in accidents in 2008.
(v) Find the number of accidents in which cars belonging to a specific model were involved.
(vi) Generate suitable reports.
(vii) Create suitable front end for querying and displaying the results.
create table person
(
driverId char(10),
name varchar(20),
address varchar(30),
primary key(driverId)
) ENGINE = INNODB;
create table car
(
regNo char(10),
model char(20),
year date,
primary key(regNo)
) ENGINE = INNODB;
create table accident
(
reportNumber int,
accidentDate date,
location varchar(30),
primary key(reportNumber, accidentDate)
) ENGINE = INNODB;
create table owns
(
driverId char(10),
regNo char(10),
primary key(driverId, regNo),
foreign key(driverId) references person(driverId),
foreign key(regNo) references car(regNo)
) ENGINE = INNODB;
create table participated
(
driverId char(10),
regNo char(10),
reportNumber int,
damageAmount int,
primary key(driverId, regNo, reportNumber),
foreign key(driverId) references person(driverId),
foreign key(regNo) references car(regNo),
foreign key(reportNumber) references accident(reportNumber)
) ENGINE = INNODB;
2. Consider the following relations for an order processing database application in a company:
CUSTOMER (cust #: int , cname: string, city: string)
ORDER (order #: int, odate: date, cust #: int, ord-Amt: int)
ORDER – ITEM (order #: int, item #: int, qty: int)
ITEM (item # : int, unit price: int)
(order #: int, warehouse#: int, ship-date: date)
WAREHOUSE (warehouse #: int, city: string)
(i) Create the above tables by properly specifying the primary keys and the foreign keys.
(ii) Enter at least five tuples for each relation.
(iii) Produce a listing: CUSTNAME, #oforders,
AVG_ORDER_AMT, where the middle column is the total numbers of orders by the customer and the last column is the average order amount for that customer.
(iv) List the order# for orders that were shipped from all the warehouses that the company has in a specific city.
(v) Demonstrate the deletion of an item from the ITEM and demonstrate a method of handling the rows in the ORDER_ITEM table that contain this particular item.
(vi) Generate suitable reports.
(vii) Create suitable front end for querying and displaying the results.
create table customer
(
custId int,
cname varchar(30),
city varchar(20),
primary key (custId)
) ENGINE = INNODB;
create table orderProcessing
(
orderNo int primary key,
odate date,
custId int,
ordAmt int,
foreign key(custId) references customer(custId)
) ENGINE = INNODB;
create table orderItem
(
orderNo int,
itemNo int,
quantity int,
foreign key(orderNo) references orderProcessing(orderNo),
foreign key(itemNo) references item(itemNo)
) ENGINE = INNODB;
create table item
(
itemNo int primary key,
unitPrice int
) ENGINE = INNODB;
create table shipment
(
orderNo int,
warehouseNo int,
shipDate date,
foreign key(orderNo) references orderProcessing(orderNo),
foreign key(warehouseNo) references warehouse(warehouseNo)
) ENGINE = INNODB;
create table warehouse
(
warehouseNo int primary key,
city varchar(20)
) ENGINE = INNODB;
3. Consider the following database of student enrollment in courses & books
adopted for each course:
STUDENT (regno: string, name: string, major: string, bdate:date)
COURSE (course #:int, cname:string, dept:string)
ENROLL ( regno:string, course#:int, sem:int, marks:int)
BOOK _ ADOPTION (course# :int, sem:int, book-ISBN:int)
TEXT (book-ISBN:int, book-title:string, publisher:string,
author:string)
(i) Create the above tables by properly specifying the primary keys
and the foreign keys.
(ii) Enter at least five tuples for each relation.
(iii) Demonstrate how you add a new text book to the database and make this book be adopted by some department.
(iv) Produce a list of text books (include Course #, Book-ISBN,
Book-title) in the alphabetical order for courses offered by the
‘CS’ department that use more than two books.
(v) List any department that has all its adopted books published by
a specific publisher.
(vi) Generate suitable reports.
(vii) Create suitable front end for querying and displaying the
results.
create table student(
regNo char(10) primary key,
name varchar(30) not null,
major char(10),
birthDate date
) ENGINE = INNODB;
create table course(
courseNo int primary key,
cname varchar(20) not null,
dept varchar(20)
) ENGINE = INNODB;
create table enroll(
regNo char(10),
courseNo int,
sem int,
marks int,
primary key(regNo, courseNo, sem),
foreign key(regNo) references student(regNo),
foreign key(courseNo) references course(courseNo)
) ENGINE = INNODB;
create table bookAdoption(
courseNo int,
sem int,
bookISBN int,
primary key(courseNo, sem),
foreign key(bookISBN) references text(bookISBN)
) ENGINE = INNODB;
create table text(
bookISBN int primary key,
bookTitle varchar(30) not null,
publisher varchar(30),
author varchar(30)
) ENGINE = INNODB;

No comments:
Post a Comment