nhibernate - Many to many with implied and explicit relationships -
i have standard many-to-many relationship in database between person , widget. person in administrative role has access widgets. in application, want see widgets person has access to.
i have 2 high level options:
explicitly manage relationships. when person becomes administrator, relate person existing widgets. when widget created, relate widget existing administrators.
at run-time, if person administrator, assume have access widgets , bypass relationship table when loading widgets.
is 1 option better other? there name scenario?
i have been trying apply option 2 using nhibernate , can't seem figure out how bypass relationship table when loading widgets entity (and if could, unnecessarily load alot of information unless load widgets separately person entity , apply paging).
i map means of roles.
roles : person = 1 : many
so when create person, create new role, unless administrator in case use existing admin role.
then problem easy: need widgetrole table.
when new widget created, , entry automatically added widgetrole table newwidget, adminrole
when person changes admin role, change current role.
imo setup logically simpler, having special admin case.
Comments
Post a Comment