Hi,
I'm experiencing some difficulties with foreign key constraints. I have three tables:
Features
ID PK AUTO_INC
Title VARCHAR
Subscriptions
ID PK AUTO_INC
Title VARCHAR
Subscriptionfeatures
ID PK AUTO_INC
feature_id INT (index)
subscription_id INT (index)
When I have the following records
Features
1 Testfeature
Subscriptions
1 Testsubscription
I can insert the following record in Subscriptionfeatures when defining a FK constraint as follows
ALTER TABLE subscriptionfeatures ADD CONSTRAINT FK_feature FOREIGN KEY (feature_id) REFERENCES features(id);
Subscriptionfeatures
x 1 1 => ok
But I can not insert the identical record when adding an ON DELETE CASCADE clause to the FK constraint, but i must admint i do not understand its reason for denial!
ALTER TABLE subscriptionfeatures ADD CONSTRAINT FK_feature FOREIGN KEY (feature_id) REFERENCES features(id) ON DELETE CASCADE;
Subscriptionfeatures
x 1 1 => fails
Any help on this would be greatly appreciated!