Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

Graves Robber
($1.99)

African Adventure
($0.99)

iTazer
($0.99)

ArtStudio
($3.99)

Pigs Vs Wolves
($1.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
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,753
Threads: 38,524
Posts: 169,208
Top Poster: smasher (2,543)
Welcome to our newest member, edcruise
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:12 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.