Search code examples
databasedatabase-designdatabase-normalization

What is a sensible approach for enabling/disabling features on a database object?


Say I have a User database table with the regular username, password, email fields. What is a sensible way to add additional boolean fields that enable/disable features for any given user.

e.g.,

user_can_view_page_x
user_can_send_emails
user_can_send_pms
etc

Adding a bunch of boolean columns to the existing user table seems like the wrong way to go.


Solution

  • Yes, I would think that this is the wrong approach.

    I would rather create a

    User_Features Table 
    

    with columns something like

    UserID
    FeatureName
    

    And check if a given user has the feature in question enabled/entered in the table.

    You could even go as far as creating a Users_Groups table, where users are also assosiated with groups and features can be inherited/disallowed from group settings.