0% found this document useful (0 votes)
61 views2 pages

2

The document contains SQL statements that create tables for teams, players, stadiums, and matches in a database to track cricket data. Tables are populated with sample data. Queries are written to find the youngest player on each team, stadiums that have hosted the most matches, players who have won man of the match twice but not as captains, and teams that have won matches at multiple stadiums.

Uploaded by

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

2

The document contains SQL statements that create tables for teams, players, stadiums, and matches in a database to track cricket data. Tables are populated with sample data. Queries are written to find the youngest player on each team, stadiums that have hosted the most matches, players who have won man of the match twice but not as captains, and teams that have won matches at multiple stadiums.

Uploaded by

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

create table team(tid int primary key,tname varchar(20),coach

varchar(30),captainpid int,city varchar(20));

insert into team values('123','rcb','sunil','1','banglore');


insert into team values('124','csk','laxman','3','chennai');
insert into team values('125','royals','singh','4','rajasthan');
insert into team values('126','daredevils','sehwag','2','delhi');

select * from team;

create table player(pid int primary key,pname varchar(20),age int,tid int


references team(tid));

insert into player values('1','sachin','33','123');


insert into player values('2','dravid','32','124');
insert into player values('3','dhoni','30','124');
insert into player values('4','raina','30','125');
insert into player values('5','kohli','23','126');

create table stadium(sid int primary key,sname varchar(20),picode number(8),city


varchar(20),area varchar(20));

insert into stadium values('111','chinnaswamy','56001','bangalore','mg_road');


insert into stadium values('222','kotla','460009','delhi','highway');
insert into stadium values('333','international','38883','chennai','tr nagar');
insert into stadium values('444','ksca','560098','bangalore','peenya');
insert into stadium values('555','csca','567772','cochin','beach road');

create table match(mid int primary key,mdate date,time varchar(6),sid int


references stadium(sid),team1id int references team(tid),team2id int references
team(tid),winningteamid int references team(tid),manofmatch int references
player(pid),CHECK(team1id!=team2id));

insert into match values('1','10-jan-17','10am','111','123','124','123',1);


insert into match values('102','11-jan-17','pm','222','124','126','126',5);
insert into match values('103','12-jan-17','11am','111','125','126','126','5');
insert into match values('104','17-jan-17','12pm','111','125','123','123','1');

create table playerphone(pid int references player(pid),phone int,primary


key(pid,phone));

insert into playerphone values('1','998882928');


insert into playerphone values('2','877563733');
insert into playerphone values('2','988928822');
insert into playerphone values('3','877366383');

select pname,tname,age from player p,team t where p.tid=t.tid and age=(select


min(age) from player);

select * from stadium where sid in(select sid from match group by sid having
count(sid)=(select max(count(sid)) from match group by sid));

select * from player where pid not in(select captainpid from team)and pid in
(select manofmatch from match group by manofmatch having count(manofmatch)=2);

select tname from team where tid in(select winningteamid from match group
by(winningteamid,sid)having count(*) in(select count (winningteamid) from match
group by winningteamid));

You might also like