jayLim Posted February 3, 2014 Share Posted February 3, 2014 Hello forum In chapter 3, I'm having a hard time creating the 'orders' table, I get this message: ERROR 1005 (HY000): Can't create table 'ecommerce1.orders' (errno: 150) I believe I'm typing everthing correctly, anyone else having the some issue? Link to comment Share on other sites More sharing options...
Larry Posted February 3, 2014 Share Posted February 3, 2014 You're probably having problems with the foreign key constraints. The orders table needs the users table, so you should check that it exists and try again. Or you could just remove the FK constraints clause. Link to comment Share on other sites More sharing options...
jayLim Posted February 3, 2014 Author Share Posted February 3, 2014 Thanks, problem fixed. I also got this message in the users table: ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause To solve that I used TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP in the date_created field and TIMESTAMP in date_modified Any comments? Link to comment Share on other sites More sharing options...
Larry Posted February 4, 2014 Share Posted February 4, 2014 That's fine. This may be necessary depending upon the version of MySQL in place. Link to comment Share on other sites More sharing options...
jayLim Posted February 4, 2014 Author Share Posted February 4, 2014 Ok cool, Thanks! Link to comment Share on other sites More sharing options...
imsachinraut Posted October 10, 2014 Share Posted October 10, 2014 hi all, I am a newbie to database designing & web programming. In 'orders' table, the FK constraint clause is as follows. CONSTRAINT `fk_orders_user1` FOREIGN KEY(`id`) REFERENCES `users`(`id`) Is it a typo? Because in 'orders' table if the 'users_id' is foreign key then the FK constraint clause should have been as follows. CONSTRAINT `fk_orders_user1` FOREIGN KEY(`users_id`) REFERENCES `users`(`id`) Am i right folks? regards Sachin Raut Link to comment Share on other sites More sharing options...
Larry Posted October 14, 2014 Share Posted October 14, 2014 That sounds right, but I'd have to double-check the code. In the meantime, if it works, it works. Link to comment Share on other sites More sharing options...
Recommended Posts