drop table acts_in;
drop table movies;
drop table persons;

create table persons (lname varchar(40) not null,  -- last name
                      fnames varchar(40),          -- first names
                      id int,                      -- identifying number
                      primary key (id));

create table movies (title varchar(40) not null,   -- title of the movie
                     director int not null,        -- matches an id in persons
                     year_made int not null,       -- year the movie was made
                     id int,                       -- identifying number
                     primary key (id),
                     foreign key (director) references persons);

create table acts_in (actor int,                   -- matches an id in persons
                      movie int,                   -- matches an id in movies
                      primary key (actor, movie),
                      foreign key (actor) references persons,
                      foreign key (movie) references movies
                         on delete cascade);

insert into persons (lname, fnames, id)
  select lname, fnames, id from max.persons;

insert into movies (title, director, year_made, id)
  select title, director, year_made, id from max.movies;
 
insert into acts_in (actor, movie)
  select actor, movie from max.acts_in;