Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One thing I've done before, in a similar-sounding scenario:</p> <p>Keep Roles and users in the same table.</p> <p>Have an objects table (the tables/queries/forms/etc. you will be granting permissions to)</p> <p>Have a permission table -- this is where you will link roles/users to objects (i.e., John can SELECT on table 1)</p> <p>Finally, have an Inheritance table -- this is where you will link roles/users to each other (i.e., John has permission to do whatever Role1 can do)</p> <p>For example -- a structure like this:</p> <p>For example:</p> <pre><code>Users Table: UserID -- User -- UserTypeID 1 ------- John Smith --- 1 2 ------- Sally Fort --- 1 3 ------- Public Role -- 2 4 ------- Special Role - 2 UserType Table: UserTypeID -- Description 1 ----------- Human Being 2 ----------- Role Objects Table: 1 -- Data-Entry Form 1 2 -- Data-Entry Form 2 3 -- Query 1 4 -- Table 1 Permissions Table UserID -- ObjectID -- Permission 1 -- 1 -- Update (This says John can Update Data-Entry Form 1 (via direct permission)) 3 -- 1 -- Update (This says that the Public Role can Update Data-Entry Form 1) 3 -- 2 -- Update (...as well as Data-Entry Form 2) 4 -- 3 -- Select (This says that the special role can Select from Query1) 4 -- 4 -- Insert (...the special role can Insert into Table1) Permission Inheritance Table UserID -- UserID_ToInheritFrom 1 -- 3 (this says John can do whatever the Public Role can do) 1 -- 4 (this says John can do whatever the Special Role can do) 2 -- 3 (this says Sally can do whatever the Public Role can do) </code></pre> <p>So then if you wanted to query, "What can John do?", you'd do something like this:</p> <pre><code>SELECT ObjectID, Permission FROM PermissionsTable WHERE UserID = 1 -- John has direct permission OR UserID IN (SELECT UserID_ToInheritFrom FROM PermissionInheritanceTable WHERE UserID = 1) -- John has indirect permission via the Permission Inheritance Table (or you can call it the "role -- membership table" if that's easier for you to think of that way.) </code></pre> <p>This implementation works well. If you want to see a similar implementation, look at SQL-Server's implementation (or better yet, USE it, instead of re-creating the wheel from scratch.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload