DBMS and Web MANUAL
DBMS and Web MANUAL
LAB_PROGRAM 1
QUERIES:
1. List the details of Students who are all Studying in 2 nd sem MCA.
2. List the students who are not borrowed any books.
3. Display the USN, Student name, Branch_name, Book_name,
Author_name, Books_Borrowed_Date of 2nd sem MCA Students
who borrowed books.
4. Display the number of books written by each Author.
5. Display the student details who borrowed more than two books.
6. Display the student details who borrowed books of more than one
Author.
7. Display the Book names in descending order of their names.
8. List the details of students who borrowed the books which are all
published by the same publisher.
1MV24MC046 1
DBMS and Web Technologies Laboratory MMCL106
SCHEMA CONSTRUCT:
1MV24MC046 2
DBMS and Web Technologies Laboratory MMCL106
ER DIAGRAM:
BRANCH
create table branch(brid varchar(20) primary key,brname varchar(20),hod
varchar(20));
insert into branch values('MCA1','MCA','Prakash');
insert into branch values('MBA2','MBA','Vivek');
insert into branch values('CIVIL3','Civil','Kishor');
select * from branch;
1MV24MC046 3
DBMS and Web Technologies Laboratory MMCL106
STUDENT
create table student1(usn varchar(20) primary key,stname varchar(20),staddress
varchar(20),brid varchar(20),sem number(3),foreign key(brid) references
branch(brid));
insert into student1 values('1MV46','Punith','Davangere','MCA1',1);
insert into student1 values('1MV47','Malik','Raichur','MCA1',1);
insert into student1 values('1MV48','Praveen','Shimoga','MCA1',2);
insert into student1 values('1MV49','Pavan','Belgum','MBA2',2);
insert into student1 values('1MV50','Rohanth','Mysore','CIVIL3',2);
select * from student;
AUTHOR
create table author(aid varchar(20) primary key,aname varchar(20),country
varchar(20),age number(3));
insert into author values('A101','Dennis Ritchie','usa',56);
insert into author values('A102','Chetan Bhagat','india',49);
insert into author values('A103','Roam Agarwal','usa',59);
select * from author;
1MV24MC046 4
DBMS and Web Technologies Laboratory MMCL106
BOOK
create table book(bookid varchar(20) primary key,bookname varchar(20),authorid
varchar(20),publisher varchar(20),branchid varchar(20),foreign key(branchid)
references branch(brid),foreign key(authorid) references author(aid));
insert into book values('boo1','C','A101','KN','MCA1');
insert into book values('boo2','B programming','A101','KN','MCA1');
insert into book values('boo3','Unix','A101','MK','MCA1');
insert into book values('boo4','Finace','A102','PS','MBA2');
insert into book values('boo5','Civils','A103','KN','CIVIL3');
select * from book;
BORROW
create table borrow(stusn varchar(20),bookid varchar(20),borrowdate
varchar(20),foreign key(bookid) references book(bookid),foreign key(stusn)
references student1(usn));
insert into borrow values('1MV46','boo1','01-02-2025');
insert into borrow values('1MV46','boo2','02-03-2025');
insert into borrow values('1MV46','boo3','03-04-2025');
1MV24MC046 5
DBMS and Web Technologies Laboratory MMCL106
Queries: -
Query 1-> List the details of Students who are all Studying in 2 nd sem MCA.
SQL>
select * from student1 where sem=2 and brid in(select brid from branch where
brname='MCA');
Query 2 -> List the students who are not borrowed any books.
SQL>
select * from student1 where usn not in(select stusn from borrow);
1MV24MC046 6
DBMS and Web Technologies Laboratory MMCL106
SQL>
select distinct s.usn,s.stname,bk.bookname,a.aname,bw.borrowdate,br.brname from
student1 s,book bk,author a,borrow bw,branch br where s.usn=bw.stusn AND
s.brid=br.brid AND bw.bookid=bk.bookid AND bk.authorid=a.aid AND s.sem=1
AND brname='MCA';
SQL>
select authorid,count(*) as no_of_books from book group by authorid;
Query 5 -> Display the student details who borrowed more than two books.
SQL>
select * from student1 where usn in(select stusn from borrow group by stusn
having count(borrow.stusn)>2);
1MV24MC046 7
DBMS and Web Technologies Laboratory MMCL106
Query 6 -> Display the student details who borrowed books of more than one
Author.
SQL>
select * from student1 where usn in(select stusn from borrow bw join book b on
bw.bookid=b.bookid group by stusn having count(b.authorid)>1);
Query 7 -> Display the Book names in descending order of their names.
SQL>
Select bookname from book order by bookname desc;
1MV24MC046 8
DBMS and Web Technologies Laboratory MMCL106
Query 8 -> List the details of students who borrowed the books which are all
published by the same publisher.
SQL>
select * from student1 where usn in(select bw.stusn from borrow bw join book b on
bw.bookid=b.bookid group by bw.stusn having count(b.publisher)=1);
1MV24MC046 9
DBMS and Web Technologies Laboratory MMCL106
LAB_PROGRAM 2
QUERIES:
1MV24MC046 10
DBMS and Web Technologies Laboratory MMCL106
SCHEMA:
ER DIAGRAM:
1MV24MC046 11
DBMS and Web Technologies Laboratory MMCL106
STUDENT
create table student(usn int,name varchar(20),dob date,branch varchar(20),marks1
int,marks2 int,marks3 int,total int,gpa int);
1MV24MC046 12
DBMS and Web Technologies Laboratory MMCL106
Queries: -
Query 1-> Update the column total by adding the columns mark1, mark2,
mark3.
SQL>
Update student set total=marks1+marks2+marks3;
Select * from student;
SQL>
Update student set gpa=round((total/3)/9.5,2);
Select * from student;
1MV24MC046 13
DBMS and Web Technologies Laboratory MMCL106
Query 3 Find the students who born on a particular year of birth from the
date_of_birth column.
SQL>
select * from student where dob='04-08-2003';
Query 4-> List the students who are studying in a particular branch of study.
SQL>
select usn,name,branch from student where branch='MCA';
Query 5-> Find the maximum GPA score of the student branch-wise.
SQL>
select max(gpa),branch from student group by branch;
1MV24MC046 14
DBMS and Web Technologies Laboratory MMCL106
Query 6-> Find the st udents whose name starts with the alphabet
SQL>
select usn,name,branch from student where name like 'S%';
Query 7-> Find the students whose name ends with the alphabets
SQL>
select usn,name,branch from student where name like '%ar';
Query 8-> Delete the student details whose USN is given as 1001
SQL>
delete from student where usn=1001;
1MV24MC046 15
DBMS and Web Technologies Laboratory MMCL106
LAB_PROGRAM 3
Design an ER-diagram for the following scenario, Convert the same into a
relational model and then solve the following queries.
QUERIES:
1. Display the youngest player (in terms of age) Name, Team name ,
age in which he belongs of the tournament.
2. List the details of the stadium where the maximum number of
matches were played.
3. List the details of the player who is not a captain but got the
man_of _match award at least in two matches.
4. Display the Team details who won the maximum matches.
5. Display the team name where all its won matches played in the
same stadium.
1MV24MC046 16
DBMS and Web Technologies Laboratory MMCL106
SCHEMA CONSTRUCT:
TEAM
TID TNAME COACH CAPID CITY
PLAYER
PID PNAME AGE TID
STADIUM
MATCHES
MID MDATE TIME TEAMID1 TEAMID2 WINNERID MOMID STADIUMID
PHONE_NO
1MV24MC046 17
DBMS and Web Technologies Laboratory MMCL106
ER DIAGRAM
TEAM
create table team(tid varchar(20) primary key,tname varchar(20),city
varchar(20),coach varchar(20),capid varchar(20));
1MV24MC046 18
DBMS and Web Technologies Laboratory MMCL106
PLAYER
create table player(pid varchar(20) primary key,pname varchar(20),age int,tid
varchar(20),foreign key(tid) references team(tid));
1MV24MC046 19
DBMS and Web Technologies Laboratory MMCL106
STADIUM
create table stadium(sid varchar(20) primary key,sname varchar(20),pincode
number(6),city varchar(20),area varchar(20));
MATCH
create table match(mid varchar(20) primary key,mdate varchar(20),time
varchar(20),stadiumid varchar(20) references stadium(sid),teamid1 varchar(20)
references team(tid),teamid2 varchar(20) references team(tid),winnerid varchar(20)
references team(tid),momid varchar(20) references player(pid));
insert into match values('m10','14-12-2019','3pm','s1','t001','t002','t001','p019');
insert into match values('m11','16-12-2019','4pm','s1','t003','t004','t004','p049');
1MV24MC046 20
DBMS and Web Technologies Laboratory MMCL106
PLAYERNO
create table playerno(pid varchar(20) references player(pid),phone_number
number(10));
insert into playerno values('p018',9212181221);
insert into playerno values('p019',9112281221);
insert into playerno values('p028',8212183911);
insert into playerno values('p038',9211815671);
insert into playerno values('p048',9212181921);
select * from playerno;
1MV24MC046 21
DBMS and Web Technologies Laboratory MMCL106
Queries: -
Query 1-> Display the youngest player (in terms of age) Name, Team name ,
age in which he belongs of the tournament.
SQL>
select p.pname,t.tname,p.age from team t,player p where t.tid=p.tid and age
in(select min(age) from player);
Query 2-> List the details of the stadium where the maximum number of
matches were played.
SQL>
select * from stadium where sid in(select stadiumid from match group by
stadiumid having count(stadiumid)=(select max(count(stadiumid)) from match
group by stadiumid));
1MV24MC046 22
DBMS and Web Technologies Laboratory MMCL106
Query 3-> List the details of the player who is not a captain but got the
man_of _match award at least in two matches.
SQL>
select * from player where pid in(select momid from match group by momid
having count(momid)>1 and momid not in(select capid from team));
Query 4-> Display the Team details who won the maximum matches.
SQL>
Select * from team where tid in(select winnerid from match group by winnerid
having count(winnerid)=(select max(total) from (select count(winnerid) as total
from match group by winnerid)));
Query 5-> Display the team name where all its won matches played in the
same stadium.
SQL>
select tname from team where tid in(select winnerid from match group by winnerid
having count(distinct stadiumid)=1);
1MV24MC046 23
DBMS and Web Technologies Laboratory MMCL106
LAB_PROGRAM 4
QUERIES:
1. List the details of the candidates who are contesting from more than one
constituencies which are belongs to different states.
2. Display the state name having maximum number of constituencies.
3. Create a stored procedure to insert the tuple into the voter table by
checking the voter age. If voter’s age is at least 18 years old, then insert
the tuple into the voter else display the “Not an eligible voter msg”.
4. Create a stored procedure to display the number_of_voters in the
specified constituency. Where the constituency name is passed as an
argument to the stored procedure.
5. Create a TRIGGER to UPDATE the count of “ number_of_voters” of
the respective constituency in “CONSTITUENCY” table , AFTER
inserting a tuple into the “VOTERS” table.
1MV24MC046 24
DBMS and Web Technologies Laboratory MMCL106
SCHEMA :
CONSTITUENCY
VOTER
VID NAME AGE ADDRESS CDID
PARTY
PID PNAME PSYMBOL
CANDIDATE
CDID NAME PHONE AGE STATE PID
1MV24MC046 25
DBMS and Web Technologies Laboratory MMCL106
ER DIAGRAM
1MV24MC046 26
DBMS and Web Technologies Laboratory MMCL106
PARTY
create table party(pid varchar(20) primary key, pname varchar(20), psymbol
varchar(20));
insert into party values('p101','bjp','lotus');
insert into party values('p102','congress','hand');
insert into party values('p103','jds','farmer');
select * from party;
CANDIDATE
create table candidate(cid varchar(20) primary key,name varchar(20),phone
varchar(20),age number(3),state varchar(20),pid varchar(20) references party(pid));
1MV24MC046 27
DBMS and Web Technologies Laboratory MMCL106
CONSTITUENCY
create table constituency(cnid varchar(10) primary key,name varchar(20),state
varchar(20),no_of_voters varchar(20));
insert into constituency values('cnt1','RR nagar','karnataka','1000');
insert into constituency values('cnt2','haveri','karnataka','900');
insert into constituency values('cnt3','davangere','karnataka','600');
insert into constituency values('cnt4','bhuvangiri','telengana','800');
1MV24MC046 28
DBMS and Web Technologies Laboratory MMCL106
CONTEST
create table contest(cnid varchar(20) references constituency(cnid),cid varchar(10)
references candidate(cid));
VOTER
create table voter(vid varchar(20) primary key,name varchar(20),age
number(3),address varchar(20),cnid varchar(30) references constituency(cnid));
1MV24MC046 29
DBMS and Web Technologies Laboratory MMCL106
Query 1 -> List the details of the candidates who are contesting from more
than one constituencies which are belongs to different states.
SQL>
select * from candidate where cid in(select cid from contest, constituency where
contest.cnid=constituency.cnid group by cid having count(distinct(state))>1);
Query 2 -> Display the state name having maximum number of constituencies.
SQL>
select state from constituency group by state having count(state)=(select
max(count(state)) from constituency group by state);
1MV24MC046 30
DBMS and Web Technologies Laboratory MMCL106
Query 3 -> Create a stored procedure to insert the tuple into the voter table by
checking the voter age. If voter’s age is at least 18 years old, then insert the
tuple into the voter else display the “Not an eligible voter msg”.
SQL>
create or replace procedure insertdate(id varchar2, name varchar2, age number,
address varchar2, cnid varchar2)as begin
if age>=18 then insert into voter(vid, name, age, address, cnid)values(id, name,
age, address, cnid); else
dbms_output.put_line('not eligible voter');
end if; end;
//EXEC 1
begin insertdate('v06','kitch',17,'bangalore','cnt2');
end;
//EXEC 2
begin insertdate('v06','kitch',19,'bangalore','cnt2');
end;
1MV24MC046 31
DBMS and Web Technologies Laboratory MMCL106
SQL>
create or replace procedure getnoofvoter(consti_name in varchar2) is no_voters
number;
begin
select no_of_voters into no_voters from constituency c where
c.name=consti_name;
dbms_output.put_line(no_voters);
end;
begin getnoofvoter('haveri');
end;
1MV24MC046 32
DBMS and Web Technologies Laboratory MMCL106
SQL>
create trigger countofvoters after insert on voter
begin
update constituency c set c.no_of_voters=c.no_of_voters+1 where c.cnid in(select
cnid from voter);
end;
begin insertdate('v07','RAKESH',28,'haveri','cnt2'); end;
1MV24MC046 33
DBMS and Web Technologies Laboratory MMCL106
LAB_PROGRAM 5
Design an ER-diagram for the following scenario, Convert the same into a
relational model, normalize Relations into a suitable Normal form and then
solve the following queries.
A country can have many Tourist places . Each Tourist place is identified by
using tourist_place_id, having a name, belongs to a state, Number of
kilometers away from the capital city of that state,history. There are many
Tourists visits tourist places every year. Each tourist is identified uniquely by
using Tourist_id, having a Name, age, Country and multiple emailids. A
tourist visits many Tourist places, it isalso required to record the visted_date
in the database. A tourist can visit a Tourist place many times at different
dates. A Tourist place can be visited by many touristseither in the same
QUERIES:
1. List the state name which is having maximum number of ourist places.
2. List details of Tourist place where maximum number of tourists visited.
3. List the details of tourists visited all tourist places of the state
“KARNATAKA”.
4. Display the details of the tourists visited at least one tourist place of the
state, but visited all states tourist places.
5. Display the details of the tourist place visited by the tourists of all country.
1MV24MC046 34
DBMS and Web Technologies Laboratory MMCL106
SCHEMA :
TOURIST_PLACE
TOURIST
TID NAME COUNTRY AGE
VISITED
TPID TID VISITED__DATE
1MV24MC046 35
DBMS and Web Technologies Laboratory MMCL106
ER DIAGRAM
1MV24MC046 36
DBMS and Web Technologies Laboratory MMCL106
TOURISTPLACES
create table touristplaces(tpid varchar(20) primary key,name varchar(20),state
varchar(20),kilometer number(5),history varchar(20));
insert into touristplaces values('tp01','nandi','karnataka',50,'hills');
insert into touristplaces values('tp02','udupi','karnataka',50,'krishnatemple');
insert into touristplaces values('tp03','tirupati','andhrapradesh',150,'oldtemple');
select * from touristplaces;
TOURIST
create table tourist(tid varchar(20) primary key, tname varchar(20),country
varchar(20),age number(2));
insert into tourist values('t01','mahesh','india',27);
insert into tourist values('t02','wang','china',25);
insert into tourist values('t03','elena','russia',24);
insert into tourist values('t04','james','america',30);
1MV24MC046 37
DBMS and Web Technologies Laboratory MMCL106
VISITED
create table visited(tpid varchar(20) references touristplaces(tpid), tid varchar(10)
references tourist(tid),visiteddate date);
1MV24MC046 38
DBMS and Web Technologies Laboratory MMCL106
Query 1 -> List the state name which is having maximum number of tourist
places.
SQL>
select state,count(state) as total from touristplaces group by state having
count(tpid) in (select max(count(state)) from touristplaces group by state);
Query 2 -> List details of Tourist place where maximum number of tourists
visited.
SQL>
select * from touristplaces where tpid in(select v.tpid from tourist t,visited v where
t.tid=v.tid group by v.tpid having count(v.tpid) in (select max(count(tpid)) from
visited group by tpid));
Query 3 -> List the details of tourists visited all tourist places of the state
“KARNATAKA”.
SQL>
select * from tourist where tid in(select tid from visited v join touristplaces tp on
v.tpid=tp.tpid where tp.state='karnataka' group by tid having count(state) in (select
count(state) from touristplaces where state='karnataka'));
1MV24MC046 39
DBMS and Web Technologies Laboratory MMCL106
Query 4 -> Display the details of the tourists visited at least one tourist place
of the state, but visited all states tourist places.
SQL>
select * from tourist where tid in(select tid from visited group by tid having
count(tid)>=(select count(*) from(select state from touristplaces group by state)));
Query 5 -> Display the details of the tourist place visited by the tourists of all
country.
SQL>
select * from touristplaces where tpid in(select tpid from visited join tourist on
visited.tid=tourist.tid group by tpid having count(distinct country)=(select
count(distinct country) from tourist));
1MV24MC046 40
DBMS and Web Technologies Laboratory MMCL106
LAB_PROGRAM 6
SOURCE CODE:
<!-- Create an XHTML page that provides information about your department. Your XHTML
page must use the
following tags:
a) Text Formatting tags
b) Horizontal rule
1MV24MC046 41
DBMS and Web Technologies Laboratory MMCL106
c) Meta element
d) Links
e) Images
f) Tables
(Use of additional tags encouraged). -->
<body>
<h1 style="text-align: center;"> SIR M VISVESVARAYYA INSTITUTE OF TECHNOLOGY
</h1>
<h2>About Us</h2>
<p>The <strong>MCA Department</strong> The MCA (Master of Computer Applications)
department at [College Name] is dedicated
to providing high-quality education in the field of computer applications, equipping students
with the latest skills
and knowledge to excel in the IT industry through a comprehensive curriculum focused on
software development,
database management, web technologies, and emerging trends, while fostering a strong
foundation in theoretical
concepts and practical application through industry-oriented projects and expert faculty
guidance, ultimately
preparing graduates for successful careers as software professionals. </em>, and more.</p>
<h2>Our Vision</h2>
1MV24MC046 42
DBMS and Web Technologies Laboratory MMCL106
<h2>Department Highlights</h2>
<ul>
<li><b>State-of-the-art Laboratories</b></li>
<li><b>Experienced Faculty</b></li>
<li><b>Industry Collaborations</b></li>
<li><b>Internship & Placement Opportunities</b></li>
</ul>
<hr />
<h2>Our Faculty</h2>
<table border="1" cellpadding="5" cellspacing="0">
<tr>
<th>Name</th>
<th>Designation</th>
<th>Qualification</th>
</tr>
<tr>
<td>Dr. C.H Vanipriya</td>
<td>Head of Department</td>
<td>M.E., Ph.D.</td>
</tr>
<tr>
<td>Ms. Latha R.</td>
<td>Asst Prof</td>
<td>M.CA., M.Phil.,</td>
</tr>
1MV24MC046 43
DBMS and Web Technologies Laboratory MMCL106
<tr>
<td>Ms. Vani Harave</td>
<td>Associate Professor</td>
<td>M.CA., M.Phil.,</td>
</tr>
</table>
<hr />
<h2>Contact Us</h2>
<p>Email: <a href="vani:[email protected]">[email protected]</a></p>
<p>Website: <a href="https://www.sirmvit.edu/">Visit our Website</a></p>
<hr />
</body>
</html>
OUTPUT:
1MV24MC046 44
DBMS and Web Technologies Laboratory MMCL106
1MV24MC046 45
DBMS and Web Technologies Laboratory MMCL106
LAB_PROGRAM 7
Develop and demonstrate a XHTML file that includes Javascript script for
the following problems:
a) Input: A number n obtained using prompt
Output: The first n Fibonacci numbers
b) Input: A number n obtained using prompt
Output: A table of numbers from 1 to n and their squares using alert
SOURCE CODE:
<!DOCTYPE html>
<html>
<head>
<title>Program 3</title>
</head>
<body>
<h1>First N Fibonacci Numbers</h1>
<button onclick="fib()">Generate</button>
<h1>Generate Number And Its Squares</h1>
<button onclick="square()">Generate</button>
</body>
<script>
function fib()
{
let n = parseInt(prompt("Enter value for n: "));
let a=0,b=1,c=0;
1MV24MC046 46
DBMS and Web Technologies Laboratory MMCL106
1MV24MC046 47
DBMS and Web Technologies Laboratory MMCL106
OUTPUT:
1MV24MC046 48
DBMS and Web Technologies Laboratory MMCL106
1MV24MC046 49
DBMS and Web Technologies Laboratory MMCL106
LAB_PROGRAM 8
SOURCE CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial- scale=1.0">
<title>Events</title>
<style>
.para1{
width: 300px; background-color: gray; color: ivory; position: absolute;
z-index: 0; top: 100px; left: 200px; padding: 20px;
}
.para2{
width: 300px; background-color: plum; color: ivory; position: absolute;
z-index: 0; top: 120px; left: 220px; padding: 20px;
}
1MV24MC046 50
DBMS and Web Technologies Laboratory MMCL106
.para3{
width: 300px;
background-color: salmon; color: ivory;
position: absolute; z-index: 0;
top: 140px; left: 240px; padding: 20px;
}
</style>
<script>
var top_layer = 3; var orign_pos;
function mover(totop,pos) {
var newtop = document.getElementById(totop).style; newtop.zIndex="10";
top_layer= document.getElementById(totop).id; orign_pos = pos;
}
function moveback() { document.getElementById(top_layer).style.zIndex=orign_po
s;
}
</script>
</head>
<body>
<div class="para1" id="1" onmouseover="mover(1,1)" onmouseout="moveback()">
DuckDuckGo is an American software company focused on online privacy, whose flagship
product is a search engine named DuckDuckGo. Founded by Gabriel Weinberg in 2008.
</div>
<div class="para2" id="2" onmouseover="mover(2,2)" onmouseout="moveback()">
Google LLC is an American multinational corporation and technology company focusing on
online advertising, search engine technology, cloud computing, computer software, quantum
computing, e-commerce, consumer electronics.
</div>
<div class="para3" id="3" onmouseover="mover(3,3)" onmouseout="moveback()">
1MV24MC046 51
DBMS and Web Technologies Laboratory MMCL106
Mozilla Firefox is a free, open-source web browser developed by the Mozilla Foundation and its
subsidiary, the Mozilla Corporation, used for browsing the internet, offering features like privacy
controls, customization options, and extensions.
</div>
</body>
</html>
OUTPUT:
1MV24MC046 52
DBMS and Web Technologies Laboratory MMCL106
1MV24MC046 53