--On August 3, 2005 8:28:28 AM -0700 Rick Lavin
<rlavin

pu-kumamoto.ac.jp> wrote:
> About the supposed desirability of databases: It's often assumed that a
> decent wiki engine has to make use of a database to work properly. But
> pmwiki <www.pmwiki.org> eschews a database, using flat files only. I've
> no idea whether it would be possible to run Wikipedia <www.wikipedia.org>
> on pmwiki. but the speed in everyday use with moderately-sized wikis
> suggests that the advantages of databases are limited.
I just finished moving a simple web app from using a flat-file storage
to using
a real database engine (MySQL). The app was a registration & payment
system for
a small conference. In the first versions I stored all the
registration info in
a single flat-file CSV file.
I moved to a database because the database engine provides features
that I just
couldn't write myself using PERL and an OS file system.
One of the big features I wanted was better locking. In a web app you
can't tell
how many versions of the app will be attempting to write to your data file at
the same time. I used the OS locking abilities as best I could, but there were
situtations (such as assigning confirmation numbers) where I could not really
be sure I didn't hand out a duplicate confirmation number.
The database server handles this much better. I have a field that auto-numbers
and it handles the simultaneous writing.
Along those lines, manual edits were difficult. I usually tried to do
these late
at night, but there was a chance when I edited the file, someone would come in
and register and when I saved the edited file it would overwrite those
registrations.
If I had used MySQL's InnoDB (or a database that was truly ACID compliant such
as PostGRES SQL) tables I could've implemented locking down to the row level
and even established transaction handling. Transaction handling would
be useful
as I have the ability for users to reserve a spot in a session that has
limited
seating. With transactions I would define the conference registration and
session reservation as a "transaction" and both the registration and session
reservation would have to succeed or both fail. That way I don't have a user
confirmed for a session that isn't confirmed for the conference (or
visa-versa).
I could also mention how much easier searching for items in the database are
now. I used to have to loop through every entry in the file looking for info.
Now the database server handles that for me.
Kevin