0
I’m studying bank and my foreign key does not create, I know I’m doing something wrong, but I can not understand what there is.
these are the tablets I want to call'
create table tb_cardapio(
cd_cardapio int not null auto_increment,
nm_tipo varchar(100),
cd_comida int,
constraint fk_cardapio
primary key (cd_cardapio),
constraint fk_cardapio_comida
foreign key(cd_comida)
references tb_cardapio(cd_comida)
);
create table tb_comida(
cd_comida int not null primary key auto_increment,
nm_comida varchar(100),
vl_comida double
);
you are referencing the table itself, that row
references tb_cardapio(cd_comida)
should bereferences tb_comida(cd_comida)
, and the create of the table "tb_food" should be first– Ricardo Pontual
ah, ok! thank you very much!
– user215274