i have to design a user account/profile tables for a university project. The basic idea i have is the following:
- a table for user account (email, username, pwd, and a bunch of other fields)
- a user profile table.
It seems to me that there are two ways to model a user profile table:
put all the fields in a table [UserProfileTable]
UserAccountID (FK) UserProfileID (PK) DOB Date Gender (the id of another table wich lists the possible gender) Hobby varchar(200) SmallBio varchar(200) Interests varchar(200)
...
Put the common fields in a table and design an ProfileFieldName table that will list all fields that we want. For example:
[ProfileFieldNameTable] ProfileFieldID int (PK) Name varchar
Name will be 'hobby', 'bio', 'interests' etc...Finally, we will have a table that will associate profiles with profile fields:
[ProfileFieldTalbe]
ProfileFieldID int (PK)
UserProfileID FK FK
FieldContent varchar
'FieldContent' will store a small text about hobbies, the bio of the user, his interests and so on.
This way is extensible, meaning that in this way adding more fields corresponds to an INSERT
.
What do you think about this schema?
One drawback is that to gather all profile information of a single user now i have to do a join.
The second drawback is that the field 'FieldContent' is of type varchar
. What if i want it to be of another type (int
, float
, a date
, a FK to another table for listboxs etc...)?