I’m trying to model a system with Users, Permissions and Products. The main goal is to have a way of checking if a User has a specific Permission in order to allow or deny other system operations.
So Users will have a list of Permissions and this Permissions will be given to the User when the User buys a specific Product.
This way the Users will have Permissions but the Products must have something like a “template” of the Permission that the User that buys the product will get.
This structure could be simplified to users having products and products having permissions but one of the requirements is to have the possibility of assigning a specific permission to a specific user without needing a product. And also each permission has its own context so, each permission has its own relation with a user and some other variables that mutate over time and can change the permission validity.
I’m trying to map this domain to a database structure but I’m stuck with the relation between permissions and products.
Thanks