Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Databases in Games

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Databases in Games
Michael Jensen
Member #2,870
October 2002
avatar

I was thinking it would be interesting to store everything for a game into a database file: highscores, savegames, levels, images, AI Scripts, sound, etc...

I might try it in my next game, anyone else ever try anything like this?

Edit: my first thought is that it would be really easy to sort things like highscores: "SELECT TOP 10 * FROM tblScores ORDER BY Score"
...

Thomas Fjellstrom
Member #476
June 2000
avatar

Its always a bad idea to store binary files in a Database. Just store the location.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Derezo
Member #1,666
April 2001
avatar

I use an XML database, but I think you mean a MySQL DB? (your edit confirms this :))
I've considered that, but it isn't very practical for single player games. It's only really useful for multiplayer internet games.

[edit: BTW, wouldn't it be "SELECT * FROM `scorelist` ORDER BY `score` DESC LIMIT 10"?

..and who said anything about binaries? Save games and scores can easily be stored in a database without using binary stores]

"He who controls the stuffing controls the Universe"

Thomas Fjellstrom
Member #476
June 2000
avatar

Personally, Id go for SQLite for a game database, no need for a server, much of the SQL standard is implemented, and its performance is amazing.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Michael Jensen
Member #2,870
October 2002
avatar

Quote:

MySQL

I never said anything about, nor comfirmed anything about "MySQL" or what database server/engine I'd use -- personally I agree with TF on two points: 1.) A database engine that didn't require a server would be used (personally I'd prefer the JET Engine, but SQLite could work, although it stores EVERYTHING as a string internally, and I couldn't use something simple like Access to edit it.), and 2.) Binary files would not go in the database (sounds/graphics would not go in the db as I originally suggested) -- but no reasons why save games, maps, scores, options/keyboard/joystick config, etc couldn't go in.

Quote:

DESC LIMIT 10

That must be some kind of strange MySQL syntax? ???
Edit: In what ways is using a database not practical? -- It seems like a lot of things could be simplified...

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

although it stores EVERYTHING as a string internally

Not since some 3.x version.

Quote:

and I couldn't use something simple like Access to edit it.

Theres several graphical tools that support SQLite DB editing.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Michael Jensen
Member #2,870
October 2002
avatar

Oh ok. Well my point still stands, I'd rather use something like SQLite or Access files, as opposed to a database engine that requires a database server.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

Well my point still stands

I wasn't arguing with you, I made the same point above remember? ;)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Michael Jensen
Member #2,870
October 2002
avatar

I wasn't arguing with you either, I was agreeing -- I thought I said that...? oh well. -- What I was trying to do was put some emphasis on the important part.

piccolo
Member #3,163
January 2003
avatar

any one got any links to getting mysql to run in msvc++6.

wow
-------------------------------
i am who you are not am i

Wetimer
Member #1,622
November 2001

Actually, I started a programming language based on that idea where all in-program data structures were held in tables and you could do database like operations on them. I've got a self supporting compiler written in it.

The trouble is that SQL doesn't integrate as neatly into C++ as I'd like.

<code>if(Windows.State = Crash) Computer.halt();</code>

Michael Jensen
Member #2,870
October 2002
avatar

I'm not sure about VC6, but in Visual Studio 8 (and I assume it works in C++/CLI) there's ADO, so the same code (or insanely close to it) can be used to access SQL Server, MySQL, SQLite, Access, and a bunch of others...

You shouldn't write SQL in your program, you should use Stored Procedures (Access and SQL Server support them... not sure about the others.) -- At the very least, ADO adds parameters even when not using stored procs, so people can't name their char something like "'; DROP DATABASE --" ...

Rampage
Member #3,035
December 2002
avatar

Access has a very simple format, it's documented on http://www.wotsit.org. You can write your own reader for .mbd files. I don't know if it can handle images, though...

-R

Neil Walker
Member #210
April 2000
avatar

Remember you'll need to ensure anyone using the game would have to have the database system up and running on their machine, and the same version, etc. Getting the embedded version of mysql is a bit overkill I think.

Why not opt for a small, self contained library that you can just compile into your program with no dependencies, etc. Something like xBase would be ideal. Or just store stuff in an xml file and use tinyXML library (just store the high-scores in a STL container and sort it for ordering).

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Peter Hull
Member #1,136
March 2001

Also have a look at Berkeley DB.

Quote:

Berkeley DB (BDB) is a high-performance, embedded database library with bindings in C, C++, Java, Perl, Python, Tcl, Smalltalk and many other programming languages.

Pete

BAF
Member #2,981
December 2002
avatar

Access sounds very un-portable, heh.

Audric
Member #907
January 2001

From what I've seen of Sqlite, it seems like a good idea for game data, as it will simply be an access to a file.

