mysql - How do I handle multiple types of users? -


Users in my application can be one of three types: teens, individuals or members of any organization. In my user table, I have a boolean field teen (not faucet) and a foreign key organization_id (null).

If the teen is true and Organization_id is zero, the user is a teenager Teenage can not belong to an organization.
If the teenagers are liars and the organization_id is empty, then the user is a person.
If the teenagers are liars and the organization_id is not empty then users are members of any organization. / P>

There should be a better way of doing this I do not like that this case exists where teens are true and organization_ID is not empty.

Would it be better to add a new table, the organization and remove the foreign key from the organization table? I see the negative side that it will take me more time to determine if a user is not an individual or organization, and get data if appropriate.

Is this another great way to handle?

If you had a role column that was either a teenager, individual or member. You can probably consider these roles as normal at their own table, and use a foreign key:

1 teen 2 3 individual members of an organization

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -