Hi,

I am planning an authentication system that is structured much like the
system Windows uses:
I have "users" and "groups". Groups can either contain users directly or can
contain other groups (which can again contain groups etc).

Now I am thinking on how to store and efficiently read those definitions. At
first, I thought about the this table structure (leaving out the "users"
table, which at the moment contains nothing but a userid):

CREATE TABLE groups (
        id_group INT UNSIGNED NOT NULL,
        id_target INT UNSIGNED NOT NULL,
        is_group ENUM('yes', 'no')
)

Note that id_target may both reference a user or a group, as determined by
the setting of is_group.
I don't think I can work very efficiently with this "mixed" storage, but I
haven't come up with something better yet.

Also, how would I write a query that gets me all users contained in a given
group, while at the same time dereferencing groups to the user ids contained
in them.
An example to make myself more clear:
- User ids are 1, 2, 3, 4
- Group 1 contains users 1, 2 and 3
- Group 2 contains user 4 and group 1

When I now query for group 2, I want just the user ids, i.e. 1,2,3,4
returned.

Any ideas?

Jens


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to