The advantage I can see for game development is that you can easily change the data and even add columns for new data, you don't even have to recompile, your executable will rely on columns names so it will be compatible with the new format.

Very much like the XML facilities, except the tables can be viewed and edited like a nice 2D spreadsheet.

Rampage
Member #3,035
December 2002
avatar

Quote:

Access sounds very un-portable, heh.

The file format itself is portable, you just have to generate the database under Windows :P.

[edit]

Is there any open source equivalent to Access? In OpenOffice, perhaps?

-R

Michael Jensen
Member #2,870
October 2002
avatar

This is sort of off-topic, but that seems where the thread is going:

Quote:

Access sounds very un-portable, heh.

I only plan on developing for windows, and anything with the .NET framework installed (a free download) can read/write access files (without having access installed) -- and yes access can store byte arrays so it can store binary data such as images etc, but as TF pointed out, that's not a good idea.

I was really hoping to discuss game design with databases rather than be nit-picky about what everyone would use. Personally I would prefer Access, or SQLite to other avilable products. :P

Edit: OT Again, Some one mentioned Berkeley DB, but that same page talks about it's licensing restrictions: "The Sleepycat Public License requires that software that uses the Berkeley DB code be open source (under an approved OSI license) to allow redistribution." :-/

Victor Williams Stafusa da Silva
Member #4,212
January 2004
avatar

Access is evil!
From december 2005 to June 2006 i was a victim of Access.

Try to put something like 50000 registers with multi-user support in a complex database modeled in Access. It's a nightmare.

[BTW: I didn't choose access, it was used in my work before i get my job. The system was a big piece of crap which needed some days (no joking here) to generate a report. The resulting report simply used to make no sense, frequently crashed. There were thousand of bugs too and it was not even halfway done. They putted me to try to fix that because nobody else could do. And after six months of work, the system finally was working with no more data corruption, hanging, freezing or whatever. It is multi-user and is pretty fast (of course the source code is just a big spaghetti mess). Indeed, if we used something like Java it would be done in 3 months or less]

EDIT: rewrote something wrong.

[The attack of the space bugs - Speedhack 2005] [Rambananas - Speedhack 2006] [Make clean - Speedhack 2009] [The source god - TINS 2010]

HoHo
Member #4,534
April 2004
avatar

Quote:

Is there any open source equivalent to Access? In OpenOffice, perhaps?

KOffice has Kexi that is Access-like. From their feature-list I found these:
SQLite (version 2 and 3, file-based, complete)
PostgreSQL (complete)
MySQL (complete)
Firebird (planned)

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Carrus85
Member #2,633
August 2002
avatar

Openoffice 2.0 has a Database program included with it, that seems to be Access-like (I've never really used access a whole ton though, so don't hold me to that...)

Neil Walker
Member #210
April 2000
avatar

OpenOffice Database is the biggest bag of crap ever created. Unless of course you like your programs to crash 20 times an hour and your form to randomly make controls (e.g. text box, buttons) read-only and be really really slow. Switching from the crapness known as hsql to mysql only fixes the speed problem.

I tried various 'Access' equivalents on linux (though not kexi as I have gnome adn don't know what additional stuff I'll have to install) and they are all very poor. For my database proggy I have to reboot to XP and use Access.

Saying that, you should only choose Access if you want to use it as an application, i.e. forms, reports, etc. If it's just the data you want, then you should choose a more open format and use a general purpose application/web program to maintain your data.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Onewing
Member #6,152
August 2005
avatar

@Michael: So, have you decided on what method you are going to use?

Quote:

From what I've seen of Sqlite, it seems like a good idea for game data, as it will simply be an access to a file.

Interesting...I'll have to check this out.

I've never really setup a database or used one through programming with C/C++ (I somewhat do database programming in Informix at work...). So I know the SQL commands pretty well, but am missing a few dots. The project I'm about to work on is, IMHO, a huge canidate for a db. The whole thing is based on economics and will hopefully have a large variety of items and other such things. I'll probably be diving head first into this in the next few weeks, so some knowledge beforehand is always great. I'll check out the suggestions from this thread. :)

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Specter Phoenix
Member #1,425
July 2001
avatar

Yes DESC LIMIT 10 is SQL.
SELECT * FROM `scorelist` ORDER BY `score` DESC LIMIT 10
My english translation of this may be a little off so bare with me (I'm not a MySQL or even SQL Guru).
Select *(Everything) from Scorelist ordered by the entry variable score (DESC LIMIT 10 means this) descending order with a limit of 10 scores shown.

Basically it it a way of saying to display the top 10 of the game. But I've wanted to do the same thing you are doing but I've just never got around to doing it.

 1   2 


Go to: