Scenario:
I have organization, in org I have departmenst, in depts' I have groups, in groups I have users.
I have courses. I can give access to any combination of users/groups/departments/organizations.
Each level inherit the access it's parent has (so every course which is available to the organization is also available to all of it's department and so on).
The amount of elements in the system does not allow me to load that ACL tree to memory, I need to query it. Common query would be for a user to login and see the list of courses which are relevant to him (I might have hundred of courses).
What would be a good schema to store and query such info.
Right now I have a table for each level and for each course I have to check each table if it is there.