mercredi 4 mars 2015

flexible roles and permssions databse schema

I have a question about roles and permissions schema. I understand there are existing based schemas to do manage and define this.


But I wanted to understand if there are potential issues or bad practices with the folllowing approach.


Here is how I envision the role table to be like:



Role:
id(pk)
name(varchar)
description(varchar)


This is my permissions table:



Permissions
id(pk)
role_ids(array of role ids)
Name
Description


Each permission can belong to many roles.


To identify the above, I am storing an array of role_ids in the role_ids field.


Is the above pratice considered bad?


Would it cause issues when adding new roles or assigning permissions to different roles. Will it be programatically inefficient to insert and delete from the above array?


I looked up existing approaches but some of them seem too complicated for my simple use case.


Aucun commentaire:

Enregistrer un commentaire