On Mon, Apr 5, 2010 at 4:18 PM, Aveek Misra <ave...@yahoo-inc.com> wrote:
> I have the following two tables > > CREATE TABLE `cfg_tags` ( > `cluster` varbinary(128) NOT NULL, > `tag` varbinary(128) NOT NULL, > `user` varchar(40) NOT NULL, > PRIMARY KEY (`cluster`,`tag`) > ) ENGINE=InnoDB DEFAULT CHARSET=latin1 > > > CREATE TABLE `cfg_cluster_info` ( > `cluster` varbinary(128) NOT NULL, > `admin` varbinary(128) NOT NULL, > PRIMARY KEY (`cluster`), > CONSTRAINT `cfg_cluster_info_ibfk_1` FOREIGN KEY (`cluster`) REFERENCES > `cfg_tags` (`cluster`) ON DELETE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=latin1 > > > mysql> select * from cfg_tags; > +-----------+------+--------+ > | cluster | tag | user | > +-----------+------+--------+ > | mycluster | tag1 | aveekm | > | mycluster | tag2 | aveekm | > +-----------+------+--------+ > > Now when I delete one row from this table for the cluster 'mycluster', all > the matching rows in the table cfg_cluster_info are deleted. However this is > not what I intended. I want that the delete cascade should take effect when > "all" the rows in cfg_tags with 'mycluster' are deleted. Should I then > remove the "delete cascade" condition and take care of this myself? > > > Thanks > Aveek > how data 'mycluster' can duplicate, while he is the primary key in cfg_tags? -- Muhammad Subair