Just for my own sanity I need some confirmation. I'm not new to making databases but usually make the tables on the fly and build statements with joints if necessary. Now starting with cake and the relations in the models are driving me nuts.
I've used mySQL workbench to create the tables (as a InnoDB). And also set the relationships in there (all non-identifying). Including Integrity constrains, if a referenced table is mandatory or not. Is that needed in CakePHP? phpmyadmin is picking up the relations in the view section (never knew it was there) but when I create the models with "cake bake" I get confused. Why can't cake find those keys automatically in the database? as far as I know I don't need any HABTM tables. (thank God) When it comes to setting the relations I get confused. Let me give an example. I have a User table, a sponsor table and a permission table Not every user is a sponsor. But every sponsor is a user. So this looks like: USERS id (INT) sponsor_id (INT) permission_id (INT) SPONSORS id (INT) PERMISSIONS id (INT) Do I just set up "Sponsors hasmany users (foreign key being sponsor_id)" or is it the other way around? And what if a relation is mandatory like with the permissions? Is it just the same? Being: permissions hasmany users with the foreign key on permission_id? Last question about the relationships, where does belongto fit in? or is that only being used in conjunction with hasone? I only have 1:n relations in my database, no 1:1, so I don't need that? One general question. Have a couple of other tables. and fill a tinyint in the user table if there is a record relating to the user in some of those tables. I used to do that to just speed things up in my old way of programming. So I didn't have to make a joint SQL statement to look it up in one php page and then show a new page and doing the joint again. if the tinyint was ticked I make a link and have the other page do the joint statement to show the result. Else the link wasn't there. "select has_thing from user" is quicker than writing out the full joint statement. Is CakePHP always making the joint connections when doing the view, or can I still do it the same way and have less calls to the database? Sorry for the many questions. As Cake is restricting me to make relationships from the start I want to get the start right before I continue. In the past I figured out the joins on the way. And alter the tables accordingly. Daniel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---