0

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

7
  • A user buys many products. A product has many permissions. A user has many permissions through the products they buy. – Greg Burghardt Jan 14 at 23:44
  • I wrote that option but saying that this is not possible because the permissions should be also manageable per user without the need of having a product – Fausto Sanchez Jan 15 at 1:28
  • You are conflating database design with software design. If you are looking for a proper relational database schema, this has nothing to do with code. If you are looking for a model in code, that has nothing to do with the database. The question seems to be about the database, so remove at least the "object-oriented-design" tag. – Robert Bräutigam Jan 15 at 9:23
  • @RobertBräutigam: if an object oriented language is using a relational database, then both apply. The challenge is adapting the object oriented model to the relational database. I think tackling both in one question is too broad. Focus on database first, then the OO model. – Greg Burghardt Jan 15 at 14:06
  • Would you ever need to revoke a permission that was given to the user from a purchase? – Greg Burghardt Jan 15 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.