I am trying to figure out how I should go about building my database structure (tables) for user information on my website. The kinds of information that I will be storing (at this time anyways) are:
- About Me
- Birthday (January, 1, 1970)
- Sex (Male/Female)
- Interested In: (Male, Female, Both)
- Relationship Status: (Single, In a Relationship, Engaged, Married)
- Website: (mywebsite.com)
- From: (Cupertino, California)
So this is the type of information I will be storing for now. My question basically is, should I have this be one table only? Or would it be better to split the information up depending on what it was (my users have a unique ID which would go along with each table of information, obviously). So I’m not sure if I should have a table exclusively for Birthdays with the columns: userID, Month, Day, Year; or what.
If a user only needs to store one piece of information for an attribute, then you don’t need a separate table for it. For example, a user only has one birthday. The only reason you would need a separate
Birthdaystable would be if you want to store multiple birthdays for the same userid. Each one of the attributes you’ve listed look like they’d be fine in oneUserstable.As for splitting up
Birthdaysinto the columns: userID, Month, Day, Year, it all depends on how you’re going to use that information. Will you ever need to know just the Month, Day, or Year that a user’s birthday falls on? If that’s a common need, you might want to store them separately. It’s usually not, so you probably just want to store it as a single Date value.Note: You can take a look at the schema used by Stack Overflow by checking out the Data Explorer. They keep a similar collection of data in one Users table.