I've just started a project and need a little push in the right direction. Here is my table structure:
users departments sub-departments
------- ------- -------
id id id
name name name
email
password
created
modified
posts photos profiles
------- ------- -------
id thumbnail id
content large photo_id
created created user_id
user_id profile_id department_id
profile_id id sub-department_id
The profiles table has about 5 more fields that are inconsequential. If any of this looks a little off it probably is.
users have one department
users have one sub-department
users have many posts
users have one photo
users have one profile
What I "wanted" to do was create all my tables I needed and bring them all together under the profile table using foreign keys. A CakePHP snippet of my profile model looks like:
var $belongsTo = array('User', 'Department', 'Sub_Department', 'Photo')
var $hasMany = array('Comment');
If by now you're thinking "WTF is this crap?".. I'm right there with you. This association works in scaffolding. But I don't want to run into trouble when I really start plugging in my logic.
I'm still new to ERD and CakePHP. Should I declare everything belonging to the User and under my ProfilesController query from there like $this->Profile->User->find('all', array('contain' => ....)); ?
I'm a little lost at this point. Any help would be appreciated. How would you implement this?