Minimum number of groups required to cover user / product rights

I have a list of 365 customers. Each of them has a potentially unique list of products that they are allowed to order, up to 18 out of 24 products (currently). I would like to use groups to assign permissions. How to determine the minimum number of unique permission sets?

I have a hunch that the answer includes relational division, but I'm still very fuzzy how this works.

To clarify : I am not interested only in users who have the same permissions. I want to find groups that I can use, each user who is potentially a member of several groups can play permissions. For example, group "A" may have a resolution of 99498; group "B" has permission to 99507, 99508, 99512. All three users in the truncated data below will be members of "A", and only the first two will be members of "B".

CREATE TABLE UsersProducts ( [User] INTEGER NOT NULL, [Product] INTEGER NOT NULL, PRIMARY KEY ([User],[Product]) ) CREATE TABLE GroupsProducts ( [Group] INTEGER NOT NULL, [Product] INTEGER NOT NULL, PRIMARY KEY ([Group],[Product]) ) CREATE TABLE GroupsUsers ( [Group] INTEGER NOT NULL, [User] INTEGER NOT NULL, PRIMARY KEY ([Group],[User]) ) -- Given this UsersProducts information, I want --the GroupsProducts and GroupsUsers tables filled. INSERT UsersProducts ( [User],[Product] ) VALUES (11804,99498), (11804,99506), (11804,99507), (11804,99508), (11804,99512), (11804,99547), (11804,99592), (11804,99594), (11804,99647), (11804,99658), (11804,99660), (11804,99667), (11804,99694), (11804,99700), (11804,99771), (11947,99498), (11947,99506), (11947,99507), (11947,99508), (11947,99512), (11947,99547), (11947,99592), (11947,99594), (11947,99647), (11947,99658), (11947,99660), (11947,99667), (11947,99700), (11947,99720), (11947,99771), (12009,99498), (12009,99506), (12009,99507), (12009,99508), (12009,99512), (12009,99547), (12009,99575), (12009,99592), (12009,99594), (12009,99596), (12009,99647), (12009,99658), (12009,99660), (12009,99667), (12009,99694), (12009,99700), (12009,99720), (12009,99771), (12353,99498), (12353,99512), (12353,99547), (12353,99575), (12353,99592), (12353,99594), (12353,99596), (12353,99647), (12353,99658), (12353,99660), (12353,99667), (12353,99694) -- etc. 365 distinct users, 28 distinct products. 4012 pairings. 
0
source share
1 answer

Thanks to Anon and Gordon Linoff and a lot of searching in their own way: this is an example of a cover problem, or perhaps even more complex, and the solution is simply not worth it. We will come with a solution for 24 groups, with some users simultaneously being members of 18 groups. This, as you know, is far from minimal, but it will work and that’s all we need. Only the input phase requires caution.

0
source

Source: https://habr.com/ru/post/1258922/


All Articles