Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 12-11-2008, 11:34 AM   #5 (permalink)
dicklacara
New Member
 
Join Date: Nov 2008
Posts: 123
Default

Quote:
Originally Posted by detz View Post
If I was doing that I would store them as text files and just load them when you need them. There is no way to store book information in a relational database.
Normally, I'd agree...

...except in this case (the bible) you have lots of small files (chapter and verse) that you want to index and manipulate. So, the entire bible might require thousands of individual text files.

What's the minimum OS X file size on the iPhone?

You might be able to save a lot of Flash storage and minimize RAM use by using an SQL db over manipulating text files.

You could develop a complex scheme where you had a separate text file for each chapter, and an offset index (text file) into that file to locate the verses.

But, now, you are trying to outdo SQL at its job.

SQLite supports Blobs (fields of arbitrary size) so any field size is possible (even the entire bible in a single field).

Interestingly, I just checked, and SQLite does not enforce size limits (nor truncate) varchar fields. So, you could (conceptually, anyway) store the verses of a chapter as a many-to-one table of verses (varchar) related to a one-to-many table of chapters.

To use any SQL database intelligently and efficiently, you should: create indexes where appropriate, based on usage; consider the underlying structure of the data when making queries (manipulating data); and avoid redundancies where possible.

However, sometimes, if you break the redundancy rule, you can gain efficiency and flexibility at the expense of a little redundant data.

For example, we might have a chapter index that contained:
title: "John 3:16"
pointer/key to verse table

However, we intend to use the db by displaying the chapter title and the first few words of the verse, say in a table view.

So, every cellForRowAtIndexPath (worst case) would query the chapter index table, and the related verse table to display our row.

But, if we change our chapter index to:
title: "John 3:16"
words: "For God so loved the world..."
pointer/key to verse table

We can do a lot of manipulation (search/sort) entirely within the chapter index table (without ever accessing the verse table), and display table rows like:

John 3:16 For God so loved the world...

*

*

*

We have broken the rule, have redundant data, increased file size some... but gained a whole lot of performance in how we actually use the db.


HTH

Dick

Last edited by dicklacara; 12-11-2008 at 12:27 PM.
dicklacara is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,673
Threads: 89,155
Posts: 380,386
Top Poster: BrianSlick (7,110)
Welcome to our newest member, rockystdr
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:50 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.