Jump to content
Larry Ullman's Book Forums

Facebook Locations And Normalization


Recommended Posts

A database design question - I am posting this in the Advanced section cause I want to hear what other advanced programmers think.

 

I am in the middle of developing a site for a client. The site has user profiles, which work exclusively via Facebook Connect: the first time a user logs in with Facebook Connect it reads his facebook info and puts it into a profile for him.

 

Now, I am noticing that the locations given by the Facebook API are not normalized!

 

For example:

 

"hometown": {
  "id": "108363292521622",
  "name": "Oakland, California"
  },
  "location": {
  "id": "109650795719651",
  "name": "Los Gatos, California"
  },

 

In a regular design of course, Los Angeles would be in a states table and the cities in a cities table with a foreign key to states. (All other data returned by Facebook API is properly split up according to normalization.)

 

My question: While this is not ideal design, is it nonetheless OK for me to follow this style, and simply create one locations table where cities and states are stored together like FB does? While splitting cities from states from countries would be ideal, of course, keep in mind that the script which reads the FB API data and inserts it into my websites tables to create a user profile is already very database query intensive - so far it has about 10 db queries - and I would rather not exacerbate that by adding even more queries to search and find and insert cities and states and countries.

 

And if this db design is inexcusable - why is FB doing it this way?

 

Thoughts?

Link to comment
Share on other sites

As far as I understand FB doesn't use normalized data anymore it uses non relational databses such as cassandra, so I'm not entirely surprised with the data it returns, for 99% of websites non relational databases aren't really applicable, but integrating with them I suppose would bring up this kind of discrepency. I think I would be tempted to just go with the flow and not put extra strain on your own server.

  • Upvote 2
Link to comment
Share on other sites

Also, I wouldn't be inclined, in this particular case, to ever create a states table and relate that to cities. One justification for a relational structure is the possibility that repeating values would change, or would be entered erroneously. The names and abbreviations of states are not going to change, and there's a control (the drop down menu during registration) over the entry values.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...