title: Problem with creating foreign key which refers to a composited primary key parent
body: <p>In the mysql code I pasted, the second foreign actor_id_FK cannot be added with error (1215 cannot add foreign key constraint). Where is the problem?</p>
  
  <pre><code>create table castings
  (
      movieid int,
      actorid int,
      primary key (movieid, actorid)
  );
  
  create table movies
  (
      id int primary key
  );
  
  create table actors
  (
      id int primary key
  );
  
  alter table movies
  add constraint movies_id_FK
  foreign key (id) references castings(movieid);
  
  alter table actors
  add constraint actors_id_FK
  foreign key (id) references castings(actorid);
  </code></pre>