drop database if exists mydb1;

create database if not exists mydb1;

use mydb1;

drop table if exists mytable;

create table if not exists mytable (
  sid char(5),
  name varchar(30),
  addr varchar(30),
  city varchar(30),
  state char(2),
  constraint mytable_PK primary key (sid));

drop table if exists myemail;

create table if not exists myemail (
  sid       char(5),
  emailaddr varchar(70),
  constraint myemail_PK primary key (sid,emailaddr),
  constraint myemail_FK1 foreign key (sid) references mytable (sid));

insert into mytable (sid, name, addr, city, state) values ('12345','John Doe','123 main St','anytown','PA');

insert into myemail (sid, emailaddr) values ('12345','jdoe@yahoo.com');

select * from mytable;

select * from myemail;

select mytable.sid, name, addr, city,emailaddr
from mytable, myemail
where mytable.sid = myemail.sid ;

insert into myemail (sid, emailaddr) values ('12345','jdoe@gmail.com');
insert into mytable (sid, name, addr, city, state) values ('12346','Jane Doe','123 main St','anytown','PA');

insert into myemail (sid, emailaddr) values ('12346','janedoe@gmail.com');


insert into mytable (sid, name, addr, city, state) values ('12345','Ralph Croce','333 chestnut St','anytown','PA');

insert into myemail (sid, emailaddr) values ('12345','jdoe@hotmail.com');