Muncul Cannot delete or update a parent row: a foreign key constraint fails

sore agan" saya newbie di php dan sql nih.. saya ingin bertanya gimana caranya menghapus 1 row yang memiliki foreign key di table lain.. soalnya ketika saya mencoba untuk mendelete row tersebut, muncul error di bawah ini: Cannot delete or update a parent row: a foreign key constraint fails (`ebudget`.`budget`, CONSTRAINT `budget_id_event_foreign` FOREIGN KEY (`id_event`) REFERENCES `event` (`id_event`))

berikut adalah table saya:

 CREATE TABLE `event` (
 `id_event` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `id_department` int(10) unsigned NOT NULL,
 `id_event_type` int(10) unsigned NOT NULL,
 `name_event` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
 `description_event` text COLLATE utf8mb4_unicode_ci NOT NULL,
 `location_event` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
 `regular_event` tinyint(1) NOT NULL,
 `start_date` date NOT NULL,
 `end_date` date NOT NULL,
 `repeat_event` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
 `publication_date` date NOT NULL,
 `registration_date` date NOT NULL,
 `image_event` blob,
 `num_participant_event` int(11) NOT NULL,
 `created_at` timestamp NULL DEFAULT NULL,
 `updated_at` timestamp NULL DEFAULT NULL,
 PRIMARY KEY (`id_event`),
 UNIQUE KEY `event_name_event_unique` (`name_event`),
 KEY `event_id_department_foreign` (`id_department`),
 KEY `event_id_event_type_foreign` (`id_event_type`),
 CONSTRAINT `event_id_department_foreign` FOREIGN KEY (`id_department`) REFERENCES `department` (`id_department`),
 CONSTRAINT `event_id_event_type_foreign` FOREIGN KEY (`id_event_type`) REFERENCES `event_type` (`id_event_type`)
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
avatar jvic96
@jvic96

1 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban