views:

227

answers:

1

Hi,

I am developing an app on Android that will randomly pick and display an inspirational quotation (or verse) from a large collection of quotations. On Android I can choose between a flat file and an SQLite database.

The app should satisfy the following conditions:

  1. Be scalable to 10^6 quotations and/or verses

  2. Be very fast (i.e. retrieve and display a quotation, immediately at the touch of a button)

  3. Be able to load new quotations from an external source (in a format I have not yet decided)

What data format must I use? Thanks.

+3  A: 

I'd go with a very simple database, single table:

Quotes
ID          sequential integer PK
Quote       text/string

with a possible "Viewed" bit field, that you can update to prevent duplicates. Generate a random value and select that row from the table, mark it viewed and be done with it.

The problem with a flat file is quickly finding and reading a quote from the middle of the file. This is what a database does well. Also with a "flat" file you'll have a lot of wasted space at the end of file lines.

Also, if you can load new quotes, why populate 10^6 at any one time? just load enough to keep the app going and march through them in a sequential order, deleting viewed ones and loading new ones. This approach would require you to keep track of the last loaded quote, so you are always loading new ones.

KM
Thanks a bunch!
Pankaj Godbole
Scalable and searchable, hmmmm - sounds like db to me :)
DroidIn.net