Hi, I’m creating a card game very similar to Magic “The Gathering” and Yu-Gi-Oh! Card game. I was wondering, what type of database do game programmers use? I think it shouldn’t use database managers like mysql and sql server since they are for more complex data dealing applications, I need to know what database to use such that a computer that only has the java virtual machine installed can run my card game and don’t have problems accessing the databse. I really have 0 experience on gameprogramming, I’m learning and really need a lot of help out here, this is one of the many issues I will have for this project, later I’ll have to deal with AI technique for these type of games, but for now I would appreciate any help about java connecting to database for games and if you have tutorials for working with java and a dabatase.
I’ve used hsqldb in the past, it’s small and fast. I noticed though that the current build isn’t that small anylonger, ranking in at 553kb.
First I think you should consider if you need to use a database at all. If you don’t need transaction handling, indexing, query language etc. storing objects in files might be a good solution. If you are creating a client/server application and your data objects fits in memory you should consider a solution like Prevayler (www.prevayler.org) which is very easy to use.
[quote]First I think you should consider if you need to use a database at all. If you don’t need transaction handling, indexing, query language etc. storing objects in files might be a good solution. If you are creating a client/server application and your data objects fits in memory you should consider a solution like Prevayler (www.prevayler.org) which is very easy to use.
[/quote]
This is the old debate: are databases for general storage and retrieval of data? (hint: in the end, those that said “yes” won the majority verdict by a huge margin).
I would suggest you never ever turn down a database if you could conceivably use one; you will benefit many times over in terms of how quickly you can write your code, how easy it is to maintain, etc.
OK, so the most famous DB’s you hear of these days are:
- Oracle
- DB2
- MySQL
- Access
3 of which are a PITA to install and setup and sometiems hard to justify the hassle for 20 users, let alone for just a single non-networked app for one person. The fourth is pretty trivial - assuming you have windows and Office.
But…you should use databases wherever you can, really. They’re like java.util.*, only much better ;D. Thankfully, Java has JDBC which lets you write your code independent of the actual database you use, and then you can try out several of the “local machine only” DB’s. Someone mentioned one above, but there are many more available (have a look on sourceforge.net for a start for free ones?).
Sadly, though, most of the famous ones are only compatible with each other for the most common commands, and they each rename all the other commands to words they like better (stupid evil bastards) than the ones their competitors use for no good reason. So you have to limit yourself in some ways if you want trivial portability. Although if you’re considering not using a database, your needs are probably straightforward enough that you can use the common subset for everything anyway (it will only become a problem when you start to say “Hey, this is cool…what else can I do with it?”)
EDIT: I forgot to say my most important point: just because the “big four” require lots of setup, many megabyte downloads, etc doesn’t matter - the many other DB’s around are often just tens or hundres of Kb, and many do things like implement as lots of files in the local directory - perhaps even with no networking at all - but they give you all the benefits of a DB-style API to work to.
If you need something basic just to Store/Modify/Read records you could use a library I recently wrote.
see http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Offtopic;action=display;num=1084466955 for more details.
It works and supports indexes, there is an NIO and a regualr IO version. On a crappy lap top it can read 100,000 records in only a few seconds.
Hehe… remember that a filesystem IS a database. Then take a look at what Microsoft and Apple are planning to add to their filesystems in future OS releases… (more metadata), and you will realize how silly today’s filesystems are. The trend is to move to more full-featured databases for all general storage.
I’m with blah3.
I’ve always had a question with regard to database access:
How would I go about making sure that the password used to access the database is not discovered? Someone could obtain a class decompiler, extract the password and delete all my data.
Couls I somehow hash the password, then the hashed password is checked against the real password on the server (a jsp file?) and then i somehow reroute the access?
[quote]I’ve always had a question with regard to database access:
How would I go about making sure that the password used to access the database is not discovered? Someone could obtain a class decompiler, extract the password and delete all my data.
Couls I somehow hash the password, then the hashed password is checked against the real password on the server (a jsp file?) and then i somehow reroute the access?
[/quote]
If your game client has a password, then every hacker with a copy of your game has that password. There is no other scenario (assuming you have any significant number of people playing your game!).
The way that games typically work is to NOT access the server directly from the client. Instead, they access an intermediary - usually a “gameserver” written perhaps in java - which itself then performs DB access. There are many advantages to this, not least of which that you can also place a software cache inside your “gameserver” which is shared by all the clients accessing the game :).
In the case mentioned by the OP, all that is going to happen is that someone could “hack” their local copy, and perhaps change the powers of the different cards etc. They could do this anyway, of course :), and it’s only them who is affected, so you probably don’t care.
…except that it is perhaps easier now for someone to distribute a tiny client that lets people interactively modify the game rules on their local copy. But if someone does this, you’ll probably be delighted - it shows people really like your game! And if you are charging money, you just include a “bonus” app (possibly for minimal) charge which is your own official editor in your next release.
(nb: it’s not unknown for games companies to hire hackers in this way, in order to get the person and the editor, which they then convert into an “official” one at less than the cost of developing one from scratch. The first major hacker of Diablo got recruited by Blizzard in time for D2 IIRC…)
Thanx for your responses, I just have a question, with te HSQLDB, when deploying my game, somebody installing my game in his computer doesn’t need to install de HSQLDB in order to be able to play my game am I right?
That’s right: HSQLDB in a deployment consists of a number of data files (the database data) and a Jar library (the database application code). As long as you distribute this library with your application, end-users will not even need to know you’re using HSQLDB.
What do you think about Pointbase Server?
thanks for the explanation blah^3! So, I’m thinking that I’d need to use servlets (which my host does not allow me to do), is there any other way using standard server-side scripting such as PHP, ASP or Coldfusion?
[quote]What do you think about Pointbase Server?
[/quote]
I"ve never really used it before myself, but I think it’s as lightweight as you can get.
Any comments from someone who has used (or choose not to use) Java Data Objects?
http://access1.sun.com/jdo/
Thanks!
[quote]Any comments from someone who has used (or choose not to use) Java Data Objects?
http://access1.sun.com/jdo/
Thanks!
[/quote]
I haven’t used JDO for games, but I am using it in production code. JDO has saved us buttloads of development time. We’re quite happy with the results.
If you’re going to evaluate JDO, the best thing you can do is to make sure you try out a good implementation. Some of the open-source stuff out there is total crap. (There may be some better free implementations out there since I lasted checked - it’s been a while).
We’re using JDOGenie and we’ve been very happy with them. I’ve also evaluated Kodo, and Solarmetric seem to be a competent vendor.
God bless,
-Toby Reyelts