#6 MilanL
každopádně při 1:N tam ta zpětná vazba tj detail:id do Order nepatří
a ten foreign klíč má být u detailu, takhle jak to máš ti to právě ten detail blokuje, takže
DROP TABLE IF EXISTS `order`;
CREATE TABLE `order` (
`order_id` int(11) NOT NULL AUTO_INCREMENT,
`state` enum('NOVÁ','PODEPSÁNO','UHRAZENÁ ZÁLOHA','VE VÝROBĚ','SKLAD','HOTOVO','PŘED DOKONČENÍM','STORNO','REKLAMACE') COLLATE utf8_czech_ci NOT NULL,
`date` datetime NOT NULL,
`number` int(11) NOT NULL,
`serial_number` varchar(155) COLLATE utf8_czech_ci NOT NULL,
`type` varchar(155) COLLATE utf8_czech_ci NOT NULL,
`commodity` varchar(255) COLLATE utf8_czech_ci NOT NULL,
`construction_date` datetime DEFAULT NULL,
`construction_team` int(11) NOT NULL,
`state_date` datetime DEFAULT NULL,
`weight` int(100) DEFAULT NULL,
`invoices_id` int(11) NOT NULL,
`client_id` int(11) NOT NULL,
`dealer_id` int(11) NOT NULL,
`source_id` int(11) NOT NULL,
`price` float NOT NULL,
PRIMARY KEY (`order_id`),
KEY `client` (`client_id`),
KEY `dealer` (`dealer_id`),
KEY `source` (`source_id`),
KEY `construction_team` (`construction_team`),
KEY `invoices` (`invoices_id`),
CONSTRAINT `order_ibfk_14` FOREIGN KEY (`client_id`) REFERENCES `client` (`client_id`),
CONSTRAINT `order_ibfk_15` FOREIGN KEY (`dealer_id`) REFERENCES `dealer` (`dealer_id`),
CONSTRAINT `order_ibfk_16` FOREIGN KEY (`source_id`) REFERENCES `source` (`source_id`),
CONSTRAINT `order_ibfk_17` FOREIGN KEY (`construction_team`) REFERENCES `construction_team` (`construction_team_id`),
CONSTRAINT `order_ibfk_6` FOREIGN KEY (`invoices_id`) REFERENCES `order_invoices` (`invoices_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
DROP TABLE IF EXISTS `order_detail`;
CREATE TABLE `order_detail` (
`order_detail_id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` int(11) NOT NULL,
`supplier` enum('petecki','kns','witraz','alsecco','pagen','int_dvere','kasko_z','kasko_s','paramont','vrata','rolety','vyplne','purenit','ostatni') COLLATE utf8_czech_ci NOT NULL,
`price` float DEFAULT NULL,
PRIMARY KEY (`order_detail_id`),
KEY `order_id` (`order_id`),
CONSTRAINT `order_ibfk_27` FOREIGN KEY (`order_id`) REFERENCES `order` (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;