Open Bracket Developer Column

Framework for PBBGs? - DB Planning

bardicknowledge on 07/25/2008 09.55 PM
(read 1648 times)

I don?t know if I mentioned it here, but I am looking into creating a framework for PBBGs using PHP. This is not only to help myself create games but to make it easier others to start to create their own games.

What's the first problem you think of when you think of making a framework for games? For me it was databases. We all approach these differently, and will want different info to be stored. After a bit of thinking, the easiest way to do something like this would be to put objects of data into the database and have your code know the schema of the info.
Doing some searching it seems Google beat me to the punch with this idea.

http://en.wikipedia.org/wiki/BigTable

So this gives me the impression its plausible to do what I’m thinking, but is it really efficient? Can it be done is such as way so that each call isn’t grabbing ALL the info related to a player. The goal would be to return a query then to deserialize it. And not to perform string manipulations on it during the query.

Let me give an example of the problem of having all of ones data in a single object.
You have 5 stats, experiences, weapons, armour, magic, a guild, quests, inventory, gold, friends, mail, an attack history…

I think you start to get the point. That’s a large amount of info when you only want your players names and id. I can think of a number of problems for using a large scale solution like bigtable, but is there a way to keep a similar structure on a smaller scale?

To make descent framework for games, the DB needs to be incredibly flexible and this is the only thing that comes to mind when I try to think of a solution.

So for you all DB guru’s out there, what are your thoughts? Can it be done? I will try to put more thought into it over the weekend.

Also, does anyone know of any good database stress testing tools?

Open Bracket Developer Column

Introduction
Starting a new design
Forming a PBBG development group
Nav and layout
Community Interaction
Future of web gaming
OpenBracket Podcast - Revenue
OpenBracket Podcast 2: Player Growth
PBBG RPGs
Strategy PBBG’s
Goals and Achievements
The tick
Graphics of web games
Target Audience
Player Controlled Economies and Player ...
Thinking about why

Share Subscribe

Comments

07/29/2008 01.23 PM

An irresistible comment :)

If I get you right, you're trying to store information as a serialized BLOB or String in a single column instead of spreading this information over several columns or tables and your hope is, that this will speed up your database access. Am I right, so far?

I think this journey will end soon, as you're abandoning all the favors of a relational DBMS! If you serialize the data you can neither search for it nor order the result by it or do anything else with it. I think serializing data in a database is a very tough decision which should be well considered. We store some information as a serialized string but we're absolutely sure that, at any time we need one piece of this dataset we need all the rest of it, too and we have absolutely no need to search or sort by the serialized data. So we gain some speed by eliminating some costly joins in the query. But as I said this isn't THE solution, it's only a small option for some very special niche use cases.

The BigTable project you're referencing to has a quite different goal. They try to create a very scalable DBMS which works a little different than a relational database and acts more like a sortable associative array than such a relational DBMS. But this does not mean, that they mix data in that array with each other by serializing it. The biggest difference to a "normal" DMBS like Postgresql or mySQL is the ability to scale very well over more and more and more hardware which is difficult task with traditional databases.

I think you should have a look at some kind of object relational mapper (en.wikipedia.org/wiki/Object-relational_m
apping
). In PHP this might be Propel (propel.phpdb.org/trac/) or Doctrine (www.phpdoctrine.org/). Those frameworks will map objects in their object oriented sense to a relational database and let you access them in a more OO like way. This way you might not create the most efficient queries possible but you stay very agile with your data structures as you can easyli redefine your db schemas and remap them without the need to rewrite all your handwritten SQL in your application.

Anyway I think you should stop thinking about performance to much in the beginning! Just build something that works! Improving an existing system is for all means the better way to achieve performance. I don't know if you've planned to develop the framework as open source but if you do so, it will be a significant factor for the numbers of contributors you will get how usable your system is. And with this I do not mean how good your system perform but if it is able to run games. If it can, you will find people who use it and they will complain that it's slow and this is the point when people get involved! If you have just a barebone framework which is not capable to run any real world application nobody will get interested in it and you will have to lift all the heavy work on your own which makes it very likely that you'll give up in the middle of the game. Therefore my advice: Make plans, but don't plan (too much) about the performance. Align your concepts mainly about the usability of your framework! Performance will come. Look at Rails. It's a great to use framework which performed real worse in it's early days. But since it is so easy and elegant to use many many maaaaany people chose to stick with it and today those peope have created a very compelling and competitive framework, even in performance terms.

I hope this helps a little and my english wasn't too bad :/ But I'm trying to improve that

I would be glad to keep this discussion alive!

Cheers,

Thorben

07/28/2008 05.51 PM

db

I'm not sure if I get your problem, just use "SELECT username, id FROM tablename" instead of "SELECT * FROM tablename" in mysql? And with join queries you can even select data from multiple tables/databases with 1 query.

Add new comment
Please log in to use this feature!
Games
Screenshots
MondoZoo
MondoVeto

How old are you?
< 18
18 - 24
25 - 34
35 - 49
> 50