0
I have a database of an electronic urn with the following tables:
- Voter(Pk title )
- Votoscomputers(Fk quibbler , vote)
To my knowledge, the table VotosComputados
should not insert a FK
any, and yes one that already exists in the table Eleitor
, but I’m making a INSERT
and he’s inserting a FK
whichever.
In short:
When I make a INSERT
in the table that has the foreign key, it is letting me insert a key that is not registered in the table Eleitor
.
Below follows how I created my tables:
CREATE TABLE Eleitor(
titulodeeleitor VARCHAR(150) ,
nome VARCHAR(30) NOT NULL ,
primary key (titulodeeleitor)
);
create table votoscomputados(
titulodeeleitor varchar(150),
votoinserido int
);
alter table votoscomputados add foreign key (titulodeeleitor) references Eleitor(titulodeeleitor);