I'm trying to follow Zend Framework's conventions as much as possible.
In my application, is it recommended to write a DbTable, a Mapper, and the Model class for every single table in my DB? Even tables like user_permission
? (the fields on that one are user_id, permission_id
, and are both the PK).
If the answer is no, then how would a situation like that be modelled?
I wouldn't create a model for each table but for each domain object and add a reference to the other domain. In your case that'd be User
and Permission
. You'd still have to create a DbTable
for each table, but that shouldn't be too hard.
I think survithedeepend has done real good in explaining that even if it's a lot to read. This might be helpfull for further readings on data modeling ;)