I know that there are many questions regarding SO regarding this error, but even applying what I have learned from them, I still get "cannot create table (errno: 150)"
CREATE TABLE sch_results ( id INT NOT NULL AUTO_INCREMENT, s_id INT UNSIGNED NOT NULL, r_eid VARCHAR(10) NOT NULL, cohorts INT, allstudents INT, comments TEXT, PRIMARY KEY (id), FOREIGN KEY (s_id) REFERENCES scholarships (id), FOREIGN KEY (r_eid) REFERENCES sch_recommenders (eid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I checked that foreign keys are stored exactly under this name in the respective tables.
I checked that the corresponding data types match this query. I checked that the two existing tables use InnoDB and utf8.
I have added UNSIGNED NOT NULL to foreign keys.
I indexed two foreign keys in my tables. I originally used s_id and r_id, but heard that this might cause some problems. r_eid is also unique, so I switched to this. This is not a primary key.
What am I missing? Thanks!
LESSON LEARN: Carefully check all aspects of your data types!
source share