I have two tables named
MEMBER - columns id(primary key), name, email &
TOPICS - columns id, topic_type, created_by.
I want to create a new table MEMBER_TO_TOPICS which maps member to topics, which has columns memberid(foreign key of member table id), topicid(foreign key of topic table id), created_time.
Here is the query am trying to execute .
CREATE TABLE `gsraisin`.`member_to_topics` (
`member_id` VARCHAR(50) NOT NULL,
`topic_id` VARCHAR(50) NOT NULL,
`created_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`member_id`, `topic_id`),
CONSTRAINT `FK_member_to_topics_memberid` FOREIGN KEY `FK_member_to_topics_memberid`
(`member_id`)
REFERENCES `member` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION,
CONSTRAINT `FK_member_to_topics_topicid` FOREIGN KEY `FK_member_to_topics_topicid`
(`topic_id`)
REFERENCES `topics` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
ENGINE = InnoDB;
But getting the following error while executing - MYSQL Error Number 1005 can't Create table member_to_topics (errno:121)