0

I have three fields in table user, where upto three locations for a user are saved. The schema of table is like:

UserID, name, location_1, location_2, location_3

Now the question is I also have to save user favorite location, so there are two ways.

Either I add another column (in table user), named favorite_location which will be value of one of the three saved locations.

OR

should I only store the position of location (in column favorite_location), i.e. 2 means location_2 is currently a favorite location.

UPDATE:

I have a limitation to not create another table UserLocation

3
  • if you do not want create another table, you can add a FavoriteLocation column to "user" table, that contains name of the location.
    – frogatto
    Jan 7, 2013 at 7:09
  • 3
    How about having "fav_location", "location_1", "location_2" columns. If "fav_location" is mandatory only these 3 columns will be suffice. If not, add another bit column "IsFavoriteDefined".
    – Sunny
    Jan 7, 2013 at 7:11
  • 1
    If the sequence is not important, then you can have three columns like this : location_1, location_2 and location_3. Then, enter the favorite location in location_1 and other two location in location_2 and location_3 respectively. This way, you dont need to add either a new table or a new column. Jan 7, 2013 at 7:12

1 Answer 1

0

Either way, you are going to create favorite_location column. So it's your choice to store complete location value or just the column index.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.