i am creating my own little blog and i am trying to implement the whole comments feature. i am trying to use a foreign key in my comments table but i keep on getting this error:
#1005 - Can't create table '.\blog\comments.frm' (errno: 150)
Both tables are InnoDB, journal and comments that is.
I orginally created the comments table before I read about FOREIGN KEYS, so I tried executing the following command:
ALTER TABLE comments
ADD FOREIGN KEY(comment_journal_id)
REFERENCES journal(journal_id) ON DELETE CASCADE ON UPDATE CASCADE;
I recieved the error listed above. So not really knowing what I was doing, I decided to try and create the table from scratch thinking that it might work, which it didn't. I tried:
CREATE TABLE comments(
comment_id INT,
journal_id INT,
INDEX jrn_ind( journal_id ) ,
FOREIGN KEY ( journal_id ) REFERENCES journal( journal_id ) ON DELETE CASCADE
) TYPE = INNODB
same error as above. now before i go and do something stupid, i thought i might ask for some help on this issue 😃