DB (PS)
DB (PS)
(NAAC Accredited)
Valachil, Mangaluru-574 143
USN : 4SN24MC018
Course : MCA
Semester : 1st
SRINIVAS INSTITUTE OF TECHNOLOGY
(NAAC Accredited)
VALACHIL, MANGALURU-574 143
LABORATORY CERTIFICATE
This is to Certify that, Mr.Pavan N Shetty bearing USN
4SN24MC018 has satisfactorily completed the practical work in
DBMS and Web Technologies Laboratory prescribed by the
Visvesvaraya Technological University, Belgaum for the 1st Semester
MCA course during the year 2024-2025.
Date:
Examiners: Signature
1.
2.
INDEX
Sl.No Experiments Page.No
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)
Execute the following Queries:
i. List the details of Students who are all studying in 2nd sem
MCA.
ii. List the students who are not borrowed any books.
iii. Display the USN, Student name, Branch_name, Book_name,
01-07
Author_name, Books_Borrowed_Date of 2nd sem MCA
Students who borrowed books.
iv. Display the number of books written by each Author.
v. Display the student details who borrowed more than two
books.
vi. Display the student details who borrowed books of more than
one Author.
vii. Display the Book names in descending order of their names.
viii.List the details of students who borrowed the books which
are all published by the same publisher.
2. Consider the following schema:
STUDENT (USN, name, date_of_birth, branch, mark1, mark2,
mark3, total, GPA) Execute the following queries:
i. Update the column total by adding the columns mark1, mark2,
mark3.
ii. Find the GPA score of all the students.
iii. Find the students who born on a particular year of birth from
the date_of_birth column.
08-11
iv. List the students who are studying in a particular branch of
study. v. Find the maximum GPA score of the student branch-
wise.
vi. Find the students whose name starts with the alphabet.
vii. Find the students whose name ends with the alphabets.
viii. Delete the student details whose USN is given as 1001.
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.
12-17
Each team is uniquely identified by using Teamid. 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.
Execute the following Queries:
i. Display the youngest player (in terms of age) Name, Team
name, age in which he belongs of the tournament.
ii. List the details of the stadium where the maximum number of
matches were played.
iii. List the details of the player who is not a captain but got the
man_of _match award at least in two matches.
iv. Display the Team details who won the maximum matches.
v. Display the team name where all its won matches played in
the same stadium.
4. 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 02.03.2021 updated 52/
104 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 is also
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 tourists either in the same date or 18-23
at different dates.
Queries:
i. List the state name which is having maximum number of
tourist places.
ii. List details of Tourist place where maximum number of
tourists visited.
iii. List the details of tourists visited all tourist places of the state
iv. Display the details of the tourists visited at least one tourist
place of the state, but visited all states tourist places.
v. Display the details of the tourist place visited by the tourists
of all country.
5. Program Statement: 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 02.03.2021 updated 52/ 104 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 is also 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 24-28
many tourists either in the same date or at different dates.
Queries:
i. List the state name which is having maximum number of
tourist places. ii. List details of Tourist place where maximum
number of tourists visited. iii. List the details of tourists visited
all tourist places of the state
iv. Display the details of the tourists visited at least one tourist
place of the state, but visited all states tourist places.
v. Display the details of the tourist place visited by the tourists
of all country.
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) 29-32
Images f) Tables (Use of additional tags encouraged).
Source Code:
mysql> create database library;
mysql> use library;
Database changed
Table Branch
mysql> create table branch(branch_id int(10) primary key,branch_name varchar(20),hod
varchar(20));
Insert
mysql> insert into branch values(101,'MCA','Shashidhar Kini');
mysql> insert into branch values(102,'MBA','Harish');
mysql> insert into branch values(103,'BE','AshaLatha');
mysql> insert into branch values(104,'Mtech','Seema');
mysql> insert into branch values(105,'Btech','Malavika');
mysql> select * from branch;
+ + + +
| branch_id | branch_name | hod |
+ + + +
| 101 | MCA | Shashidhar Kini |
| 102 | MBA | Harish |
| 103 | BE | AshaLatha |
| 104 | Mtech | Seema |
| 105 | Btech | Malavika |
+ + + +
5 rows in set
Table Student
mysql> create table student( usn varchar(10) primary key, s_name varchar(20),branch_id
int(10) references branch(branch_id),sem varchar(20),address varchar(20));
Insert
mysql> insert into student values('S21','Nireeksha',101,2,'Adyar');
mysql> insert into student values('S22','Akhrith',102,2,'Kasargod');
mysql> insert into student values('S23','Mehika',103,2,'Vamadapadav');
mysql> insert into student values('S24','Chiranya',104,2,'Kodakal');
mysql> insert into student values('S25','Thanvi',105,1,'Uppala');
mysql> insert into student values('S26','Shraddha',101,1,'Udupi');
mysql> insert into student values('S27','Adya',102,1,'Udupi');
mysql> insert into student values('S28','Rithisha',101,2,'Mumbai');
Query OK, 1 row affected (0.01 sec)
Table Author
mysql> create table author(author_id int(10) primary key,author_name varchar(20),country
varchar(20),age int(20));
Insert
mysql> insert into author values(1,'Sudha','India',30);
mysql> insert into author values(2,'Kuvempu','India',70);
mysql> insert into author values(3,'Kavin','America',50);
mysql> insert into author values(4,'Lee Min ho','Korea',70);
mysql> insert into author values(5,'Xukai','China',25);
Table Book
mysql> create table book (book_id int(10) primary key,book_name varchar(20), author_id
int(10) references author(author_id), publisher varchar(20),branch_id int(10) references
student(branch_id));
Insert
mysql> insert into book values(201,'Earth',1,'Mangala',101);
mysql> insert into book values(202,'Happy',2,'Mangala',102);
mysql> insert into book values(203,'Gold',3,'Swapna',103);
mysql> insert into book values(204,'Myname',3,'Education',104);
mysql> insert into book values(206,'The Horror',5,'Education',101);
Table Borrow
create table borrow(usn varchar(10) references student(usn),book_id int(10) references
book(book_id), borrowed_date date);
Insert
mysql> insert into borrow values('S21',201,'2023-05-03');
mysql> insert into borrow values('S21',206,'2023-12-17');
mysql> insert into borrow values('S22',203,'2023-10-21');
mysql> insert into borrow values('S23',205,'2023-05-23');
mysql> insert into borrow values('S24',202,'2023-01-15');
mysql> insert into borrow values('S26',202,'2023-05-29');
Query 1:
mysql> select s.* from student s join branch b on s.branch_id=b.branch_id where s.sem=2
and b.branch_name ='MCA';
+ + + + + +
| usn | s_name | branch_id | sem | address |
+ + + + + +
| S21 | Nireeksha | 101 | 2 | Adyar |
| S28 | Rithisha | 101 | 2 | Mumbai |
+ + + + + +
2 rows in set
Query 2:
mysql> select s.* from student s left join borrow b on s.usn = b.usn where b.usn is null;
+ + + + + +
| usn | s_name |branch_id | sem | address |
+ + + + + +
| S25 | Thanvi | 105 | 1 | Uppala |
| S27 | Adya | 102 | 1 | Udupi |
| S28 | Rithisha | 101 | 2 | Mumbai|
+ + + + + +
3 rows in set
Query 3:
mysql> select s.usn,s.s_name as studentname,br.branch_name,
bo.book_name,a.author_name,b.borrowed_date from student s join branch br on s.branch_id
= br.branch_id join borrow b on s.usn = b.usn join book bo on b.book_id =bo.book_id join
author a on bo.author_id = a.author_id where s.sem = 2 and br.branch_name ='MCA';
+ + + + + + +
| usn | studentname | branch_name | book_name | author_name | borrowed_date |
+ + + + + + +
| S21 | Nireeksha | MCA | Earth | Sudha | 2023-05-03 |
| S21 | Nireeksha | MCA | The Horror | Xukai | 2023-12-17 |
+ + + + + + +
2 rows in set
Query 4:
mysql> select a.author_id,a.author_name,count(bo.book_id)as number_of_books from author
a left join book bo on a.author_id = bo.author_id group by a.author_id,a.author_name;
+ + + +
| author_id | author_name | number_of_books |
+ + + +
| 1 | Sudha | 1|
| 2 | Kuvempu | 1|
| 3 | Kavin | 2|
| 4 | Lee Min ho | 0|
| 5 | Xukai | 1|
+ + + +
5 rows in set (0.00 sec)
Query 5:
mysql> select s.* from student s join borrow b on s.usn =b.usn join book bo on b.book_id
=bo.book_id group by s.usn,s.s_name,s.address,s.branch_id,s.sem having count(distinct
bo.author_id)>1;
+ + + + + +
| usn | s_name | branch_id | sem | address |
+ + + + + +
| S21 | Nireeksha | 101 | 2 | Adyar |
+ + + + + +
1 row in set
Query 6:
mysql> select s.* from student s join borrow b on s.usn = b.usn group by
s.usn,s.s_name,s.address,s.branch_id,s.sem having count(b.book_id)>=2;
+ + + + + +
| usn | s_name | branch_id | sem | address |
+ + + + + +
| S21 | Nireeksha | 101 | 2 | Adyar |
+ + + + + +
1 row in set (0.00 sec)
Query 7:
mysql> select book_name from book order by book_name desc;
+ +
| book_name |
+ +
| The Horror |
| Myname |
| Happy |
| Gold |
| Earth |
+ +
5 rows in set
Query 8:
mysql> select distinct s.* from student s join borrow b on s.usn = b.usn join book bo on
b.book_id =bo.book_id where bo.publisher in(select publisher from book group by publisher
having count(distinct book_id)>1);
Source Code:
mysql> create database Student1;
mysql> use Student1;
Database changed
Table Student
mysql> create table Student(USN varchar(10) primary key,Name varchar(30),DOB
date,Branch varchar(10),mark1 int(4),mark2 int(4),mark3 int(4),Total int(4),GPA integer(5));
Insert
mysql> insert into Student values('SS001','Likhitha','2003-04-04','MCA',70,80,95,0,NULL);
mysql> insert into Student values('SS002','Raksha','2003-04-12','MCA',50,60,85,0,NULL);
mysql> insert into Student values('SS003','Ameesha','2003-12-05','MCA',80,85,90,0,NULL);
mysql> insert into Student values('SS004','Suraj','1999-10-05','MBA',50,55,70,0,NULL);
mysql> insert into Student values('SS005','Sagar','2000-08-20','MA',70,55,60,0,NULL);
mysql> insert into Student values('SS006','Manohar','1993-03-28','MSC',10,60,90,0,NULL);
mysql> insert into Student values('SS007','Priyanka','2002-04-12','MCA',85,90,100,0,NULL);
mysql> insert into Student values('SS008','Agasthya','2001-07-06','MBA',95,90,90,0,NULL);
Query 1:
mysql> Update Student set total = mark1+mark2+mark3;
Rows matched: 8 Changed: 8
Query 2:
mysql> Update Student Set GPA =(Total/300)*10;
Rows matched: 8 Changed: 8
Query 3:
mysql> select name from Student where Branch="MCA";
+ +
| name |
+ +
| Raksha |
| Ameesha |
| Priyanka |
+ +
3 rows in set
Query 4:
mysql> select * from Student where year(DOB)=2000;
+ + + + + + + + + +
| USN | Name | DOB | Branch | mark1 | mark2 | mark3 | Total | GPA|
+ + + + + + + + + +
| SS005 | Sagar | 2000-08-20 | MA | 70 | 55 | 60 | 185 | 6 |
+ + + + + + + + + +
1 row in set
Query 5:
mysql> Select Branch ,max(GPA) from Student group by Branch;
+ + +
| Branch | max(GPA) |
+ + +
| MCA | 9 |
| MBA | 9 |
| MA | 6 |
| MSC | 5 |
+ + +
4 rows in set
Query 6:
mysql> select * from Student where name like 'S%';
+ + + + + + + + + +
| USN | Name | DOB | Branch | mark1 | mark2 | mark3 | Total | GPA |
+ + + + + + + + + +
| SS004 | Suraj |1999-10-05| MBA | 50 | 55 | 70 | 175 | 6 |
| SS005 | Sagar |2000-08-20| MA | 70 | 55 | 60 | 185 | 6 |
+ + + + + + + + + +
2 rows in set
Query 7:
mysql> select * from Student where name like '%AR';
+ + + + + + + + + +
| USN | Name | DOB | Branch | mark1 | mark2| mark3 | Total | GPA |
+ + + + + + + + + +
| SS005 | Sagar |2000-08-20 | MA | 70 | 55 | 60 | 185 | 6 |
| SS006 | Manohar | 1993-03-28 | MSC| 10 | 60 | 90 | 160 | 5 |
+ + + + + + + + + +
2 rows in set
Query 8:
Relational Model:
E-R Diagram:
Source Code:
mysql> use cricket;
Database changed
Table Team
mysql> create table team(tid int primary key,tname varchar(20),coach
varchar(20),captain_pid int, city varchar(20));
Insert
mysql> insert into team values(101,'RCB','Sunil',1,'Bangalore');
mysql> insert into team values(102,'CSK','Laxman',3,'Chennai');
mysql> insert into team values(104,'Royals','Singh',7,'Rajasthan');
mysql> insert into team values(105,'KKR','Sehwag',5,'Kolkata');
Table Player
mysql> create table player(pid int primary key,pname varchar(20),age int ,tid int references
team(tid));
Insert
mysql> insert into player values(1,'Sachin',33,101);
mysql> insert into player values(2,'Virat',35,101);
mysql> insert into player values(3,'Dhoni',40,102);
mysql> insert into player values(4,'Ruturaj',33,102);
mysql> insert into player values(5,'Manish',26,103);
mysql> insert into player values(6,'Ajinkya',26,105);
mysql> insert into player values(7,'Shubham',32,104);
mysql> insert into player values(8,'Sanju',30,104);
| 7 | Shubham| 32 | 104 |
| 8 | Sanju | 30 | 104 |
+ + + + +
8 rows in set
Table Stadium
mysql> create table stadium(sid int primary key,sname varchar(20),pincode int,city
varchar(20),area varchar(20));
Insert
mysql> insert into stadium values(111,'Chinnaswamy',56001,'Bangalore','MG Road');
mysql> insert into stadium values(222,'Kotla',46009,'Delhi','Highway');
mysql> insert into stadium values(333,'Eden',76004,'Kolkata','Maidan');
mysql> insert into stadium values(444,'Chidambaram',600002,'Chennai','Chepauk');
mysql> insert into stadium values(555,'CSCA',567772,'Cochin','Beach Road');
Table Matches
mysql> create table matches(mid varchar(4)primary key,mdate date, time varchar(10),sid int
references stadium(sid),team_id1 int references team(tid),team_id2 int references
team(tid),winning_team_id int references team(tid),man_of_match int references
player(pid));
Insert
mysql> insert into matches values(001,'2017-01-10','10am',111,101,102,101,2);
mysql> insert into matches values(002,'2017-01-10','1pm',222,102,105,105,5);
mysql> insert into matches values(003,'2017-01-11','10am',333,104,101,101,2);
mysql> insert into matches values(004,'2017-01-11','2pm',111,104,105,104,7);
mysql> insert into matches values(005,'2017-01-12','11am',444,104,101,104,7);
Table Player_phone
mysql> create table player_phone(pid int references player(pid),phone varchar(15),primary
key(pid,phone));
Insert
mysql> insert into player_phone values(1,'9562132051');
mysql> insert into player_phone values(2,'8265678241');
mysql> insert into player_phone values(2,'9485523168');
mysql> insert into player_phone values(7,'6265723421');
mysql> insert into player_phone values(5,'6263435671');
Query OK, 1 row affected (0.01 sec)
Query 1:
mysql> select pname,tname,age from player p ,team t where p.tid=t.tid and age =(select
min(age)from player);
+ + + +
| pname | tname | age |
+ + + +
| Ajinkya | KKR | 26 |
+ + + +
1 row in set
Query 2:
select * from stadium where sid in (select sid from matches group by sid having count(*) =
(select max(x.total) from (select sid, count(*) as total from matches group by sid) x));
+ + + + + +
| sid | sname | pincode | city | area |
+ + + + + +
| 111 | Chinnaswamy | 56001 | Bangalore | MG Road |
+ + + + + +
1 row in set
Query 3:
mysql> select * from player where pid not in (select captain_pid from team) and pid in (select
man_of_match from matches group by man_of_match having count(man_of_match) >= 2);
+ + + + +
| pid | pname | age | tid |
+ + + + +
| 2 | Virat | 35 | 101 |
+ + + + +
1 row in set
Query 4:
mysql> select * from team where tid in (select winning_team_id from matches group by
winning_team_id having count(*) = (select max(x.total) from (select winning_team_id,
count(*) as total from matches group by winning_team_id) x));
+ + + + + +
| tid | tname | coach | captain_pid | city |
+ + + + + +
| 101 | RCB | Sunil | 1 | Bangalore |
| 104 | Royals | Singh | 7 | Rajasthan |
+ + + + + +
2 rows in set
Query 5:
mysql> select t.tname from team t, matches m where t.tid = m.winning_team_id group by
m.winning_team_id having count(distinct m.sid) >= 1;
+ +
| tname |
+ +
| RCB |
| Royals |
| KKR |
+ +
3 rows in set
Relational Model:
E-R Diagram
Source Code:
Table Constituency
create table constituency(cons_id number(20)primary key, csname varchar(20), csstate
varchar(20), no_of_voters number(10));
Table Party
create table party(pid number(20) primary key, pname varchar(20), psymbol varchar(10));
Table Candidates
create table candidates (cand_id number(12)primary key, phone_no number(10), age
number(2), state varchar(20), name varchar(20), pid int references party(pid));
Table Contest
create table contest(cons_id number(20) references constituency(cons_id), cand_id
number(12) references candidates(cand_id) primary key(cons_id,cand_id);
+ + +
| CONS_ID |CAND_ID |
+ + +
| 111 | 122 |
| 222 | 121 |
| 222 | 122 |
+ + +
Table Voter
create table voter(vid number(20) primary key, vname varchar(20), vage number(5), vaddr
varchar(20), cons_id number(20) references constituency(cons_id), cand_id number(12)
references candidates(cand_id));
+ + + + + + +
| VID |VNAME| VAGE |VADDR |CONS_ID| CAND_ID |
+ + + + + + +
| 345 |prashanth | 21 |kanakpura |222 |122 |
|346 |prakash | 23 |ramnagar |111 |121 |
|348 |nagesh | 30 |mandya |111 |121 |
|349 |nagesh | 30 |mandya |111 |121 |
+ + + + + + +
Query 1:
select * from candidates where cand_id in (select cand_id from contest join constituency on
contest.cons_id=constituency.cons_id group by cand_id having count(distinct(csstate))>1);
+ + + + + + +
CAND_ID |PHONE_NO |AGE |STATE |NAME |PID |
+ + + + + + +
|122 |9740777502 | 24 | karnataka | veena | 877 |
+ + + + + + +
Query 2:
select csstate from constituency group by csstate having count(csstate) in (select
max(count(csstate)) from constituency group by csstate);
+ +
| CSSTATE |
+ +
| Karnataka |
+ +
Query 3:
Query 4:
create orreplace procedure display_count (const_id number)as vid constituency.cons_id %
type; begin select no_of_voters into vid from constituency where cons_id = const_id and
rownum = 1; dbms_output.put_line ( 'total voters are: ' || vid); end;
/
Procedure created.
Query 5:
create or replace trigger count after insert on voter for each row begin update constituency set
no_of_voters = no_of_voters + 1 where cons_id=:new.cons_id; end count;
/
Trigger created.
SQL> setserveroutput on;
+ + + + +
SQL> insert into voter values(348,'nagesh',30,'mandya',111,121);
1 row created.
After insertion into voter table , the constituency table is automatically updated.
E-R Diagram:
Source code:
mysql> create database Tour;
Query OK, 1 row affected (0.01 sec)
Table Tourist
mysql> create table Tourist01(Tid int primary key,Name varchar(20),Age int(3),Country
varchar(20));
Insert
mysql> insert into Tourist01 values(22,'PRAKESH','40','DUBAI');
mysql> insert into Tourist01 values(23,'ABDHUL','35','INDIA');
mysql> insert into Tourist01 values(24,'ARNOLD','45','AMERICA');
mysql> select * from Tourist01;
+ + + + +
| Tid | Name | Age | Country |
+ + + + +
| 22 | PRAKESH | 40 | DUBAI |
| 23 | ABDHUL | 35 | INDIA |
| 24 | ARNOLD | 45 | AMERICA |
+ + + + +
3 rows in set
Table Visits
mysql> create table visits01 (tpid int references tourist_place01(tpid), tid int references
tourist01(tid), v_date date, primary key (tpid, tid));
Insert
mysql> insert into Visits01 values(11, 22, '2016-10-30');
mysql> insert into Visits01 values(11, 23, '2011-08-13');
mysql> insert into Visits01 values(11, 24, '2015-10-13');
mysql> insert into Visits01 values(12, 24, '2016-04-13');
mysql> insert into Visits01 values(16, 24, '2016-04-13');
mysql> insert into Visits01 values(13, 24, '2018-09-19');
mysql> insert into Visits01 values(15, 22, '2018-09-19');
mysql> insert into Visits01 values(16, 22, '2018-08-09');
mysql> select * from Visits01;
+ + + +
| tpid | tid | v_date |
+ + + +
| 11 | 22 | 2016-10-30 |
| 11 | 23 | 2011-08-13 |
| 11 | 24 | 2015-10-13 |
| 12 | 24 | 2016-04-13 |
| 13 | 24 | 2018-09-19 |
| 15 | 22 | 2018-09-19 |
| 16 | 22 | 2018-08-09 |
| 16 | 24 | 2016-04-13 |
+ + + +
8 rows in set
Table Email
mysql> create table email01(Tid int References Tourist01(Tid),email varchar(30),primary
key (tid,email));
Insert
mysql> insert into email01 values(23,'bhanu@gmal.com');
mysql> insert into email01 values(22,'manu@gmal.com');
mysql> insert into email01 values(25,'thanu@gmal.com');
mysql> select * from email01;
+ + +
| Tid | email |
+ + +
| 22 | manu@gmal.com |
| 23 | bhanu@gmal.com |
| 25 | thanu@gmal.com |
+ + +
3 rows in set
Query 1:
mysql> select State from tourist_place01 group by State having count(*) = (select
max(p.tp_count) from (select State, count(*) as tp_count from tourist_place01 group by state)
p);
+ +
| State |
+ +
| Karnataka |
+ +
1 row in set (0.00 sec)
Query 2:
mysql> select tp.tpid, tp.tpname, tp.state, count(tv.tid) from tourist_place01 tp, visits01 tv
where tv.tpid = tp.tpid group by tv.tpid order by count(tv.tpid) desc limit 2;
+ + + + +
| tpid | tpname | state | count(tv.tid) |
+ + + + +
| 11 | tajmhal | delhi | 3|
| 16 | Mangaluru| Karnataka | 2|
+ + + + +
2 rows in set
Query 3:
mysql> select * from tourist01 t where t.tid in (select tid from visits01 join tourist_place01 on
visits01.tpid = tourist_place01.tpid where state = 'Karnataka' group by tid having count(state)
in (select count(state) from tourist_place01 where state = 'Karnataka'));
+ + + + +
| Tid | Name | Age | Country |
+ + + + +
| 22 | PRAKESH | 40 | DUBAI |
+ + + + +
1 row in set
Query 4:
mysql> select * from tourist01 t where t.tid in (select tid from visits01 join tourist_place01 on
visits01.tpid = tourist_place01.tpid group by tid having count(distinct state) in (select
count(distinct state) from tourist_place01));
+ + + + +
| Tid | Name | Age | Country |
+ + + + +
| 24 | ARNOLD | 45 | AMERICA |
+ + + + +
1 row in set
Query 5:
mysql> select * from tourist_place01 where tpid in (select tpid from visits01 join tourist01 on
visits01.tid = tourist01.tid group by tpid having count(distinct country) = (select
count(distinct country) from tourist01));
+ + + + + +
| Tpid | TpName | State | Kilometer | History |
+ + + + + +
| 11 | tajmhal | delhi | 100 | monument |
+ + + + + +
1 row in set
</tr>
<tr>
<td>Web</td><td>Ms.Nikshitha R S</td>
</tr>
<tr>
<td>mobile application</td><td>Ms. Sharanya M</td>
</tr>
</center>
</h3>
</body>
</html>
OUTPUT:
OUTPUT:
alert(msgstr);
</script>
</body>
</html>
OUTPUT:
Source code:stack.html
<html>
<head>
<title>Stack Ordering</title>
<style type="text/css">
#layer1
{
border:solid thick black;
background-color:brown;
padding:10px;
width:300px;
height:200px;
position:absolute;
top:100px;
left:200px;
z-index:0;
}
#layer2
{
border:solid thick black;
background-color:gray;
padding:10px;
width:300px;
height:200px;
position:absolute;
top:120px;
left:220px;
z-index:0;
}
#layer3
{
border:solid thick black;
background-color:white;
padding:10px;
width:300px;
height:200px;
position:absolute;
top:140px;
left:240px;
z-index:0;
}
</style>
</head>
<body>
<script type=text/javascript>
var topLayer="layer3";
//function to place the choosen layer on the top
function mover(toTop)
{
document.getElementById(topLayer).style.zIndex="0";
document.getElementById(toTop).style.zIndex="1";
topLayer=toTop;
}
</script>
<p id=layer1 onMouseOver=mover('layer1');>This is the last layer</p>
<p id=layer2 onMouseOver=mover('layer2');>This is the middle layer</p>
<p id=layer3 onMouseOver=mover('layer3');>This is the first layer</p>
</body>
</html>
OUTPUT: