Hi guys, I'm just making a reference to the foreign keys of the parent table in the child table. When I try to delete a row from the parent table whose link is in the child table, surprisingly this allows me to delete it. I tried to create the child table explicitly, writing on the restriction on deletion, as well as without it, but without help. Any idea why this is happening? .Below is the code I use when creating tables.
CREATE TABLE region ( id int PRIMARY KEY AUTO_INCREMENT, name varchar(50) NOT NULL ); CREATE TABLE aggregator ( id int PRIMARY KEY AUTO_INCREMENT, name varchar(50) NOT NULL ); CREATE TABLE gateway ( id int PRIMARY KEY AUTO_INCREMENT, name varchar(50) NOT NULL, region_id int , aggregator_id int , is_public boolean DEFAULT 0 NOT NULL, FOREIGN KEY (region_id) REFERENCES region(id), FOREIGN KEY (aggregator_id) REFERENCES aggregator(id) );
source share