-- MySQL dump 9.11 -- -- Host: serverpc Database: test -- ------------------------------------------------------ -- Server version 4.0.20-standard-log -- -- Table structure for table `s1` -- CREATE TABLE s1 ( id int(10) NOT NULL auto_increment, a varchar(25) default NULL, PRIMARY KEY (id), UNIQUE KEY a (a) ) TYPE=innodb; -- -- Dumping data for table `s1` -- INSERT INTO s1 VALUES (1,'me'); -- -- Table structure for table `s2` -- CREATE TABLE s2 ( id int(10) NOT NULL auto_increment, b varchar(25) default NULL, PRIMARY KEY (id), UNIQUE KEY b (b) ) TYPE=innodb; -- -- Dumping data for table `s2` -- INSERT INTO s2 VALUES (1,'you'); -- -- Table structure for table `s3` -- CREATE TABLE s3 ( id int(10) NOT NULL auto_increment, s1_id int(10) NOT NULL default '0', s2_id int(10) NOT NULL default '0', state int(11) default NULL, PRIMARY KEY (id), UNIQUE KEY s1_id (s1_id,s2_id), KEY s2_id (s2_id,s1_id), CONSTRAINT `s3_ibfk_1` FOREIGN KEY (`s1_id`) REFERENCES `s1` (`id`), CONSTRAINT `s3_ibfk_2` FOREIGN KEY (`s2_id`) REFERENCES `s2` (`id`) ) TYPE=innodb; -- -- Dumping data for table `s3` -- INSERT INTO s3 VALUES (2,1,1,2);