Model relations (optional level)
Hi
I am not sure how to give this thread a clear title or topic. But let me explain what I am trying to do (or find the best and "right" practice for this approch).
Think of 3 tables: Users, companies and subsidiaries. Users always belong to a company but they could (!) belong to subsidiary which is itself related to a company.
So there are 2 constellations:
Company -> Users
Company -> Subsidiaries -> Users
The relation between a company and a subsidiary is clear. But what is the best approach for storing the user relation?
Set both company_id + subsidiary_id in the user model although subsidiary_id has already a relation to a company? This could lead into illogical data, if the relation between company and subsidiary has changed.
Or leaving company_id empty in that case and only setting the subsidiary_id? In the other case leave subsidiary_id empty if a user belongs directly to a company.
What do you think?
Thanks,
Frank
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home