0
I cannot create the fk’s from the location table, appears Error Code: 1215. Cannot add Foreign key Constraint
create table automovel(
placa varchar(7) not null,
cor varchar(20),
num_portas int,
tp_combus varchar(30),
km float not null,
renavam float not null,
chassi varchar(30) not null,
vlr_loca float,
modelo varchar(30) not null,
marca varchar(20),
primary key (placa)
);
create table locacao(
pedido int auto_increment not null,
placa varchar(7),
dt_loca date,
hr_loca datetime,
dt_dev date,
hr_dev datetime,
km float,
vlr_loca float,
dev int,
primary key (pedido),
FOREIGN KEY (placa) REFERENCES automovel(placa),
FOREIGN KEY (km) REFERENCES automovel(km),
FOREIGN KEY (vlr_loca) REFERENCES automovel(vlr_loca)
);
The foreing key ONLY connects to the Primary Key of the referenced table.
– Motta
Our really, I didn’t pay attention. Thank you friend!
– pedromilard
@Motta put his comment as answer so he can choose as the best answer and close the question.
– Leticia Rosa