drop table teams cascade constraints;
create table teams (
  tname varchar2(20),
  primary key (tname)
);
insert into teams values ('Braves');
insert into teams values ('Cardinals');
insert into teams values ('Cubs');
insert into teams values ('Diamondbacks');
insert into teams values ('Indians');
insert into teams values ('Red Sox');
insert into teams values ('Reds');
insert into teams values ('Rockies');
--
drop table results cascade constraints;
create table results (
  when date, -- includes time of game as well
  home varchar2(20),
  visitor varchar2(20),
  hruns number(3),
  vruns number(3),
  primary key (when,home),
  foreign key (home) references teams,
  foreign key (visitor) references teams
);
--
insert into results values ('20-MAR-2004','Rockies','Braves',10,6);
insert into results values ('20-MAR-2004','Reds','Cardinals',16,1);
insert into results values ('20-MAR-2004','Indians','Red Sox',1,0);
insert into results values ('20-MAR-2004','Diamondbacks','Cubs',10,11);
--
insert into results values ('23-MAR-2004','Braves','Cardinals',0,1);
insert into results values ('23-MAR-2004','Rockies','Indians',10,14);
insert into results values ('25-MAR-2004','Red Sox','Diamondbacks',1,0);
insert into results values ('25-MAR-2004','Cubs','Reds',10,12);
insert into results values ('27-MAR-2004','Cardinals','Cubs',7,9);
insert into results values ('27-MAR-2004','Indians','Braves',1,0);
insert into results values ('27-MAR-2004','Diamondbacks','Rockies',15,5);
insert into results values ('27-MAR-2004','Reds','Red Sox',7,6);
--
insert into results(when,home,visitor) values ('30-MAR-2004','Red Sox','Cardinals');
insert into results(when,home,visitor) values ('30-MAR-2004','Braves','Cubs');
insert into results(when,home,visitor) values ('01-APR-2004','Indians','Diamondbacks');
insert into results(when,home,visitor) values ('01-APR-2004','Rockies','Reds');
--
insert into results(when,home,visitor) values ('15-APR-2004','Cubs','Red Sox');
insert into results(when,home,visitor) values ('15-APR-2004','Diamondbacks','Braves');
insert into results(when,home,visitor) values ('16-APR-2004','Reds','Indians');
insert into results(when,home,visitor) values ('17-APR-2004','Diamondbacks','Reds');
insert into results(when,home,visitor) values ('17-APR-2004','Braves','Red Sox');
insert into results(when,home,visitor) values ('17-APR-2004','Cubs','Rockies');
insert into results(when,home,visitor) values ('17-APR-2004','Indians','Cardinals');
--
insert into results(when,home,visitor) values ('20-APR-2004','Cardinals','Diamondbacks');
insert into results(when,home,visitor) values ('20-APR-2004','Red Sox','Rockies');
insert into results(when,home,visitor) values ('22-APR-2004','Reds','Braves');
insert into results(when,home,visitor) values ('22-APR-2004','Cubs','Indians');
insert into results(when,home,visitor) values ('23-APR-2004','Cardinals','Rockies');
insert into results(when,home,visitor) values ('24-APR-2004','Red Sox','Indians');
insert into results(when,home,visitor) values ('24-APR-2004','Cardinals','Reds');
insert into results(when,home,visitor) values ('24-APR-2004','Braves','Rockies');
insert into results(when,home,visitor) values ('24-APR-2004','Cubs','Diamondbacks');
--
insert into results(when,home,visitor) values ('27-APR-2004','Reds','Cubs');
insert into results(when,home,visitor) values ('27-APR-2004','Diamondbacks','Red Sox');
insert into results(when,home,visitor) values ('29-APR-2004','Indians','Rockies');
insert into results(when,home,visitor) values ('29-APR-2004','Cardinals','Braves');
--
insert into results(when,home,visitor) values ('01-MAY-2004','Braves','Indians');
insert into results(when,home,visitor) values ('01-MAY-2004','Cubs','Cardinals');
insert into results(when,home,visitor) values ('01-MAY-2004','Rockies','Diamondbacks');
insert into results(when,home,visitor) values ('01-MAY-2004','Red Sox','Reds');
--
insert into results(when,home,visitor) values ('04-MAY-2004','Cubs','Braves');
insert into results(when,home,visitor) values ('04-MAY-2004','Diamondbacks','Indians');
insert into results(when,home,visitor) values ('06-MAY-2004','Cardinals','Red Sox');
insert into results(when,home,visitor) values ('06-MAY-2004','Reds','Rockies');
--
insert into results(when,home,visitor) values ('08-MAY-2004','Rockies','Cardinals');
insert into results(when,home,visitor) values ('08-MAY-2004','Red Sox','Cubs');
insert into results(when,home,visitor) values ('08-MAY-2004','Indians','Reds');
insert into results(when,home,visitor) values ('08-MAY-2004','Braves','Diamondbacks');
--
insert into results(when,home,visitor) values ('11-MAY-2004','Reds','Diamondbacks');
insert into results(when,home,visitor) values ('11-MAY-2004','Red Sox','Braves');
insert into results(when,home,visitor) values ('13-MAY-2004','Cubs','Rockies');
insert into results(when,home,visitor) values ('13-MAY-2004','Cardinals','Indians');
--
insert into results(when,home,visitor) values ('15-MAY-2004','Braves','Reds');
insert into results(when,home,visitor) values ('15-MAY-2004','Rockies','Red Sox');
insert into results(when,home,visitor) values ('15-MAY-2004','Diamondbacks','Cardinals');
insert into results(when,home,visitor) values ('15-MAY-2004','Indians','Cubs');
--
insert into results(when,home,visitor) values ('18-MAY-2004','Diamondbacks','Cubs');
insert into results(when,home,visitor) values ('18-MAY-2004','Reds','Cardinals');
insert into results(when,home,visitor) values ('20-MAY-2004','Braves','Rockies');
insert into results(when,home,visitor) values ('20-MAY-2004','Red Sox','Indians');
--
insert into results(when,home,visitor) values ('22-MAY-2004','Red Sox','Diamondbacks');
insert into results(when,home,visitor) values ('22-MAY-2004','Braves','Cardinals');
insert into results(when,home,visitor) values ('22-MAY-2004','Reds','Cubs');
insert into results(when,home,visitor) values ('22-MAY-2004','Rockies','Indians');
--
