Advertisement

Database use in games

Started by December 01, 2000 03:04 PM
2 comments, last by ZeroRage 24 years, 1 month ago
I am trying to figure out how most games ( if any ) use a database during the game, or if they just use some sort of hash-table or something. For example in an RPG, all the items and weapons and armor are kept somewhere. Are they usually in a db, and how do they access them during the game?
Star Wars Galaxies (a MMOG) is using a MySQL db. It resides on a separate server, and every night the game servers are gonna "persist" the universe state to the db, or something like that...
Advertisement
Most games don''t use any kind of relational database. They are generally not suited to the way games access the data. Relational databases are optimised for batch operations, whereas games make lots of individual alterations. Game programmers will tend to go a bit deeper and write the structure they need directly... usually some variation of arrays, linked lists, trees or maps (which are really just associative arrays anyway).

In an RPG, you probably have something like this:
class Object
{
int type;
// etc...
};

// There are 1024 objects in the game
Object allObjects[1024];

Simple as that. Of course, more sophisticated designs might have separate classes for Object instances and Object types... they might store objects as part of the map tile or container they reside in rather than in a global list... etc.

The main use for relational dbs in games is probably for persistent games where it''s easier to use a db than to define a lot of new file formats.
In my opinion, use of industry strength database engines in games (where such storage is neccessary, as in MMORPG''s) is underutilized. As stated here, the game engine does need more imidiate and direct access to the data, but this is the same in business-level systems too. The solution is to keep an in-memory scratch-pad of the data and on certain points update these to a persistent store. The benefit with industry dbe''s is the speed, scalability, safety, etc functionality. You get (usually) back-up support out of the box, replication, ACID-support (Atomicity, Concurrency, Integrity and Durability) right away.

And more, many developers already know SQL or some DB-system development, so the entry-level is lower.

My 2-cents on this.

This topic is closed to new replies.

Advertisement