Hi, I am starting to experiment with using InnoDB in web applications. I've setup some tables with a foreign key, but they are not behaving as expected. Here are my table CREATE statements:
CREATE TABLE sections (
section_id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(section_id),
title VARCHAR(30),
created_at int(10) NOT NULL,
updated_at int(10) NOT NULL)
ENGINE=InnoDB;
CREATE TABLE pages (
page_id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(page_id),
section_idfk INT NOT NULL,
FOREIGN KEY(section_idfk) REFERENCES sections(section_id)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE=InnoDB;
The tables create ok and I can populate them with data, however, I was expecting any changes I made to the Sections table to have an effect on the corresponding rows in the Pages table. I tried changing the ID of a section and also deleting a section entirely. In both cases, the Pages table was unaffected.
Can anyone see where I'm going wrong?
Any advice appreciated.
Thanks.