I\'m developing an application for our company that eventually will have lots of ways of restricting users to particular sections/modules. While the application is still small,
In a very famous MySQL performance book High Performance MySQL, the author specifically mentioned ACL as where data type like SET
could be used. They use following example to demonstrate such use cases:
CREATE TABLE acl (
permissions SET('CAN_READ', 'CAN_WRITE', 'CAN_DELETE') NOT NULL
);
INSERT INTO acl VALUES ('CAN_READ,CAN_WRITE');
SELECT permissions FROM acl WHERE find_in_set('CAN_READ', permissions);
The problem is that, mentioned in the book as well, you can't modify the permissions set easily (you have to use ALTER TABLE
), neither can you declare a column typed SET
as an index, which may causes performance issue.
You can also use something like TINYINT
to "wrap" the ACL list, the cons is that it's harder to read as well as to code SELECT
sentence.