Database vs Array (was: Filtering array vs plain list)

Sarah Reichelt sarah.reichelt at gmail.com
Sun Feb 3 17:35:26 EST 2008


> 1.  Would the user need to install something extra to use it?  If so,
> would it be a separate program from my app that I would have to deal
> with tech support if the user upgrades his system?  Thousands of
> people download my apps from around the world, so added tech support
> is a big bad.

SQLite is now part of Revolution, so your users would not need to
install anything extra. However it would be adding a new library to
your app which might need tech support.

> 2.  Is there a way to make it * part * of my app, running for both
> Mac and Windows without a bunch of hoo hah from me?  I don't use
> installers.  My apps are designed to launch, and create any separate
> files they need during initial launch.  Stacks that need to be
> updated (i.e. preferences, saved games, etc.) are stored compressed
> in custom properties, and on initial launch decompressed and saved to
> a writeable location.  That becomes the permanent prefs file or save
> file or whatever (which is what the database would be).  (Used to be
> able to just stick them in the program's folder but with all the new
> security issues, computers can't write to that location anymore :-(
> Can I do this with a database file?

You will need to include the database library with your app. On Mac OS
X that's not a problem as it can be part of the application bundle. On
Windows, it is a separate dll file which usually means an installer,
although I don't see why you couldn't store the dll in a custom
property and save it out to disk when the app first runs. The data
itself would be a separate file so would need to be stored and saved
as you do your prefs.

> 3.  Can it be protected?

Don't know. The SQLite data files can be opened in a text editor and
while they contain binary data, the text data is there in readable
form.

> 4.  Whereas filtering will happen and needs to be super fast, the
> most common thing I will be doing is changing the data as follows:
>
> put "1286,5900,3422,9984" into myVar # this won't be done in one
> line, but as parts of other handlers
>
> repeat for each item x in myVar
>    subtract random(variable2) from myArray[x,cattledog]
>    if myArray[x,cattledog] < 0 then
>        doSomething
>     end if
> end repeat
>
> This type of code will be the most common.  Also, moving data from
> cell to cell.  It must perceive columns and rows, and be able to move
> the data from myArray[23,67] to myArray[55,90].  Or at least my code
> needs to be able to think this way.

While searching for all Red Sox fans born in a certain year sounded
more like a database candidate, this example sounds more suited to an
array or even to tab-delimited text.

I must say that I have a fondness for tab-delimited text. It can
easily be turned into an array temporarily for speed, but it is very
simple in concept and therefore easier to program. You can write
dedicated functions to retrieve, set or edit specific portions of the
data. Filtering is a good method of doing a rough find which can then
be refined by looping through all the remaining entries. If the first
item on each line is a unique ID number, then it is easy to work out
which line you are operating on, even after a filter.

Cheers,
Sarah



More information about the use-livecode mailing list