What’s the recommended database to use? I’ve been using sqlite for many of my applications, but I’m not sure that’s appropriate for a game where the map and player-data will be frequently loaded and saved and all that. Is there a better option?
the answer to that is what are your needs. What functionality do you need from your dbms
Well, if you’re just loading and saving player data and maps and so on, why bother with a database?
Cas
Postgres for industrial-strength server-side, H2 for client or small servers, sqlite for Android.
Well, by maps I mean in chunks, so say 32x32 tiles at a time. But I guess I could use flatfiles for that just as easily… hmm.
So your wanting to save binary images in your database?
Databases do not magically make things better. As a rule in programming, if you do not know what something is meant to be used for, then don’t use it. Your question is sort of like asking “What’s the best type of rocket fuel to use? I drive my car very frequently.”
Second, do not load and save things frequently. The trick to improving disk performance is to use the disk less. You can’t change read, write, or seek speeds. That’s why you minimize the amount of data transferred and the number of times you need to seek.
Minecraft uses files to store chunks, and it works fine. The filesystem itself is a pretty decent database for this sort of thing, as long as you’re not doing it concurrently (file locking is not fast) or on mobiles (phone filesystems are tiny and slow).
It’s good to learn relational databases, but you need to understand how they work (with some experience) before applying it. The last thing you want in a project is a solution looking for a problem, it’s how you ensure your project is never finished.
Yeah, I was thinking about Minecraft using the chunk files. I’ve done a lot with relational databases (mostly at school/internship though), I just figured with so much data it’d be better to put it all in one big db file but that was pretty silly of me. Anyway, thanks for the info, I think I’m gonna use the file system approach. Seems easier anyway.
Base your storage off of the way you hold your data, not the other way around. Feel me?
If you have something like Minecraft, were you basically have large memory chunks you want to quickly read&write to storage.
Perhaps a memory mapped file is something for you.
But that is for tile information and like. Perhaps for your entities (characters, items, whatever) you would still opt for a db.
Finally, as others mentioned, you have to be aware of size.
Postgres is a great db, but it consumes a lot of space and is not very portable.
H2 and sqlite on the other hand are.
So try to figure out first what you need in every aspect (what has to be stored, how much space do you have, are you running on a client or is there a server, etc pp) and then find something that fulfils those needs.
You could try hydrazine. I’d be very interested to see how that works with a car. (… from behind a thick panel of reinforced glass ;D)
No seriously. There seldom is a “best” of anything, and I start to dislike all the “What is the best” questions.
Step 1) List all solutions that you can imagine.
Step 2) Make a list of your requirements to the solutions.
Step 3) See which of your solutions fulfill the requirements and how well they do it.
Step 4) Make a well-thought decision between those solutions which fulfill the requirements well.
This is a way to find what will be “best” for your needs. If still usnure in step 4, post yourt doubts, and people will have much better chances to actually help you, than just asking for the “best” in such a big domain as databases.
Oracle is a good choice good if you plan on supporting 20.000.000 players.
java.io.FileWriter is a good choice if you plan on supporting 200 players.
OR: how about just using php+mysql on a standard free or rented webspace.