I need to be able to store some information about the user and I was wondering the best way to approach this.
Social Media
id - user_id - facebook - twitter_username - display_tweets
Some quick questions:
- The Facebook field is just a yes or no to see if they have one, so I know whether or not to display the icon. Should that just be an enum 0 or 1? and 1 meaning they have one.
- Same with display_tweets should that just be an enum 0 or 1?
And then the main question is, should I just store these in the users table? So I would just add 3 fields, the facebook, twitter_username, and display_tweets. Also, some might not have either facebook or twitter. The users table already has 20 fields, so I don’t want to make it TOO big.
Thanks!
Yes, put them in your users table. Columns are cheap (if they are often null or small), particularly as your users table is guaranteed to be very small (You cannot possibly have a large number of users).
Putting things in more tables just creates more effort. I’ve previously created tables with over 50 columns (properly normalised – all 50 columns store different items of data).
It is probably a good idea to allow NULLs if the columns are not necessarily relevant to every user. “Magic values” are not a good idea (I’ve seen “” or -1 used as a “magic value” often enough).