designing database tables using JDBC -


I am creating a user table using JDBC and MySQL, each user's permission list that contains the integer value.

I am surprised that I should use an array to store these values ​​and then there should be only 1 record for this user in the table, or just create a new table that includes 2 columns Are: User IDs and permissions, and then many records for each user that specify the user name in a column and specify a permissive value in the second column.

The second option seems unusable because the permission value is a simple object that is similar to any other object (for example a student and course list, because the course is associated with many other objects such as grades, teacher, etc.) So, it is natural to keep many records in this case), but the first one seems a bit unnatural for me, so if someone experiences these things and I am " Natural "design? Thanks

"I do not need this, like I said, the permission is only one integer value (No name or id). I have a question that can run through the details of my question "

Consider the following statement

  • User Noona has 5, 6, and 7 permissions
  • Users API have 1 and 9 permissions

Which more powerful users Is the person? What user can do noona with the permissions of 5, 6 and 7? What does mean those permissions?

A name or identifier is present outside the database without the meaning of the data. There are occasions when it is valid, but generally it is an indicator of poor design decisions. This is why everyone is standing as an intersection table between a permission table and a UserPermissions that and the user.

The correct selection of a separate UserPermissions table (whether you store the meaning of permissions), a column for value makes it easy to find all those users who have permission 4 or the user address That user is allowed to noona .

In any event, arrays are unnatural


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -