I've different 3 kinds of customers and every kind of user might have posts and associations with tables that another type does not, but these have login(Unique) and password,
how does one do:
- produce a table for every type or
- create one table its them or
- produce a table its them just for login and password and separate for the other activities and bind all of them with a FK
- another thing
# 3 is the greatest from the options you recommended (up-to-date slightly for clarification):
- produce a table its them for login and password and other things that's shared along with a separate table for the other activities that aren't shared and bind all of them with a FK
Except don't keep password, store a hashed version of the salted password.
An alternate may be to assign groups and/or roles for your customers. This can be more flexible than the usual fixed table structure, permitting you to definitely add new roles dynamically. However it is dependent in your needs whether this really is helpful for you personally or otherwise.
As Aaronaught stated, within the primary table you'll need an
AccountType to make sure that a person are only able to have among the roles. You must remember to determine the worth of this column when joining the tables to make sure that a person only has one role active.
A distinctive constraint around the foreign key guarantees that the user are only able to contribute once.
I'd this exact question when creating a recent system. Here is a thread which was super-useful for me personally: http://stackoverflow.com/questions/600684/object-oriented-like-structures-in-relational-databases.
I opted for the disjoint subtypes solution, referred to well here: http://stackoverflow.com/questions/561576/polymorphism-in-sql-database-tables/561960#561960