0% found this document useful (0 votes)
3 views

dbA.sql

The document contains SQL commands to manage a database for a sports tournament, specifically focusing on creating and populating tables for teams, groups, matches, and top results. It includes commands to drop existing tables, create new ones, and insert data related to the 2010 FIFA World Cup. The data encompasses team information, match results, and historical winners from previous tournaments.

Uploaded by

llow5735
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)
3 views

dbA.sql

The document contains SQL commands to manage a database for a sports tournament, specifically focusing on creating and populating tables for teams, groups, matches, and top results. It includes commands to drop existing tables, create new ones, and insert data related to the 2010 FIFA World Cup. The data encompasses team information, match results, and historical winners from previous tournaments.

Uploaded by

llow5735
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/ 6

-- drop old tables

drop table IF EXISTS A_MATCHES;


drop table IF EXISTS A_GROUPS;
drop table IF EXISTS A_TOP;
drop table IF EXISTS A_TEAMS;

-- create tables
create table IF NOT EXISTS A_TEAMS (
cup int(4) not null,
continent varchar(30) not null,
teams varchar(200) not null,
constraint pk_A_Teams primary key (cup,continent)
);

create table IF NOT EXISTS A_GROUPS (


cup int(4) not null,
groupId varchar(1) not null,
firstPlace varchar(25) not null,
secondPlace varchar(25) not null,
thirdPlace varchar(25) not null,
fourthPlace varchar(25) not null,
constraint pk_A_Groups primary key (cup,groupId)
);

create table IF NOT EXISTS A_MATCHES (


cup int(4) not null,
matchId int(2) not null,
matchDate varchar(5) not null,
stage varchar(25) not null,
team1 varchar(25) not null,
team2 varchar(25) not null,
goals varchar(5) not null,
stadium varchar(50) not null,
constraint pk_A_Matches primary key (cup, matchId)
);

create table IF NOT EXISTS A_TOP (


cup int(4) not null,
winner varchar(25),
runnerUp varchar(25),
thirdPlace varchar(25),
fourthPlace varchar(25),
goalScore varchar(200),
host varchar(50) not null,
constraint pk_A_Top primary key (cup)
);

-- insert teams' data


