I have three tables (blocks, roles, users) where the following is true in the schema:
blocks have many users
users have many blocks
users have many roles, but the roles are specific to the block (and the user)
blocks have many roles, but the roles are specific to the user (and the block)
For example:
user => john
belongs to block => 'metro' with role => 'builder'
belongs to block => 'rural' with role => 'investor'
user => dan
belongs to block => 'metro' with role => 'resident'
belongs to block => 'rural' with role => 'investor'
I have a join table named block_role_user with the following columns:
id block_id role_id user_id created modified
I guess this would be a hasandbelongstomany relationship amongst all three tables. I thought about laying this out with a hasandbelongstomany table between blocks and users and another hasandbelongstomany table between roles and users but this will not fully define the unique relationship between a block, role and user.
I'm looking for advice on the best way to approach this and appreciate any advice.
I've looked into binding the model, but this doesn't seem to apply for the unique three part relationship I have here.
I thought about creating a model called blockroleuser and setting up the relationships using standard cakephp convention. If this is an acceptable way, can you give some guidance on naming the model and controller files?
Thanks again...