Thanks for this Ronan. I understand it but I have an error in my create table coding.
This is what successfully creates my table; it does not, obviously, designate the foreign key, although it's obviously there:
create table horse
(
horse_id int not null auto_increment primary key,
horse_name varchar(20) not null,
horse_colour varchar(20),
horse_sire int not null,
horse_dam int not null,
horse_born year(4) not null,
trainer_id int references trainer(trainer_id)
) type=InnoDB;
If I prepend FOREIGN KEY to my trainer_id, which would then be
FOREIGN KEY (trainer_id) int references trainer(trainer_id)
I get an error. What am I doing wrong?