Database Management Systems Laboratory With Mini Project Manual
Database Management Systems Laboratory With Mini Project Manual
Database Management Systems Laboratory With Mini Project Manual
DATABASE
MANAGEMENT
SYSTEMS
LABORATORY WITH
MINI PROJECT
Manual
(Subject Code: 18CSL58)
[As per Choice Based Credit System (CBCS) scheme]
BMS INSTITUTE OF TECHNOLOGY AND
MANAGEMENT
VISION MISSION
To emerge as one of the finest Accomplish a stimulating learning
technical institutions of higher environment through high quality
learning, to develop engineering academic instruction, innovation
professionals who are technically and industry-institute interface.
competent, ethical and environment
friendly for betterment of the society.
ABOUT INSTITUTION
In view of the growing demand for technical education and with the goal of establishing
a premier technical education on par with international standards, a new technical
institution by name 'BMS Institute of Technology and Management' was established in
2002. Currently, BMSIT & M offers eight UG, three PG programs and Ph.D. /M.Sc. (Engg.) in
seven disciplines. BMSIT & M considers research to be of equal importance as
academics for the betterment of an institution. Research culture has been embraced
well by the faculty members and research scholars at BMSIT and M. In this report, we
present an overview of the research activities of Information Science and Engineering,
BMSIT & M.
1
DEPARTMENT OF INFORMATION
SCIENCE AND ENGINEERING
VISION
Emerge as center of learning in the field of information
science & engineering with technical competency to serve
the society.
MISSION
To provide excellent learning environment through
Balanced Curriculum, Best Teaching Methods,
Innovation, Mentoring and Industry Institute Interaction.
2
PROGRAMME EDUCATIONAL OBJECTIVES (PEO’s)
PEO-1: Successful professional career in Information Science and Technology.
PEO-2: Pursue higher studies & research for advancement of knowledge in IT industry
3
PROGRAM SPECIFIC OUTCOMES (PSO’s)
PSO-1: Apply the knowledge of information technology to develop software
solutions.
Lab Instructions 8
Program 1:
Consider the following schema for a Library Database:
BOOK (Bookie, Title, Publisher_Name, Pub_Year)
BOOK_AUTHORS (Book_id, Author_Name)
PUBLISHER (Name, Address, Phone)
BOOK_COPIES (Book_id, Programme_id, No-
of_Copies)
BOOK_LENDING (Book_id, Programme_id, Card_No,
Date_Out, Due_Date)
LIBRARY_PROGRAMME (Programme_id,
Programme_Name, Address)
4
average.
2. Find the name and numbers of all salesman who had more
than one customer.
3. List all the salesman and indicate those who have and don’t
have customers in their cities (Use UNION operation.)
4. Create a view that finds the salesman who has the customer
with the highest order of a day.
5. Demonstrate the DELETE operation by removing salesman
with id 1000. All his orders must also be deleted.
Program 3:
Consider the schema for Movie Database:
ACTOR(Act_id, Act_Name, Act_Gender)
DIRECTOR(Dir_id, Dir_Name, Dir_Phone)
MOVIES(Mov_id, Mov_Title, Mov_Year, Mov_Lang, Dir_id)
MOVIE_CAST(Act_id, Mov_id, Role)
RATING(Mov_id, Rev_Stars)
Write SQL queries to:
1. List the titles of all movies directed by ‘Hitchcock’.
3. 2. Find the movie names where one or more actors acted in 24
two or more movies.
3. List all actors who acted in a movie before 2000 and also in
a movie after 2015 (use JOIN operation).
4. Find the title of movies and number of stars for each
movie that has at least One rating and find the highest
number of stars that movie received. Sort the
result by movie title.
5. Update rating of all movies directed by ‘Steven Spielberg’
to 5.
Program 4:
5
COURSE (Subcode, Title, Sem, Credits)
IAMARKS(USN, Subcode, SSID, Test1, Test2, Test3,
FinalIA)
Write SQL queries to:
1. List all the student details studying in fourth semester ‘C’
section.
2. Compute the total number of male and female students in
each semester and in each section.
3. Create a view of Test1 marks of student USN
‘1BI15CS101’ in all subjects.
4. Calculate the FinalIA (average of best two test marks)
and update the corresponding table for all students.
5. Categorize students based on the following criterion:
If FinalIA = 17 to 20 then CAT = ‘Outstanding’
If FinalIA = 12 to 16 then CAT = ‘Average’
If FinalIA< 12 then CAT = ‘Weak’
Give these details only for 8th semester A, B,
and C section students.
Program 5:
Consider the schema for Company Database:
EMPLOYEE(SSN, Name, Address, Sex, Salary, SuperSSN,
DNo)
DEPARTMENT(DNo, DName, MgrSSN, MgrStartDate)
DLOCATION(DNo,DLoc)
PROJECT(PNo, PName, PLocation, DNo)
WORKS_ON(SSN, PNo, Hours)
Write SQL queries to
5. 1. Make a list of all project numbers for projects that 35
involve an employee whose last name is ‘Scott’, either as
a worker or as a manager of the department that
controls the project.
2. Show the resulting salaries if every employee working on
the ‘IoT’ project is given a 10 percent raise.
3. Find the sum of the salaries of all employees of the
‘Accounts’ Department As well as the maximum salary,
the minimum salary, and
the average salary in this department
4. Retrieve the name of each employee who works on all the
projects controlled by department number 5 (use NOT
EXISTS operator).
5. For each department that has more than five employees,
retrieve the department number and the number of its
employees who are making more than Rs. 6,00,000.
6 Open ended programs 39
6
DBMS LABORATORY WITH MINI PROJECT
(Effective from the academic year 2018 -2019)
SEMESTER – V
Subject Code 18CSL58 IA Marks 40
Number of Lecture 0:2:2 Exam Marks 60
Hours/Week
Total Number of 36 Exam Hours 3
Lecture Hours
7
INTRODUCTION
What is a database?
To find out what database is, we have to start from data, which is the basic building block
of any DBMS.
Data: Facts, figures, statistics etc. having no particular meaning (e.g. 1, ABC, 19 etc).
Record: Collection of related data items, e.g. in the above example the three data items had
no meaning.
But if we organize them in the following way, then they collectively represent meaningful
information.
The columns of this relation are called Fields, Attributes or Domains. The rows
are called Tuples or Records.
T2 Roll Address
1 KOL
2 DEL
3 MUM
8
T3 Roll Year
1 I
2 II
3 I
T4
Year Hostel
I H1
II H2
We now have a collection of 4 tables. They can be called a “related collection” because we can clearly
find out that there are some common attributes existing in a selected pair of tables. Because of these
Common attributes we may combine the data of two or more tables together to find out the complete
Details of a student. Questions like “Which hostel does the youngest student live in?” can be answered
now, although Age and Hostel attributes are in different tables.
In a database, data is organized strictly in row and column format. The rows are called Tuple or
Record. The data items within one row may belong to different data types. On the other hand, the
columns are often called Domain or Attribute. All the data items within a single attribute are of the
same data type.
A management system is a set of rules and procedures which help us to create organize and manipulate
the database. It also helps us to add, modify delete data items in the database. The management system
can be either manual or computerized.
The management system is important because without the existence of some kind of rules and
regulations it is not possible to maintain the database. We have to select the particular attributes which
should be included in a particular table; the common attributes to create relationship between two
tables; if a new record has to be inserted or deleted then which tables should have to be handled etc.
These issues must be resolved by having some kind of rules to follow in order to maintain the integrity
of the database.
9
Three Views of Data
If database is viewed from different angles produces difference sights. Likewise, the database that we
have created already can have different aspects to reveal if seen from different levels of abstraction.
The term Abstraction is very important here. Generally it means the amount of detail you want to hide.
Any Entity can be seen from different perspectives and levels of complexity to make it a reveal its
current amount of abstraction. Let us illustrate by a simple example. A computer reveals the minimum
of its internal details, when seen from outside. We do not know what parts it is built with. This is the
highest level of abstraction, meaning very few details are visible. If we open the computer case and
look inside at the hard disc, motherboard, CD drive, CPU and RAM, we are in middle level of
abstraction. If we move on to open the hard disc and examine its tracks, sectors and read-write heads,
we are at the lowest level of abstraction, where no details are invisible. In the same manner, the
database can also be viewed from different levels of abstraction to reveal different levels of details.
From a bottom-up manner, we may find that there are three levels of abstraction or views in the
database.
The word schema means arrangement – how we want to arrange things that we have to store. The
Diagram above shows the three different schemas used in DBMS, seen from different levels of
Abstraction.
The lowest level, called the Internal or Physical schema, deals with the description of how raw data
Items (like 1, ABC, KOL, H2 etc.) are stored in the physical storage (Hard Disc, CD, Tape Drive etc.).
It also describes the data type of these data items, the size of the items in the storage media, the location
(Physical address) of the items in the storage device and so on. This schema is useful for database
Application developers and database administrator.
The middle level is known as the Conceptual or Logical Schema, and deals with the structure of the
Entire database. Please note that at this level we are not interested with the raw data items anymore, we
are interested with the structure of the database. This means we want to know the information about the
attributes of each table, the common attributes in different tables that help them to be combined, what
kind of data can be input into these attributes, and so on. Conceptual or Logical schema is very useful
for database administrators whose responsibility is to maintain the entire database.
10
The highest level of abstraction is the External or View Schema. This is targeted for the end users.
Now, an end user does not need to know everything about the structure of the entire database, rather
than the Amount of details he/she needs to work with. We may not want the end user to become
confused with Astounding amount of details by allowing him/her to have a look at the entire database,
or we may also not allow this for the purpose of security, where sensitive information must remain
hidden from unwanted persons. The database administrator may want to create custom made tables,
keeping in mind the specific kind of need for each user. These tables are also known as virtual tables,
because they have no separate physical existence. They are crated dynamically for the users at runtime.
Say for example, in our sample database we have created earlier, we have a special officer whose
responsibility is to keep in touch with the parents of any under aged student living in the hostels. That
officer does not need to know every detail except the Roll, Name, Address and Age. The database
administrator may create a virtual table with only these four attributes, only for the use of this officer.
Data Independence
This brings us to our next topic: data independence. It is the property of the database which tries to
ensure that if we make any change in any level of schema of the database, the schema immediately
above it would require minimal or no need of change.
What does this mean? We know that in a building, each floor stands on the floor below it. If we change
the design of any one floor, e.g. extending the width of a room by demolishing the western wall of that
room, it is likely that the design in the above floors will have to be changed also. As a result, one
change needed in one particular floor would mean continuing to change the design of each floor until
we reach the top floor, with an increase in the time, cost and labour. Would not life be easy if the
change could be contained in one floor only? Data independence is the answer for this. It removes the
need for additional amount of work needed in adopting the single change into all the levels above.
1. Physical Data Independence: This means that for any change made in the physical schema, the need
to change the logical schema is minimal. This is practically easier to achieve.
Let us explain with an example. Say, you have bought an Audio CD of a recently released film and one
of your friends has bought an Audio Cassette of the same film. If we consider the physical schema,
they are entirely different. The first is digital recording on an optical media, where random access is
possible. The second one is magnetic recording on a magnetic media, strictly sequential access.
However, how this change is reflected in the logical schema is very interesting. For music tracks, the
logical schema for both the CD and the Cassette is the title card imprinted on their back. We have
information like Track no, Name of the Song, Name of the Artist and Duration of the Track, things
which are identical for both the CD and the Cassette. We can clearly say that we have achieved the
physical data independence here.
2. Logical Data Independence: This means that for any change made in the logical schema, the need to
change the external schema is minimal. As we shall see, this is a little difficult to achieve. Let us
explain with an example.
3. Suppose the CD you have bought contains 6 songs, and some of your friends are interested in
11
copying some of those songs (which they like in the film) into their favorite collection. One friend
wants the songs 1, 2, 4, 5, 6, another wants 1, 3, 4, 5 and another wants 1, 2, 3, 6. Each of these
collections can be compared to a view schema for that friend. Now by some mistake, a scratch has
appeared in the CD and you cannot extract the song 3. Obviously, you will have to ask the friends who
have song 3 in their proposed collection to alter their view by deleting song 3 from their proposed
collection as well.
Database Administrator
The Database Administrator, better known as DBA, is the person (or a group of persons) responsible
for the wellbeing of the database management system. S/he has the flowing functions and
responsibilities regarding database management:
1. Definition of the schema, the architecture of the three levels of the data abstraction, data
independence.
3. Definition of the storage structure i.e. and access method of the data stored i.e. sequential, indexed or
direct.
4. Creating new used-id, password etc, and also creating the access permissions that each user can or
cannot enjoy. DBA is responsible to create user roles, which are collection of the permissions (like
read, write etc.) granted and restricted for a class of users. S/he can also grant additional permissions to
and/or revoke existing permissions from a user if need be.
5. Defining the integrity constraints for the database to ensure that the data entered conform to some
rules, Thereby increasing the reliability of data.
7. Creating backup and recovery policy. This is essential because in case of a failure the database must
be able to revive itself to its complete functionality with no loss of data, as if the failure has never
occurred. It is essential to keep regular backup of the data so that if the system fails then all data up to
the point of failure will be available from a stable storage. Only those amount of data gathered during
the failure would have to be fed to the database to recover it to a healthy status.
12
Advantages and Disadvantages of Database Management System
We must evaluate whether there is any gain in using a DBMS over a situation where we do not use it.
Let us summarize the advantages.
1. Reduction of Redundancy: This is perhaps the most significant advantage of using DBMS.
Redundancy is the problem of storing the same data item in more one place. Redundancy creates
several problems like requiring extra storage space, entering same data more than once during data
insertion, and deleting data from more than one place during deletion. Anomalies may occur in the
database if insertion, deletion etc. are not done properly
2. Sharing of Data: In a paper-based record keeping, data cannot be shared among many users. But in
computerized DBMS, many users can share the same database if they are connected via a network.
3. Data Integrity: We can maintain data integrity by specifying integrity constrains, which are rules and
restrictions about what kind of data may be entered or manipulated within the database. This increases
the reliability of the database as it can be guaranteed that no wrong data can exist within the database at
any point of time.
4. Data security: We can restrict certain people from accessing the database or allow them to see
certain portion of the database while blocking sensitive information. This is not possible very easily in
a paper based record keeping.
However, there could be a few disadvantages of using DBMS. They can be as following:
1. As DBMS needs computers, we have to invest a good amount in acquiring the hardware, software,
installation facilities and training of users.
2. We have to keep regular backups because a failure can occur any time. Taking backup is a lengthy
process and the computer system cannot perform any other job at this time.
3. While data security system is a boon for using DBMS, it must be very robust. If someone can bypass
the security system then the database would become open to any kind of mishandling
13
LAB EXPERIMENTS
PART A: SQL PROGRAMMING
14
create table book_copies(
bookid number(4) references book(bookid) on delete cascade,
branchid number(5) references library(branchid) on delete cascade,
noc number(3),
primary key(bookid,branchid));
15
Queries:
1. select book.bookid,title,pname,aname,noc,branchid from
book,book_copies,book_author where book.bookid=book_author.bookid and
book.bookid=book_copies.bookid order by branchid;
1 53565 1004
1 24564 958
1 77777 7
16
4. CREATE VIEW YEAR AS SELECT pyear FROM BOOK;
select * from book order by(pyear);
17
5. create view dbs as select bookid,title from
book; select * from dbs;
BOOKID TITLE
7 HP-TOOP
1004 HOBBIT
958 FF:BOD
3243 13RW
18
2. Consider the following schema for Order Database:
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)
Write SQL queries to
1. Count the customers with grades above Bangalore’s average.
2. Find the name and numbers of all salesmen who had more than one customer.
3. List all salesmen and indicate those who have and don’t have customers in their cities
(Use UNION operation.)
4. Create a view that finds the salesman who has the customer with the highest order of a day.
5. Demonstrate the DELETE operation by removing salesman with id 1000. All his orders
must also be deleted.
Table Creation;
create table salesman(
sid integer(4) primary key,
sname varchar(10) not null,
city varchar(10) not null,
commission integer(10,2) not null);
Queries:
1. Count the customers with grades above Bangalore’s average.
A; select count(cid) from customer where grade>=(select avg(grade) from customer
where city='bangalore');
Count(cid)
2. Find the name and numbers of all salesmen who had more than one customer.
A; select sname,sid from salesman where sid=any( select sid from customer group by(sid) having
count(sid)>=2);
Sname sid
Clarke 1003
20
3. List all salesmen and indicate those who have and don’t have customers in their cities
(Use UNION operation.)
A; select s.sid,s.sname,s.city from salesman s,customer c where s.city=c.city union select s.sid,
s.sname,'no match' from salesman s where not s.city=any(select city from customer);
21
4. Create a view that finds the salesman who has the customer with the highest order of a
day. A; Create view abcde as select salesman.sid,sname from salesman,orders where
orders.pamt=(select max(pamt) from orders) and orders.sid=salesman.sid;
5. Demonstrate the DELETE operation by removing salesman with id 1000. All his orders
must also be deleted
22
3. Consider the schema for Movie Database:
ACTOR (Act_id, Act_Name, Act_Gender)
DIRECTOR (Dir_id, Dir_Name, Dir_Phone)
MOVIES (Mov_id, Mov_Title, Mov_Year, Mov_Lang, Dir_id)
MOVIE_CAST (Act_id, Mov_id, Role)
RATING (Mov_id, Rev_Stars)
Write SQL queries to
a. List the titles of all movies directed by ‘Hitchcock’.
b. Find the movie names where one or more actors acted in two or more movies.
c. List all actors who acted in a movie before 2000 and also in a movie after
2015 (use JOIN operation).
d. Find the title of movies and number of stars for each movie that has at least
one rating and find the highest number of stars that movie received. Sort the
result by movie title.
e. Update rating of all movies directed by ‘Steven Spielberg’ to 5.
Table Creation;
create table actor(
aid integer(4) primary key,
aname varchar(10),
agender varchar(1));
23
Insertion of Values to Tables;
insert into actor values(1001,'preetham','M');
insert into actor values(1002,'jason','M');
insert into actor values(1003,'tom','M');
insert into actor values(1004,'jenna','f');
insert into actor values(1005,'anna','f');
Queries:
1. List the titles of all movies directed by ‘Hitchcock’.
A; select * from movies,director where director.did=movies.did and dname='hitchcock';
24
2. Find the movie names where one or more actors acted in two or more movies.
A; select title from movies where mid= any (select mid from cast where aid=any
(select aid from cast having count(aid)>1 group by(aid)));
TITLE
super jaws
3. List all actors who acted in a movie before 2000 and also in a movie after 2015 (use
JOIN operation).
ANAME
preetham
4. Find the title of movies and number of stars for each movie that has at least one rating
and find the highest number of stars that movie received. Sort the result by movie title.
A; update rating set rev=5 where mid= any(select mid from movies,director
where movies.did=director.did and dname='steven');
25
26
4. Consider the schema for College Database:
STUDENT (USN, SName, Address, Phone, Gender)
SEMSEC (SSID, Sem, Sec)
CLASS (USN, SSID)
COURSE (Subcode, Title, Sem, Credits)
IAMARKS (USN, Subcode, SSID, Test1, Test2, Test3,
FinalIA) Write SQL queries to
a. List all the student details studying in fourth semester ‘C’ section.
b. Compute the total number of male and female students in each semester and in each
section.
c. Create a view of Test1 marks of student USN ‘1BI15CS101’ in all subjects.
d. Calculate the FinalIA (average of best two test marks) and update the
corresponding table for all students.
e. Categorize students based on the following criterion:
Table Creation :
create table student(usn varchar(10) primary key,
sname varchar(10) not null,
address varchar(10) not null,
phone integer(10),
gender varchar(6) not null);
27
foreign key (ssid) references semsec (ssid),
foreign key (subcode) references subject
(subcode), primary key(usn,subcode,ssid),
test1 integer(2),
test2 integer(2),
test3 integer(2),
finalia integer(2));
Queries:
i. List all the student details studying in fourth semester ‘C’ section.
A; select * from student s,semsec ss,class c where s.usn=c.usn and
c.ssid=ss.ssid and sem=5 and sec='b';
USN SNAME ADDRESS PHONE GENDER SSID SEM SEC USN SSID
28
ii. Compute the total number of male and female students in each semester and
in each section.
A; select count(s.gender) from student s,semsec ss,class c where s.usn=c.usn
and c.ssid=ss.ssid group by sem,sec,gender;
COUNT(S.GENDER)
1
1
1
29
iii. Create a view of Test1 marks of student USN ‘1BI15CS101’ in all subjects.
A; create view test1 as
select test1,subcode from iamarks where
usn='1by15cs02'; View created.
TEST1 SUBCOD
13 15cs51
iv. Calculate the FinalIA (average of best two test marks) and update the
corresponding table for all students.
A; create or replace procedure avgmarks
is cursor c_iamarks is
select greatest(test1,test2) as a,greatest(test1,test3) as b,greatest(test2,test3)
as c from iamarks
where finalia=0 for update;
c_a number;
c_b number;
c_c number;
c_sum number;
c_avg number;
begin
open
c_iamarks;
loop
30
fetch c_iamarks into c_a,c_b,c_c;
exit when c_iamarks%notfound;
dbms_output.put_line(c_a||''||c_b||''||c_c);
if c_a!=c_b then
c_sum:=c_a+c_b;
else
c_sum:=c_a+c_c;
end if;
c_avg:=c_sum/2;
dbms_output.put_line('sum is'||c_sum);
dbms_output.put_line('average is'||c_avg);
update iamarks set finalia=c_avg
where current of
c_iamarks;
end loop;
close
c_iamarks; end;
/
To run the
procedure begin
avgmarks();
end;
/
1by16cs417 15cs52 5a 12 0 15 0
1by15cs02 15cs51 5b 13 14 0 0
1by15cs075 15cs53 3a 15 15 15 0
31
v.Categorize students based on the following criterion: If
FinalIA = 17 to 20 then CAT = ‘Outstanding’
If FinalIA = 12 to 16 then CAT = ‘Average’
If FinalIA< 12 then CAT = ‘Weak’
Give these details only for 8th semester A, B, and C section students.
32
j. end) as catagory
k. from student,semsec,iamarks,subject where
student.usn=iamarks.usn and semsec.ssid=iamarks.ssid and
subject.subcode=iamarks.subcode and subject.sem=8;
33
5. Consider the schema for Company Database:
EMPLOYEE (SSN, Name, Address, Sex, Salary, SuperSSN, DNo)
DEPARTMENT (DNo, DName, MgrSSN, MgrStartDate)
DLOCATION (DNo,DLoc)
PROJECT (PNo, PName, PLocation, DNo)
WORKS_ON (SSN, PNo, Hours)
Write SQL queries to
1. Make a list of all project numbers for projects that involve an employee whose last
name is ‘Scott’, either as a worker or as a manager of the department that controls the
project.
2. Show the resulting salaries if every employee working on the ‘IoT’ project is given
a 10 percent raise.
3. Find the sum of the salaries of all employees of the ‘Accounts’ department, as well as
the maximum salary, the minimum salary, and the average salary in this department
4. Retrieve the name of each employee who works on all the projects controlled by
department number 5 (use NOT EXISTS operator). For each department that has more
than five employees, retrieve the department number and the number of its employees
who are making more than Rs. 6,00,000.
Table Creation;
34
dno varchar(10) references department (dno));
create table workson (noh integer (2),
ssn varchar(10) references employee (ssn),
pno integer(4) references project(pno),
primary key (ssn, pno));
Note: update entries of employee table to fill missing fields SUPERSSN and DNO
➔ Update employee set dno=101 where ssn=4000;
➔ Update employee set dno=102 where ssn=4010;
Queries:
1. Make a list of all project numbers for projects that involve an employee whose last
name is ‘Scott’, either as a worker or as a manager of the department that controls the
project.
35
pno
900
901
902
2. Show the resulting salaries if every employee working on the ‘IoT’ project is given
a 10 percent raise.
name inc_sal
kumar 880000
raj 750000
3. Find the sum of the salaries of all employees of the ‘Accounts’ department, as well as
the maximum salary, the minimum salary, and the average salary in this department
36
sum(salary) max(salary) min(salary) avg(salary)
4. Retrieve the name of each employee who works on all the projects Controlled by
department number 5 (use NOT EXISTS operator).
A; select fname from employee where not exists(select pno from project where dno=’d3’
minus select pno from workson where employee.ssn=workson.ssn);
no rows selected;
5. For each department that has more than five employees, retrieve the
department number and the number of its employees who are making more
than Rs. 6, 00,000.
A; select dno, count (*) from employee where dno in(select dno from employee having
count(*)>5 group by((dno)) and salary>1000 group by(dno);
No rows selected;
37
OPEN ENDED PROGRAMS
1. Consider the insurance database given below. The primary keys are made bold 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)
1) Create the above tables by properly specifying the primary keys and foreign keys.
2) Enter at least five tuples for each relation.
3) Demonstrate how you: 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.
4) Find the total number of people who owned cars that were involved in accidents in the year 2008.
5) Find the number of accidents in which cars belonging to a specific model were involved.
2. Consider the following relations for an order processing database application in a company.
CUSTOMER( custno:int , cname:string , city:string )
ORDER( orderno:int , odate:date , custno:int , ord_amt:int )
ORDER_ITEM( orderno:int , itemno:int , quantity:int )
ITEM( itemno:int , unitprice:int )
SHIPMENT( orderno:int , warehouseno:int , ship_date:date )
WAREHOUSE( warehouseno:int , city:string )
1) Create the above tables by properly specifying the primary keys and foreign keys.
2) Enter at least five tuples for each relation.
3) Produce a listing: custname, No_of_orders, Avg_order_amount, where the middle column is the total
number of orders by the customer and the last column is the average order amount for that customer.
4) List the orderno for orders that were shipped from all the warehouses that the company has in a
specific city.
5) Demonstrate the deletion of an item from the ITEM table and demonstrate a method of handling the
rows in the ORDER_ITEM table that contains this particular item.
38
Viva Questions
1. What is SQL?
Structured Query Language
2. What is database?
A database is a logically coherent collection of data with some inherent meaning, representing
some aspect of real world and which is designed, built and populated with data for a specific
purpose.
3. What is DBMS?
It is a collection of programs that enables user to create and maintain a database. In other words
it is general-purpose software that provides the users with the processes of defining,
constructing and manipulating the database for various applications.
5. Advantages of DBMS?
➢ Redundancy is controlled.
➢ Unauthorized access is restricted.
➢ Providing multiple user interfaces.
➢ Enforcing integrity constraints.
➢ Providing backup and recovery.
39
10. What is Data Independence?
Data independence means that “the application is independent of the storage structure and access
strategy of data”. In other words, the ability to modify the schema definition in one level should not
affect the schema definition in the next higher level.
Two types of Data Independence:
➢ Physical Data Independence: Modification in physical level should not affect the logical level.
➢ Logical Data Independence: Modification in logical level should affect the view level.
41
BMS INSTITUTE OF TECHNOLOGY AND MANAGEMENT
YELAHANKA – BANGALORE - 64
DEPARTMENT OF INFORMATION SCIENCE & ENGINEERING
Rubrics used for Continuous Evaluation in every lab session (Record: 10M)
Allocated
Parameter LOW MEDIUM HIGH
Marks
05 The given program was The given The given
Execution not code/debug/execute in program was coded program was coded,
the lab session & debugged but not debugged and
executed in the lab executed in the lab
session session
0 marks 1 -3 mark 4-5marks
Viva-voce 02 The student did not The student The student
answered any viva answered few viva answered all viva
questions asked questions asked questions asked
0 marks 1 marks 2 marks
Record 03 The record was not The record was Completed record
writing submitted in the lab session submitted in the lab was submitted in the
session but was lab session
incomplete (no
Algorithm / wrong
Algorithm & no
Flowchart / wrong
Flowchart )
42
Viva- 02 The student did not The student answered The student answered
voce answered any viva few viva questions asked all viva questions asked
questions asked
0mark 1 mark 2 marks
Every program is evaluated for 10 Marks and average of all programs for 10 marks will be calculated. The
final average is converted to 5 Marks.
1. 1stcycle test: Mid semester after completion of 50% of university specified experiment.
2. 2ndcycle test: End of semester after completion of all the university specified experiment
In each cycle test the student pick a program from the pool and execute that program. The student should
answer the Viva-voce asked. The marks are awarded for each lab internals based on rubrics defined in table
2.11 average marks of both the Internal test is considered for awarding final internal assessment marks.
Rubrics used for Lab Internal Test
43
Project and 03 The Student not The Student specifies The student specifies
Finance specified the work work schedule but not clearly about work
Management schedule and budget or vice versa schedule and budget
budget of project
0marks 1 mark 2 -3 marks
Report with 03 Report was The report was well The report was well
Unplagarised submitted and organized and organized and
content Plagiarism is more submitted. plagiarism submitted. plagiarism
(Ethics) than 35% content is between 25% content is less than 25%
to 35%
44