I’m trying to create a relationship based tables but wondering which is the better way to manage data.
One way is to have table that has just foreign keys that manages by id’s of other tables’id’s.
Another is to have foreign key in each table itself as another column and define hasMany relationships.
What is better for managing information?
The best way is to use the standard CakePHP conventions. If you use anything else, you’ll either spend most of your time configuring Cake to work with the non-standard setup, debugging the configuration, or coding your own handlers that just replicate the built-in functionality.
For hasMany relationships the standard is to have a field called
model_idwheremodelis the foreign model’s name. For a hasMany through relationship the manual describes the correct structure.(If you have a structure that’s more complicated than what Cake can handle by default, you should post more of the structure that you have in mind.)