sql - MySQL Question - How to handle multiple types of users - one table or multiple? -


I am preparing a database for an organization that has many "types" of users First of all, User created table However, when all users share some common information (first name, last name, username, password etc.), then each user requires one or two additional fields that are not applicable to all users. While I can make these additional fields and set them as tap, I do not want to do this, because the fields are foreign keys and this is causing problems for me.

How is this situation generally controlled? / P>

Thanks!

Your tendency is not to create large tables with many tapes on the right.

The two most common approvals:

1) with all the common fields in it There is a user table, which includes the "UserType" field. Then there is a separate table for each user type with additional fields. All users have one line in user tables and one or more specific user type tables. It is the most generalized and most efficient for storage and quick login, it also lets you use contraints and foreign keys to make sure that all the necessary information is available for each user type.

2) Get a user table with all the common fields in it there is another table called something like UserAttributes , which contains the field, key and value for the user. Any additional metadata for any particular user can be stored here. It does not require any database administration to store new user types or metadata for each user type. However, it does not allow you to verify any data at the DB level.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -