Free Small Stand-Alone DataBase?

Started by
21 comments, last by Extrarius 18 years ago
BTW, why do you need a 10 minutes long lock? I smells some kind of strange strangeness here... [smile]
Advertisement
Quote:Original post by Emmanuel Deloget
BTW, why do you need a 10 minutes long lock? I smells some kind of strange strangeness here... [smile]
To put it simply, this is for a trading agent in a game, where players can go to it and trade stuff, and credit is given when they trade an item for something worth less. The lock is needed to ensure that a player doesn't gain credit then trade with two such agents simultaneously to 'spend' the credit twice. The problem with the 'in trade' flag is that it requires a 'query and update' (CAS, basically) command to be thread-safe (as it needs to be) that AFAIK doesn't exist in SQL.
It is highly unlikely that a person could trade twice before the database is updated (virtually impossible due to server-induced latency), but money is money =-)
A 10-minute lock is the best solution IMO since it'd be handled almost entirely by the DB and I wouldn't have to worry about screwing up the threading aspect (not much experience w/ multithreading much less inter-process interaction). I know better databases support such a thing, but I'm not spending thousands for a full Oracle license and the supercomputer required to run it =-)
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
[edit] In light of the above post, which was made while I was typing, I think my advice falls flat.

I'm going to "fourth" the recommendation for SQLite. I'm using it in an application right now which has two to three threads accessing the database at a time. The database-wide locking is indeed a bit of a pain, but it really hasn't become a problem. I simply do all the processing of data that I need to outside of a lock, then begin a transaction and quickly shove in all the data I need to. SQLite is fast enough that I can enter ten or fifteen thousand rows into a 6-field table with 3 text-based indices in a fraction of a second, then commit the transaction and let others use the database.

All my threads can simultaneously read data from the database, and they all just have to take a little break when it's INSERT or UPDATE time. As long as you're taking care to do all your SELECT's and business logic before beginning a transaction, then only do database modifications inside a transaction, SQLite will fit the bill.

But then, it sounds like you've already tried it and sacked it. So good luck rolling your own--if it's better than SQLite, I want a copy :-)
How about using 2 sqlite dbs? Use 1 as a scratch/temporary DB where the locking program can do its work, while other threads read the other DB. When the processing is finished, copy the data from the scratch DB to the actual DB.
---------------Magic is real, unless declared integer.- the collected sayings of Wiz Zumwalt
Just thought I'd throw in that by "Stand-Alone" I don't mean it has to be source I can compile into the application, but rather that it shouldn't require massive server resources like Oracle and it'd be GREATLY preferrable if it was simply a dll or small program - the main issue is resource usage and freedom from complex installation. If it's light-weight and can be run immediately after extracting it from whatever archive format (and has any settings in a local config file of some sort such as ini), it'll do just fine.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Quote:Original post by Charon
Oracle Database 10g Express Edition
this was the first thing to cross my mind after just reading the thread title...
(well, 4GB of user data IS small for a business database ^^)[...]
Thanks, but the 165MB installer leads me to believe it's quite a bit more 'heavy-weight' than I'd like.

Quote:[...]since SQLite is not an option for you what speaks agains MySQL or PostgreSQL?
(LAMP and/or WAMP are really easy to setup....)
For some reason, I thought MySQL was released under a license other than GPL. It looks like it's a possibility. PostgreSQL looks like a good possibility as well, and the BSD license is far more appealing. I'll have to investigate them both. Thanks for making me actually look into the MySQL license and suggesting a great probably alternative =-)
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
@AP : atleast with "Oracle Forms" you get the possibility to block records.

@Extrarius : an Oracle Database might be too much four your project, but i just have to defend it ^^

The Oracle Database 10g Express Edition can be used witouth paying for a licence even for commercial products. Apart from that its not that of a resource hog...
(i am using an Oracle 9 Database on an old Pentium 300 with 128MB RAM and a few Gigs Tablespace for developement purposes and it works "ok")

chaos, panic and disorder - my work here is finished

Quote:Original post by Extrarius
Just thought I'd throw in that by "Stand-Alone" I don't mean it has to be source I can compile into the application, but rather that it shouldn't require massive server resources like Oracle and it'd be GREATLY preferrable if it was simply a dll or small program - the main issue is resource usage and freedom from complex installation. If it's light-weight and can be run immediately after extracting it from whatever archive format (and has any settings in a local config file of some sort such as ini), it'll do just fine.


Wouldn't Firebird [1] --- the former Interbase --- suit your requirements? I remember it offering "DB in a file" possibilities, and it is a full-featured RDBMS. It might be overkill for your needs though.

Personally I'd roll my own for something that simple, or I'd use (G)DBM, because storing (key, value) pairs is really what it's meant for. I don't know if (G)DBM is available on non-UNIX systems though, and GDBM is probably GPL.


Hope this helps.

[1] http://www.firebirdsql.org
Quote:
Essentially, it will be used to store pairs consisting of a "UserName" (a string) and "Credit"(fixed-point number, though storing it as double precision should be fine)


Unless you skiped a few details, you will not want to use any kind of database for that.

You will write a text file, with two columns. Name might be escaped, or delimited, and the value would be just a text representation of the number (leaving you the flexibility of changing formats).

When application starts, you will read the files, and put everything in a hash table. If you need remote access, add a simple socket protocol, with "get NAME" and "set NAME VALUE" options. And that, is your application.

Anything more for this purpose is a HUGE overkill. Unless of course, you will be having hundreds of tables and millions of records somewhere in the future, but for start, KISS.
Quote:Original post by Extrarius
To put it simply, this is for a trading agent in a game, where players can go to it and trade stuff, and credit is given when they trade an item for something worth less. The lock is needed to ensure that a player doesn't gain credit then trade with two such agents simultaneously to 'spend' the credit twice.
Banks have to address precisely the same issue in their databases. Simple transactions are all that are necessary. Make sure that the trade and the credit alteration all together form a single transction (SQL BEGIN TRANSACTION and COMMIT) and you're good to go.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement