I have two tables in a MySQL database. I create them like this:
CREATE DATABASE test;
CREATE TABLE test.testtable_1 (
PRIMARY KEY (did),
CONSTRAINT kid_fkey FOREIGN KEY (kid)
REFERENCES testtable_2 ON DELETE NO ACTION
CREATE TABLE test.testtable_2 (
I want the foreign relationship between testtable1.kid and testtable2.kid to ensure that I cannot insert rows in testtable1 where kid does not match with a kid from testtable2. However, when I look at the table in PHPMyAdmin, the relationship is not shown and I can also insert whichever data I want into testtable1, regardless of the data in testtable2.
What is the correct way to create a foreign key constraint that enforces this behaviour?