Search code examples
mysqldatabasecsvdatabase-normalization

which one is best way to store multiple values for a single field? Comma separated or Separate Table


I want to store user followers and following member list. Now in order to this, i am thinking to create two columns namely FOLLOWING and FOLLOWER in USER table to store comma separated values of following and followers respectively.

USER TABLE FIELDS:

userid
firstname
lastname
date_of_birth
following   //in this we store multiple following_id as comma separated
follower    //in this we store multiple follower_id as comma separated

Another way is to create tables namely FOLLOWER and FOLLOWING to store user's followers and following members id in it.

USER TABLE FIELDS:

userid
firstname
lastname
date_of_birth

and

FOLLOWER TABLE FIELDS:

userid
follower_id (also is an user)

and

FOLLOWING TABLE FIELDS:

userid
following_id (also is an user)

Since i am learning database designing, i don't have enough knowledge. So, here i am not getting proper idea of which way is proper? I have searched that using comma separated way is not a good idea but at the same time is it a good way to have multiple tables with NF ? Is there any drawback of using JOINS? Or is there any other effective way to deal with this scenario?


Solution

  • None of the above. One row per follower. Normalize your data and using it will be easy. Make it an abstract mess like you're proposing and you're life will get tougher and tougher as your application grows.