I try to learn from book Professional PHP6 and in chapter 3 I need to create tables:
CREATE TABLE `entity` ( `entityid` SERIAL PRIMARY KEY NOT NULL, `name1` varchar(100) NOT NULL, `name2` varchar(100) NOT NULL, `type` char(1) NOT NULL );
and
CREATE TABLE `entityaddress` ( `addressid` SERIAL PRIMARY KEY NOT NULL, `entityid` int, `saddress1` varchar(255), `saddress2` varchar(255), `scity` varchar(255), `cstate` char(2), `spostalcode` varchar(10), `stype` varchar(50), CONSTRAINT `fk_entityaddress_entityid` FOREIGN KEY (`entityid`) REFERENCES `entity`(`entityid`) );
result is error: #1215 - Cannot add foreign key constraint
I check in original code for that book and there is sql file, which give me same error. ...is there anything wrong, or is something with my db in xampp? I try to create only tables and then create relation in designers, but I got program error...
I set InnoDB engine.
Thanks for any suggestion.