FOREIGN KEXY in innodb
am 09.02.2007 17:33:37 von GreenRoverHallo, ich habe Folgende Tabellenstruktur auf einem Mysql 4.0.15
CREATE TABLE `news_kategorien` (
`id` int(6) unsigned NOT NULL auto_increment,
`parent` int(6) unsigned NOT NULL default '0',
`hide` enum('1','0') NOT NULL default '0',
`hide_b` enum('1','0') NOT NULL default '0',
`spacer` enum('1','0') NOT NULL default '0',
`menue` varchar(25) NOT NULL default '',
`orders` int(6) unsigned NOT NULL default '0',
`news_sort` varchar(50) NOT NULL default '',
`show_nesletter_form` enum('1','0') NOT NULL default '0',
`show_price` enum('1','0') NOT NULL default '0',
`ever_open` enum('1','0') NOT NULL default '0',
`highlite` enum('1','0') NOT NULL default '0',
`cut_imgs` enum('1','0','x') NOT NULL default 'x',
`thump_size` int(4) unsigned NOT NULL default '150',
`thump_size_direction` enum('w','h') NOT NULL default 'w',
`template` varchar(255) NOT NULL default '',
`tpl_file` varchar(255) NOT NULL default 'cats.tpl',
`std_bllt` int(5) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `news_kategorien1` (`parent`),
KEY `news_kategorien2` (`orders`),
KEY `news_kategorien3` (`hide`),
KEY `news_kategorien4` (`hide_b`)
) TYPE=InnoDB PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 AUTO_INCREMENT=293 ;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `news_news`
--
CREATE TABLE `news_news` (
`id` int(7) NOT NULL auto_increment,
`date` int(11) NOT NULL default '0',
`position` varchar(8) NOT NULL default '',
`ablaufdatum` int(11) NOT NULL default '0',
`send_abo_mail` char(1) NOT NULL default '',
`newest_news` char(1) NOT NULL default '',
`ticker_sort` varchar(255) NOT NULL default '',
`show_heading` enum('0','1') NOT NULL default '1',
`execute_php_content` enum('0','1') NOT NULL default '0',
`show_kontakt_form` enum('x','0') NOT NULL default '0',
`do_nl2br` enum('1','0') NOT NULL default '0',
`pic_to_spezial_pos` enum('1','0') NOT NULL default '0',
`kontakt_form_email` varchar(120) NOT NULL default '',
`template` varchar(255) NOT NULL default '',
`img_size` int(4) unsigned NOT NULL default '0',
`spez_img_size` int(4) unsigned NOT NULL default '0',
`von` int(6) unsigned NOT NULL default '0',
`von_type` enum('K','A') NOT NULL default 'A',
PRIMARY KEY (`id`),
KEY `news_news2` (`newest_news`,`date`),
KEY `news_news6` (`position`),
KEY `news_news7` (`date`),
KEY `news_news8` (`ablaufdatum`),
KEY `von` (`von`,`von_type`)
) TYPE=InnoDB AUTO_INCREMENT=598 ;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `news_news_kat`
--
CREATE TABLE `news_news_kat` (
`news` int(6) unsigned NOT NULL default '0',
`kat` int(6) unsigned NOT NULL default '0',
`type` enum('h','n') NOT NULL default 'h',
PRIMARY KEY (`news`,`kat`)
) TYPE=InnoDB;
Und Folger Befehl stirb mit der Meldung error: 105
ALTER TABLE `news_news_kat` ADD CONSTRAINT `kat` FOREIGN KEY (`kat`)
REFERENCES `news_kategorien`(`id`);
ALTER TABLE `news_news_kat` ADD CONSTRAINT `news` FOREIGN KEY (`news`)
REFERENCES `news_news`(`id`);
Ich habe auf der Tabelle news_news_kat habe ich auch schon einen
normalen index probiert anstatt dem PK...