I'm trying to design a database, in which one of the entities would be a User and one of its attributes would be programming_languages which should in theory hold a list of programming languages a user knows. What would be the best approach to designing such a database, since the cell can only hold a single value? Should I create a separate table in which each row would hold a user's id and one of the languages he/she knows? Or is there a better approach?
Add a comment
|
1 Answer
Having multiple values in a field is only useful if the data is static and not changing in the database, i.e. if you only read the field out of the database and process it afterwards.
Better is to create a separate table with userID and Language. The combination of both will be the primary key. This is the rule as per Database Normalization.
UserID Language
User1 a,b,c
User2 x,y
After Normalization
UserID Language
User1 a
User1 b
User1 c
User2 x
User2 y