I'm designing the DB for the first project with Cake and having problem with duplicated foreign key constraint.
I create the db model in mysql workbench, something like
student table id/name/
studentProfile table
id/profile_value/student_id
Foreign Key: (**student_id**) Ref student.id
student_class table
student_id
class_id
Foreign Key: (**student_id**) ref student.id
class table id/className
I got error#121 when insert into mysql.After reading, it's caused by the duplicated foreign key. (http://thenoyes.com/littlenoise/?p=81)
But as stated in cakephp's doc, foreign key = name of the related table followed by _id. So if there're multiple foreign keys pointing to the same field, there will be duplications.
Foreign keys in hasMany, belongsTo or hasOne relationships are recognized by default as the (singular) name of the related table followed by _id. So if a Baker hasMany Cake, the cakes table will refer to the bakers table via a baker_id foreign key. For a multiple worded table like category_types, the foreign key would be category_type_id.
Any suggestions?
I got error#121 when insert into mysqlplease show some code and the exact error message demonstrating you doing that - that sql error is related to creating tables, which CakePHP doesn't do for you when creating data. - AD7six