views:

97

answers:

3

I am working on the design and implementation of an iPhone application ( a newbie, but I am getting the hang of it) where a person can download specific contact information about teachers based on their majors.

The information is currently on different edu websites. And I have exported the information into SQLite databases. Is it possible to develop the application that when it is first initiated, it can give the user the option of which particular SQLite database they want for their application?

Or if not, would it be better to merge all the DBs into one DB, and allow the user the option of downloading specific information from the SQLite db.

I see that the db's can be downloaded into an app, but have yet to find a solution where there can be an option to download from different SQLite dbs. Thanks!

A: 

Mark,

By setting some variable to the database name via an NSString, you should be able to open up any database you want that is bundled with the app when it's submitted. For instance,

declare variable: NSString *databaseName;

set database name: databaseName = @"teachersDBNumber1.sql";

and then when you open it up using the file path, you get the file path for whatever databaseName is set to.

If you want to open a different one, just set databaseName to a new string like databaseName = @"teachersDBNumber2.sql"; find the path for it and then open it up.

You should be able to find a number of good SQLite db tutorials out there for how to open it, read the data, etc.

iWasRobbed
A: 

How would this work with multiple databases (such as an array of databases to choose from?). The app will be used by over 4,000 people who would need just 1 of 40 different SQLite databases.

A: 

I would put all the databases on a web server; that way you can update them anytime you want, without redistributing the app. (I do this for fringegenie.com)

Use NSMutableURLRequest to download the file you want and save it. The reason I suggest NSMutableURLRequest is so that you can add the If-Modified-Since header. That way, you can make the request with the date of the last download and the server will respond "304 not modified" if you have not updated it on the server. If there is a new version, the server would give a "200 OK" and send the file.

That said: how big would a single large database be? Likely not very large, so you might as well make one database. Either way: the above is still valid for updates to the big one.

Hope that helps!

PS: Use http://gusmueller.com/blog/archives/2008/03/fmdb_for_iphone.html to access you SQLite database.

baswell