· 8 years ago · Feb 18, 2018, 09:48 PM
1CREATE TABLE IF NOT EXISTS `events_has_guests` (
2 `guests_id` int(10) unsigned NOT NULL,
3 `event_id` int(10) unsigned NOT NULL,
4 PRIMARY KEY (`event_id`,`guests_id`),
5 KEY `guests_id` (`guests_id`)
6) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;# MySQL zwrócił pusty wynik (zero rekordów).
7
8ALTER TABLE `events_has_guests`
9 ADD CONSTRAINT `events_has_guests_ibfk_1` FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
10 ADD CONSTRAINT `events_has_guests_ibfk_2` FOREIGN KEY (`guests_id`) REFERENCES `guests` (`guests_id`) ON DELETE CASCADE ON UPDATE CASCADE;