views:

21

answers:

1

Hi,

We've Web site for software repository for internal team to access it.
Currently there are many users and divided into various groups.
To manage them, we're using string like binary nos., like '000101' and do check 1's and its position, based on that, we decide user belongs which group(s)...

For example,
'01111' => group 'test1'
'10111' => group 'test2'
'11011' => group 'exa1'
'11101' => group 'exa2'
'11110' => group 'admin'
we do 'AND' operation with user access with group...
user = 'someone', access = '01001' ... means user(someone) is belongs to groups => test2 and admin.

We store this binary nos. string to DB.
Now situation is like no. of groups increased (60+) and I am looking for something new logic instead of binary string to identify user and respective groups.

So if anyone implemented or knows different logic instead of above one then please share it, it would be great help.

Thanks in advance.

+2  A: 
CREATE TABLE groups_members (
    group_id INTEGER NOT NULL,
    member_id INTEGER NOT NULL,
    PRIMARY KEY(member_id, group_id)
);

Basic SQL. Have a members table, a groups table, and a table mapping members to groups. This is called a many-to-many relationship.

Incidentally, the numbers you've shown don't make sense... If you want 60 groups, you'd need 60-bit-long numbers, unless some groups are supersets of some others. To determine group membership, it would be an OR operation, not an AND.

Borealid