Modify db to handle permission in a more flexible way