insert into A_TEAMS (cup, continent, teams) values (2010,'Africa','Algeria,
Cameroon, Cote d Ivoire, Ghana, Nigeria, South Africa');
insert into A_TEAMS (cup, continent, teams) values (2010,'America','Argentina,
Brazil, Chile, Honduras, Mexico, Paraguay, United States, Uruguay');
insert into A_TEAMS (cup, continent, teams) values (2010,'Asia','Japan, North
Korea, South Korea');
insert into A_TEAMS (cup, continent, teams) values (2010,'Europe','Denmark,
England, France, Germany, Greece, Italy, Netherlands, Portugal, Serbia, Slovakia,
Slovenia, Spain, Switzerland');
insert into A_TEAMS (cup, continent, teams) values (2010,'Oceania','Australia, New
Zealand');

-- insert groups data


insert into A_GROUPS (cup, groupId, firstPlace, secondPlace, ThirdPlace,
FourthPlace) values ('2010','C','United States','England','Slovenia','Algeria');
insert into A_GROUPS (cup, groupId, firstPlace, secondPlace, ThirdPlace,
FourthPlace) values ('2010','E','Netherlands','Japan','Denmark','Cameroon');
insert into A_GROUPS (cup, groupId, firstPlace, secondPlace, ThirdPlace,
FourthPlace) values ('2010','A','Uruguay','Mexico','South Africa','France');
insert into A_GROUPS (cup, groupId, firstPlace, secondPlace, ThirdPlace,
FourthPlace) values ('2010','H','Spain','Chile','Switzerland','Honduras');
insert into A_GROUPS (cup, groupId, firstPlace, secondPlace, ThirdPlace,
FourthPlace) values ('2010','F','Paraguay','Slovakia','New Zealand','Italy');
insert into A_GROUPS (cup, groupId, firstPlace, secondPlace, ThirdPlace,
FourthPlace) values ('2010','B','Argentina','South Korea','Greece','Nigeria');
insert into A_GROUPS (cup, groupId, firstPlace, secondPlace, ThirdPlace,
FourthPlace) values ('2010','G','Brazil','Portugal','Cote d Ivoire','North Korea');
insert into A_GROUPS (cup, groupId, firstPlace, secondPlace, ThirdPlace,
FourthPlace) values ('2010','D','Germany','Ghana','Australia','Serbia');

-- insert top data


insert into A_TOP values (1930,'Uruguay','Argentina','United
States','Yugoslavia','8','Uruguay');
insert into A_TOP values
(1934,'Italy','Czechoslovakia','Germany','Austria','5','Italy');
insert into A_TOP values (1938,'Italy','Hungary','Brazil','Sweden','7','France');
insert into A_TOP values (1950,'Uruguay','Brazil','Sweden','Spain','9','Brazil');
insert into A_TOP values (1954,'Germany','Hungary','Austria','Uruguay','11 - S�ndor
Kocsis (Hungary)','Switzerland');
insert into A_TOP values (1958,'Brazil','Sweden','France','Germany','13 - Just
Fontaine (France)','Sweden');
insert into A_TOP values
(1962,'Brazil','Czechoslovakia','Chile','Yugoslavia','4','Chile');
insert into A_TOP values (1966,'England','Germany','Portugal','Soviet
Union','9','England');
insert into A_TOP values (1970,'Brazil','Italy','Germany','Uruguay','10 - Gerd
M�ller (Germany)','Mexico');
insert into A_TOP values
(1974,'Germany','Netherlands','Poland','Brazil','7','Germany');
insert into A_TOP values
(1978,'Argentina','Netherlands','Brazil','Italy','6','Argentina');
insert into A_TOP values (1982,'Italy','Germany','Poland','France','6','Spain');
insert into A_TOP values
(1986,'Argentina','Germany','France','Belgium','6','Mexico');
insert into A_TOP values
(1990,'Germany','Argentina','Italy','England','6','Italy');
insert into A_TOP values (1994,'Brazil','Italy','Sweden','Bulgaria','6 - Oleg
Salenko (Russia), Hristo Stoitchkov (Bulgaria)','United States');
insert into A_TOP values (1998,'France','Brazil','Croatia','Netherlands','6 - Davor
�uker (Croatia)','France');
insert into A_TOP values (2002,'Brazil','Germany','Turkey','South Korea','8 -
Ronaldo (Brazil)','Japan, South Korea');
insert into A_TOP values (2006,'Italy','France','Germany','Portugal','5 - Miroslav
Klose (Germany)','Germany');
insert into A_TOP values (2010,'Spain','Netherlands','Germany','Uruguay','5 - David
Villa (Spain), Wesley Sneijder (Netherlands), Thomas Muller (Germany), Diego Forlan
(Uruguay)','South Africa');
insert into A_TOP values (2014,'Germany','Argentina','Netherlands','Brazil','6 -
James Rodriguez (Colombia)','Brazil');
insert into A_TOP values (2018,'France','Croatia','Belgium','England','6 - Harry
Kane (England)','Russia');
insert into A_TOP (cup, host) values (2022,'Qatar');
insert into A_TOP (cup, host) values (2026,'Canada, United States, Mexico');

-- insert match data


insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,1,'11/6','group','Uruguay','France','0:0','Cape Town Stadium,
Cape Town');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,2,'11/6','group','South Africa','Mexico','1:1','Socker City,
Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,3,'12/6','group','Argentina','Nigeria','1:0','Socker City,
Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,4,'12/6','group','South Korea','Greece','2:0','Nelson Mandela
Bay Stadium, Port Elizabeth');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,5,'12/6','group','England','United States','1:1','Royal
Bafokeng Stadium, Rustenburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,6,'13/6','group','Algeria','Slovenia','0:1','Peter Mokaba
Stadium, Polokwane');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,7,'13/6','group','Germany','Australia','4:0','Moses Mabhida
Stadium, Durban');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,8,'13/6','group','Serbia','Ghana','0:1','Loftus Versfeld
Stadium, Pretoria');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,9,'14/6','group','Netherlands','Denmark','2:0','Socker City,
Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,10,'14/6','group','Japan','Cameroon','1:0','Free State
Stadium, Bloemfontein');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,11,'14/6','group','Italy','Paraguay','1:1','Cape Town
Stadium, Cape Town');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,12,'15/6','group','New Zealand','Slovakia','1:1','Royal
Bafokeng Stadium, Rustenburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,13,'15/6','group','Cote d Ivoire','Portugal','0:0','Nelson
Mandela Bay Stadium, Port Elizabeth');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,14,'15/6','group','Brazil','North Korea','2:1','Ellis Park
Stadium, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,15,'16/6','group','Honduras','Chile','0:1','Mbombela Stadium,
Nelspruit');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,16,'16/6','group','Spain','Switzerland','0:1','Moses Mabhida
Stadium, Durban');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,17,'16/6','group','South Africa','Uruguay','0:3','Loftus
Versfeld Stadium, Pretoria');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,18,'17/6','group','France','Mexico','0:2','Peter Mokaba
Stadium, Polokwane');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,19,'17/6','group','Greece','Nigeria','2:1','Free State
Stadium, Bloemfontein');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,20,'17/6','group','Argentina','South Korea','4:1','Ellis Park
Stadium, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,21,'18/6','group','Germany','Serbia','0:1','Nelson Mandela
Bay Stadium, Port Elizabeth');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,22,'18/6','group','Slovenia','United States','2:2','Ellis
Park Stadium, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,23,'18/6','group','England','Algeria','0:0','Cape Town
Stadium, Cape Town');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,24,'19/6','group','Ghana','Australia','1:1','Royal Bafokeng
Stadium, Rustenburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,25,'19/6','group','Netherlands','Japan','1:0','Moses Mabhida
Stadium, Durban');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,26,'19/6','group','Cameroon','Denmark','1:2','Loftus Versfeld
Stadium, Pretoria');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,27,'20/6','group','Slovakia','Paraguay','0:2','Free State
Stadium, Bloemfontein');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,28,'20/6','group','Italy','New Zealand','1:1','Mbombela
Stadium, Nelspruit');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,29,'20/6','group','Brazil','Cote d Ivoire','3:1','Socker
City, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,30,'21/6','group','Portugal','North Korea','7:0','Cape Town
Stadium, Cape Town');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,31,'21/6','group','Chile','Switzerland','1:0','Nelson Mandela
Bay Stadium, Port Elizabeth');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,32,'21/6','group','Spain','Honduras','2:0','Ellis Park
Stadium, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,33,'22/6','group','Mexico','Uruguay','0:1','Royal Bafokeng
Stadium, Rustenburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,34,'22/6','group','France','South Africa','1:2','Free State
Stadium, Bloemfontein');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,35,'22/6','group','Nigeria','South Korea','2:2','Moses
Mabhida Stadium, Durban');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,36,'22/6','group','Greece','Argentina','0:2','Peter Mokaba
Stadium, Polokwane');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,37,'23/6','group','Slovenia','England','0:1','Nelson Mandela
Bay Stadium, Port Elizabeth');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,38,'23/6','group','United States','Algeria','1:0','Loftus
Versfeld Stadium, Pretoria');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,39,'23/6','group','Ghana','Germany','0:1','Socker City,
Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,40,'23/6','group','Australia','Serbia','2:1','Mbombela
Stadium, Nelspruit');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,41,'24/6','group','Slovakia','Italy','3:2','Ellis Park
Stadium, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,42,'24/6','group','Paraguay','New Zealand','0:0','Peter
Mokaba Stadium, Polokwane');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,43,'24/6','group','Denmark','Japan','1:3','Royal Bafokeng
Stadium, Rustenburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,44,'24/6','group','Cameroon','Netherlands','1:2','Cape Town
Stadium, Cape Town');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,45,'25/6','group','Portugal','Brazil','0:0','Moses Mabhida
Stadium, Durban');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,46,'25/6','group','Switzerland','Honduras','0:0','Free State
Stadium, Bloemfontein');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,47,'25/6','group','Chile','Spain','1:2','Loftus Versfeld
Stadium, Pretoria');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,48,'25/6','group','North Korea','Cote d
Ivoire','0:3','Mbombela Stadium, Nelspruit');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,49,'26/6','round of 16','Uruguay','North Korea','2:1','Nelson
Mandela Bay Stadium, Port Elizabeth');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,50,'26/6','round of 16','United States','Ghana','1:2','Royal
Bafokeng Stadium, Rustenburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,51,'27/6','round of 16','Germany','England','4:1','Free State
Stadium, Bloemfontein');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,52,'27/6','round of 16','Argentina','Mexico','3:1','Socker
City, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,53,'28/6','round of 16','Netherlands','Slovakia','2:1','Moses
Mabhida Stadium, Durban');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,54,'28/6','round of 16','Brazil','Chile','3:0','Ellis Park
Stadium, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,55,'29/6','round of 16','Paraguay','Japan','5:3','Loftus
Versfeld Stadium, Pretoria');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,56,'29/6','round of 16','Spain','Portugal','1:0','Cape Town
Stadium, Cape Town');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,57,'2/7','quarter-
finals','Netherlands','Brazil','2:1','Nelson Mandela Bay Stadium, Port Elizabeth');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,58,'2/7','quarter-finals','Uruguay','Ghana','4:2','Socker
City, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,59,'3/7','quarter-finals','Argentina','Germany','0:4','Cape
Town Stadium, Cape Town');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,60,'3/7','quarter-finals','Paraguay','Spain','0:1','Ellis
Park Stadium, Johannesburg');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,61,'6/7','semi-finals','Uruguay','Netherlands','2:3','Cape
Town Stadium, Cape Town');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,62,'7/7','semi-finals','Germany','Spain','0:1','Moses Mabhida
Stadium, Durban');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,63,'10/7','third-place play-
off','Uruguay','Germany','2:3','Nelson Mandela Bay Stadium, Port Elizabeth');
insert into A_MATCHES (cup, matchId, matchDate, stage, team1, team2, goals,
stadium) values (2010,64,'11/7','final','Netherlands','Spain','0:1','Ellis Park
Stadium, Johannesburg');
commit;

You might also like