I have a database of an electronic ballot box with the following tables:
- Voter ( Pk titulodeeleior, name)
- Feedback ( Fk titulodeeleitor, vote)
VotosComputados
table should not insert a FK
any, but one that already exists in the Eleitor
table, however I am making a INSERT
and it is inserting a FK
any.
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 Eleitor
table.
Below is 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);