sql - Looping hierarchies in membership, finding out user's permissions -


i'm crazy of problem below.
there users , groups, , groups can contain both users , other groups:
create table groupmembership (groupmembershipid, groupid, grouptypeid, memberid, membertypeid)
fields grouptypeid , mebmertypeid need provide types because have various types of groups , members.
let name me jim , have group "jim's friends" contains users bob, jane , group "jerry's friends". @ same time jerry has group "jerry's friends" containing steve, chloe "jim's group". can see there loop reference between me , jerry. says loops in hierarchies error. case? there way avoid loop?

now second question. have table permission describes subject's permissions objects:
create table permission (permissionid, subjectid, subjecttypeid, objectid, objecttypeid, permissiontypeid, [value])
every subject (user, group or else) has explicit permission object. @ end point, find out rights of user object, must render user's membership tree (via groupmembership), join permission , determine closest (in groupmembership hierarchy) , best permission.
seems it's common way, isn't it?

so, in scope need solve next tasks:
1) find out user's permission object
2) find out objects permitted user
3) find out users has explicit permissions object
seems it's common task, right?

at first wanted create universal view represents subject, object , actual permission object (remember hierarchy in groupmembership!). let me query or join other queries it. i've been trying make proper select many days 1 task , bad (there full scans etc). same situation if make functions. i'm broken :( don't know way solve tasks. architecture , tasks both common can't find solutions similar problems in internet.
please give links, advises or point errors?
thankful,
jim.

you can't in sql. group in group? there no way generate query can walk that. outside sql.

you may able make: groups: can contain users (but not groups). supergroup: can contain groups, not supergroups or users. lot easier handle.

also if stick structure, don't put both users , groups in same table. make 2 tables: table groups in group, , table users in group.

a combo have nightmare sql.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -