I'm having hard time creating a table in maria db with foreign key and I can't figure it out.
I got that message : "Can't create table evanightdb
.events_liked
(errno: 150 "Foreign key constraint is incorrectly formed")".
The table I try to create :
CREATE TABLE events_liked (
id INT NOT NULL AUTO_INCREMENT,
id_events int(11),
title_event text,
event_liked int NOT NULL,
PRIMARY KEY ID,
FOREIGN KEY (id_events) REFERENCES event_details(`id`),
FOREIGN KEY (title_event) REFERENCES event_details(`title`)
)
And this is the table "event_details".
CREATE TABLE `event_details` (
`id` int(11) NOT NULL,
`event_url` varchar(300) NOT NULL,
`url` varchar(300) NOT NULL,
`title` text NOT NULL,
`description` text DEFAULT NULL,
`event_image_url` text DEFAULT NULL,
`image_path` text DEFAULT NULL,
`address_1` text DEFAULT NULL,
`address_2` text DEFAULT NULL,
`latitude` decimal(10,8) DEFAULT NULL,
`longitude` decimal(10,8) DEFAULT NULL,
`event_by` text DEFAULT NULL,
`genre` varchar(255) DEFAULT NULL,
`start_time` timestamp NULL DEFAULT NULL,
`start_time_not_parsed` datetime DEFAULT NULL,
`end_time` timestamp NULL DEFAULT NULL,
`duration` time DEFAULT NULL,
`ticket` text DEFAULT NULL,
`check_address` varchar(255) DEFAULT NULL,
`going` text DEFAULT NULL,
`interested` text DEFAULT NULL,
`createdAt` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`),
UNIQUE KEY `url` (`url`);
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;