My First Database Refactoring

I spent a good portion of the day today refactoring the database used to power the Dave Matthews Band application I’ve been writing for Facebook.

I’ve been interested in writing for Facebook for some time because I believe that companies need to be expanding their online presence into applications built for major social networking platforms. It is easy to say that people should pay attention to things like OpenSocial or Facebook’s API, there have been plenty of articles about it. But nothing can convince you like building and running one yourself.

facebook application traffic statistics

My application began with only allowing users to choose a photo for their profile. Then I added the ability to select prior Dave Matthews Band shows. The problem came when people said they wanted to show their tour history further back than 2007.

I’ve been sourcing my data from the DMB Almanac, a site that I promote fairly heavily through the Weekly Davespeak’s front page and in the forums. I have a feeling I send them a good portion of traffic.

In order to get the application out as soon as possible, I decided to create my own numbering system for the shows–2007’s data was IDs 1-86.

The reason I didn’t use the almanac’s Show ID numbering was because the show id’s do not iterate consecutively. The band’s management adds shows out of chronological order. For instance they’ll announce the complete summer tour and DMB Almanac adds that–then additional dates like benefits get added.

concert posters rock show ipad iphone

Download Rock Show, the Concert Posters app for the iPhone and iPad

Using my own consecutive numbering meant that I could For loop through the list on a number of functions and random-access show information directly from the user’s show list. The refactoring meant building a translation table and script to update the old Show ID data, then change a number of functions from For to while loops that would handle non-sequential iteration the tour data.

Writing the translation script was a hurdle, I did a lot of debug output on the data I was generating to make sure it was working correctly.  You can see a bit of the verbose output here.

The application has just under 800 members now. I hope to have several thousand before DMB’s 2008 dates are announced. As the image above shows, the page has resulted in 163 new visitors, 21% of whom were new to the site. This is a low number compared to other site sources, but that may be because the app has not been in the wild for long and the skew is towards those who found out about the app from the Weekly Davespeak forums.

1 comment

Leave a comment

Your email address will not be published. Required fields are marked *