Reputation: 1
I have successfully been adding foreign key constraints to tables, but suddenly mysql has started throwing this error at me. I have read previous posts for the most probably causes of this error and none of them seem to apply to my case. Here are my create statements
CREATE TABLE activity (
id SMALLINT NOT NULL PRIMARY KEY,
name VARCHAR (200) NOT NULL,
description VARCHAR (200) NULL,
ageGroup VARCHAR(10) NULL,
createdBy TINYINT NOT NULL DEFAULT 1,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY (name)
);
mysql>
CREATE TABLE activity_game (
id SMALLINT NOT NULL PRIMARY KEY,
name VARCHAR (200) NOT NULL,
description VARCHAR (200) NULL,
activityId SMALLINT NOT NULL,
createdBy TINYINT NOT NULL DEFAULT 1,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (activityId) REFERENCES actvity (id)
);
ERROR 1215 (HY000): Cannot add foreign key constraint
mysql>
Version: '5.6.13' socket: '' port: 3306 MySQL Community Server (GPL)
Any help is greatly appreciated.
Upvotes: 0
Views: 1331