Predicates and Tables
A proposal is a statement that is true or false in a business situation. A predicate is an argument parameterized by the parameters of the column that defines the row. A table (base or query result) contains rows that make a true sentence from its predicate.
user (with id) U has name N R is a grantor (may grant permissions) user U has permission to update asset A grantor R gave permission to grantor E to use an operator of type 'CRUD' grantor E is of type 'user' AND grantor E has permission to update assets
Business rules
A business rule is an always-true operator that defines a term or describes a policy or process.
A user is uniquely identified by an id assigned when their cheque clears. A crudable is an asset, group or organization. A grantor is a user, group, organization. "Grantee" refers to a grantor receiving or holding a permission. Users can be in organizations.
You can make true statements that are parametric predicates. They can use parameter names bound by FOR ALL
and FOR SOME
( THERE EXISTS
). Business rules formulated in terms of such propositional predicates and / or table names are database restrictions. Given User(U,N)
and Grantor(R)
as abbreviations for the first two predicates above as predicates for the User
and Grantor
tables, the following lines say the same thing:
A user is a grantor. FOR ALL U, if U is a user then U is a grantor. FOR ALL U, (FOR SOME N, User(U, N)) IMPLIES Grantor(U). (SELECT U FROM User) ⊆ (SELECT R AS U FROM Grantor). FOR ALL U & N, User(U, N) IMPLIES Grantor(U). FOR ALL U & N, (U, N) IN User IMPLIES (U) IN Grantor.
FOREIGN KEY User (U) REFERENCES Grantor (R);
indicates what is indicated above (note its similarity to the middle two) plus that R is UNIQUE NOT NULL in the Grant.
Do not confuse rules with predicates. They have different uses and usually different forms. (A template without parameters can be used as.) A rule is a true statement; A predicate is a parameterized operator. See how my answer separates them. Base tables and query result tables have predicates. But a rule may assume that you need a basic predicate / table to write something. We have basic predicates / tables when we see from the rule that we should write down some statements about the current situation. Please note that some rules do not contain basic predicates.
You probably want to confirm the types and permissions.
A user is a grantor of type 'user'. Permission named 'C' is permission for a grantee to create a crudable. Grantor E is of type 'user'. Permission P is of type 'CRUD'. Grantor R gave permission P of type 'CRUD' on crudable C to grantee E.
Design finds necessary and sufficient rules and basic predicates
Here are the relevant predicates for recording situations that may arise in your exposure.
U identifies a user
- users can be groups.
G identifies a group user U is in group G
- users can be in the organization
O identifies an organization user U is in organization O
- groups may be in organizations
group G is in organization O
- the user will be allowed CRUD operations for the asset, group or organization.
A identifies a crudable of type 'asset' user U is permitted CRUD operations on crudable C
5.1 as an individual user or as a member of a group or as a member of an organization (or as a member of a group in which this group belongs to an organization that has permissions),
P identifies a permission organization O is permitted CRUD operations on crudable C
or because the object / group / org is viewable (readable) by anonymous users ("public")
crudable C is public
- the user must also have a set of permissions to say whether they can set the permissions above.
grantor R has permission to set CRUD permission for users on crudable C
What are the “above permissions”? Maybe you mean CRUD user permission and organization CRUD permission? Maybe you mean that there are separate permissions for Create, Read, etc.? You need to be more clear.
What are the permissions in the "permission set"? By "permission" here, you instead mean "specific permission for a specific recipient"? You must be more clear.
A way to be clearer is to give rules and predicates that are as simple as possible, but also not so simple that they do not mention the corresponding objects / values. After that, you will want to generalize several rules and predicates into separate ones. For example, instead of dealing with users, groups, organizations, and assets, there are grantors and rattles: Grantors may grant permissions.
and grantor R gives permission P to grantee E
If some of these permissions are also associated with specific grantees, you may also need predicates, such as grantor R gives permission P to grantee E re permission Q and grantee F
6.1. the user can set permissions for any asset, group or organization that they create,
user U created crudable C
or any asset, group or organization for which they were allowed to establish permits.
user U has permission to set permission P for crudable C
You need to write things like user U has name N and ...
Learn about database design
Look for database search results / SQL subtyping / inheritance / polymorphism. For example, the user, group, and organization are owners and owners of permissions; I made them subtypes of the type of grantor. Maybe you need some type of target permission type, which is the union of the indifferent and the grantor. Perhaps you need permission types. Some permissions may have associated recipients. Perhaps "C", "R", "U" and "D" are permissions, and "CRUD" is a permission type. You will probably want to record which grantor granted permission to the recipient.
Later we can replace the tables with our join if the connection is on a common PK / UNIQUE with the same set of values in both. When we can join PK / UNIQUE and FK, we can replace the tables with one, like joining them, but with a zero value of FK. There are other cases where we can easily replace multiple tables with one. But first, identify the main predicates.
Learn about the relational database. Follow some method of developing information. Best are members of the NIAM / FCO-IM / ORM2 family. Take a look at IDEF1X. Do not rely on products.
Learn about restrictions. They follow from predicates and business rules. These are truths about possible business situations in terms of predicates. Equivalently, these are truths about the possible states of the database in terms of tables. Also, learn about SQL constraints, both declarative (PK, UNIQUE, FK) and called.