0% found this document useful (0 votes)
46 views53 pages

DBMS and Web MANUAL

The document outlines a laboratory program for a DBMS and Web Technologies course, detailing the creation of various database tables including BRANCH, STUDENT, BOOK, AUTHOR, and BORROW, along with SQL queries to manipulate and retrieve data. It also includes additional lab programs focusing on student records and a cricket tournament scenario, with corresponding queries for data analysis. The document provides schema constructs, sample data, and SQL commands for each program.

Uploaded by

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

DBMS and Web MANUAL

The document outlines a laboratory program for a DBMS and Web Technologies course, detailing the creation of various database tables including BRANCH, STUDENT, BOOK, AUTHOR, and BORROW, along with SQL queries to manipulate and retrieve data. It also includes additional lab programs focusing on student records and a cricket tournament scenario, with corresponding queries for data analysis. The document provides schema constructs, sample data, and SQL commands for each program.

Uploaded by

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

DBMS and Web Technologies Laboratory MMCL106

LAB_PROGRAM 1

Create the following tables with properly specifying Primary keys,


Foreign keys and solve the following queries.

BRANCH(Branchid, Branchname, HOD)


STUDENT(USN,Name,Address,Branchid,sem)
BOOK(Bookid,Bookname,Authorid,Publisher,Branchid)
AUTHOR(Authorid,Authorname,Country,age)
BORROW (USN, Bookid, Borrowed_Date)

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:

BRANCH BRANCH_I BRANCH_NAME HOD


D

STD_USN NAME ADDRESS BRANCH_ID SEM


STUDENT

AUTHOR AUTHOR_I AUTHOR_NAME COUNTRY AGE


D

BOOK BOOK_ID BOOK_NAME AUTHOR_ID PUBLISHER BRANCH_ID

BORROW STD_USN BOOK_ID BORROWED_DATE

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

insert into borrow values('1MV49','boo4','07-08-2025');


insert into borrow values('1MV50','boo5','17-07-2025');
select * from borrow;

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

Query 3 -> Display the USN, Student name, Branch_name, Book_name,


Author_name, Books_Borrowed_Date of 2nd sem MCA Students who
borrowed books.

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';

Query 4 -> Display the number of books written by each Author.

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

Consider the following schema:

STUDENT (USN, name, date_of_birth, branch, mark1, mark2,


mark3, total, GPA )

QUERIES:

1. Update the column total by adding the columns mark1, mark2,


mark3.
2. Find the GPA score of all the students.
3. Find the students who born on a particular year of birth from the
date_of_birth column.
4. List the students who are studying in a particular branch of study.
5. Find the maximum GPA score of the student branch-wise.
6. Find the st udents whose name starts with the alphabet
7. Find the students whose name ends with the alphabets
8. Delete the student details whose USN is given as 1001

1MV24MC046 10
DBMS and Web Technologies Laboratory MMCL106

SCHEMA:

USN NAME DOB BRANCH MARK1 MARK2 MARK3 TOTAL GPA

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);

insert into student values(1001,'Manoj','04-02-2003','MCA',80,78,85,0,0);

insert into student values(1002,'Tushar','04-02-2003','MCA',85,75,800,0,0);

insert into student values(1003,'Vinay','06-01-2003','MBA',70,76,83,0,0);

insert into student values(1004,'Sunil','04-04-2003','MBA',81,78,83,0,0);

insert into student values(1005,'Rajath','04-08-2003','MCA',93,91,95,0,0);

select * from student;

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;

Query 2-> Find the GPA score of all the students.

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.

Consider a Cricket Tournament “ABC CUP” organized by an organization.


In the tournament there are many teams are contesting each having a
Teamid,Team_Name, City, a coach. Each team is uniquely identified by
usingTeamid. A team can have many Players and a captain. Each player is
uniquely identified by Playerid, having a Name, and multiple phone
numbers,age. A player represents only one team. There are many Stadiums
to conduct matches. Each stadium is identified using Stadiumid, having a
stadium_name,Address ( involves city,area_name,pincode).A team can play
many matches. Each match played between the two teams in the scheduled
date and time in the predefined Stadium. Each match is identified uniquely
by using Matchid. Each match won by any of the one team that also wants to
record in the database. For each match man_of_the match award given to a
player.

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

ID SNAME PINCODE CITY AREA

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));

insert into team values('t001','rcb','bangalore','m mobat','p018');


insert into team values('t002','mi','mumbai','sachin','p028');

1MV24MC046 18
DBMS and Web Technologies Laboratory MMCL106

insert into team values('t003','csk','chennai','bravo','p038');


insert into team values('t004','srh','hydarbad','karthiks','p048');
select * from team;

PLAYER
create table player(pid varchar(20) primary key,pname varchar(20),age int,tid
varchar(20),foreign key(tid) references team(tid));

insert into player values('p018','virat',38,'t001');


insert into player values('p019','abd',39,'t001');
insert into player values('p028','rohit',40,'t002');
insert into player values('p029','jaspirt',36,'t002');
insert into player values('p038','dhoni',44,'t003');
insert into player values('p039','jadeja',41,'t003');
insert into player values('p048','pcummins',44,'t004');
insert into player values('p049','abhishek',24,'t004');
select * from player;

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));

insert into stadium values('s1','chinnaswami',540008,'bengaluru','rajajinagar');


insert into stadium values('s2','wankhade',58001,'mumbai','andheri east');
insert into stadium values('s3','eaden garden',540012,'kolkata','nagpur');
select * from stadium;

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

insert into match values('m12','18-12-2019','1pm','s1','t001','t004','t001','p019');


insert into match values('m13','22-12-2019','3pm','s2','t001','t003','t001','p019');
insert into match values('m14','24-12-2019','7pm','s3','t002','t004','t002','p019');
select * from match;

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

A country wants to conduct an election for the parliament. A country having


many constituencies. Each constituency is identified uniquely by
Constituency_id, having the Name, belongs to a state,Number_of_voters. A
constituency can have many voters. Each voter is uniquely identified by
using Voter_id, having the Name, age, address (involves
Houseno,city,state,pincode). Each voter belongs to only one constituency.
There are many candidates contesting in the election. Each candidates are
uniquely identified by using candidate_id, having Name, phone_no, age,
state. A candidate belongs to only one party.Thereare many parties. Each
party is uniquely identified by using Party_id, having
Party_Name,Party_symbol. A candidate can contest from many
constituencies under a same party. A party can have many candidates
contesting from different constituencies. No constituency having the
candidates from the same party. A constituency can have many contesting
candidates belongs to different parties. Each voter votes only one candidate
of his/her constituencty.

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

CNI NAME STATE NO_OF_VOTERS


D

VOTER
VID NAME AGE ADDRESS CDID

PARTY
PID PNAME PSYMBOL

CANDIDATE
CDID NAME PHONE AGE STATE PID

CONTEST CNID CDID

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));

insert into candidate values('cdt1','ramesh','92521839',36,'karnataka','p101');


insert into candidate values('cdt2','basvaraj','8123127500',36,'karnataka','p101');
insert into candidate values('cdt3','anil','9845339209',38,'karnataka','p102');
insert into candidate values('cdt4','chetan','8710008209',43,'karnataka','p102');
insert into candidate values('cdt5','darshan','9845337819',32,'karnataka','p103');
insert into candidate values('cdt6','nikhil','9125337819',39,'karnataka','p103');
insert into candidate values('cdt7','akshay','9740203548',40,'telengana','p101');

1MV24MC046 27
DBMS and Web Technologies Laboratory MMCL106

select * from candidate;

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');

select * from constituency;

1MV24MC046 28
DBMS and Web Technologies Laboratory MMCL106

CONTEST
create table contest(cnid varchar(20) references constituency(cnid),cid varchar(10)
references candidate(cid));

insert into contest values('cnt1','cdt1');


insert into contest values('cnt4','cdt1');
insert into contest values('cnt2','cdt2');
insert into contest values('cnt3','cdt3');
insert into contest values('cnt4','cdt7');

select * from contest;

VOTER
create table voter(vid varchar(20) primary key,name varchar(20),age
number(3),address varchar(20),cnid varchar(30) references constituency(cnid));

insert into voter values('v01','karthik',20,'RR nagar','cnt1');


insert into voter values('v02','goutham',23,'haveri','cnt2');
insert into voter values('v03','ramesh',24,'davangere','cnt3');
insert into voter values('v04','gourish',25,'bhuvangiri','cnt4');

1MV24MC046 29
DBMS and Web Technologies Laboratory MMCL106

insert into voter values('v05','rahul',28,'bhuvangiri','cnt4');


select * from voter;

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;

select * from voters;

1MV24MC046 31
DBMS and Web Technologies Laboratory MMCL106

Query 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.

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('RR nagar');


end;

begin getnoofvoter('haveri');
end;

1MV24MC046 32
DBMS and Web Technologies Laboratory MMCL106

Query 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

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

TPID NAME STATE KILO_METER HISTORY

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);

select * from tourist;

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);

insert into visited values('tp01','t01','10-3-2020');


insert into visited values('tp02','t01','10-3-2020');
insert into visited values('tp01','t02','9-4-2020');
insert into visited values('tp01','t03','12-5-2020');
insert into visited values('tp01','t04','10-23-2020');
insert into visited values('tp01','t02','10-3-2020');
insert into visited values('tp02','t02','10-3-2020');
insert into visited values('tp03','t03','2-22-2020');

select * from visited;

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

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
c) Meta element
d) Links
e) Images
f) Tables (Use of additional tags encouraged).

SOURCE CODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab Program 1</title>
</head>

<!-- 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>

<center><img src="campus.jpg" alt="MCA Department Campus" width="500"


height="300" /></center>

<center> <h2 style="color: chocolate;"> <u>MCA DEPARTMENT </u></h2></center>


<marquee><h3 style="color: red;">Welcome to the <strong>Master of Computer Application
Department</strong></h3></marquee>
<hr />

<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

<p><i>"To empower students with cutting-edge technology and innovation-driven


education."</i></p>

<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

let output = "Fibaonocci Series\n";


for(i=0;i<n;++i)
{
if(i==0 || i ==1)
output+= i+" ";
continue;
}
let c=a+b;
output+= c+" ";
a=b;
b=c;
}
alert(output);
}
function square()
{
let n = parseInt(prompt("Enter value for n: "));
let output = "Number Square\n";
for(i=1;i<=n;++i)
{
let sqr = i*i;
output += i +" "+sqr+"\n";
}
alert(output);
}
</script>
</html>

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

Develop and demonstrate, using JavaScript script, a XHTML document that


contains three short paragraphs of text, stacked on top of each other, with
only enough of each showing so that the mouse cursor can be placed over
some part of them. When the cursor is placed over the exposed part of any
paragraph, it should rise to the top to become completely visible. Modify the
above document so that when a text is moved from the top stacking position,
it returns to its original position rather than to the bottom

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

You might also like