Implementing Server Database

Hello, I would like to know where do I start in learning how to make a server database for my game. Not necessarily for Multiplayer but just to be able to store data of thousands of players playing the game in my own server.

This is a very broad question. So where do you start? It depends.

Generally speaking, a database for a server is just a plain old database. The server receives information and stores it in the database, or sends requested information back to the client. So start by learning how databases work in general, pick one type you want to work with, and figure out how you write code to handle data insertion or requests.

After you figured out how to do things, you may wanna think about what you do. So ask yourself; why do you need a database, what data will you store in it and so on. Afterwards, design and create the model for your database.

Keep in mind that i’m by no means an expert on networking or databases, but i thought i’d point you in the general direction until someone with more experience on the topic goes into detail.

Out of curiosity: if what you develop is not a multiplayer game, why do you need a server at all? Seems like it adds a lot of cost without many benefits. Generally speaking, unless it’s necessary to play the game, online connection tends to annoy players. Is it required for some anti-cheat? Are you collecting data? Is the connection optional or required to play?

  • I’m interested in creating a system such as the Witcher/Divinity/DragonAge series where I can load my save from previous versions of the game
  • I want the Player to be able to play from multiple devices with his saved data.

That’s pretty much all, but I’m interested in gaining knowledge for Multiplayer gameplay as well, just not as willing to learn it as the reasons above.

There are two things involved: The saving and the storing and syncing.

First: You can save in plain json and extend that later to bson or even more efficient to a binary serializer as protobuf, messagepack, zeroformatter etc.

Second: Most games today with local saves implement only a very simple sync: If your file locally is newer => update to server, otherwise => download from server. This is how Steam and Epic Games Launcher work.

The last option is centralized data storage, this is the common way to implement it for multiplayer games. The main reason here is to avoid changing the data. Here every action results in updating the savegame on the server and the topic as a whole is a bit larger, as there is also action validation involved, as the client has to have zero control about data modification to avoid cheating. This way the client only can do some very strict defined actions, the server validates them (sometimes even heuristically “can a player even click that fast”) and then responses with an updated model. Don’t go down that rabbit hole if you do not need it. There is a reason why even very big games often do not implement this.

1 Like

Just a thought out loud. If you want to play that save game on another device you could use cloud storage for instance cloud firestore (firebase). Would that do the trick?

I’m quite unfamiliar with Cloud. From my understanding, I can store data in their server. Does this functionality exists for all platforms? I only ever saw the Cloud at Steam and Origins, what if I don’t publish to any of those, can I still use Cloud?

Cloud storage is usually used for this type of saving.

Read all about it here:
https://firebase.google.com/docs/firestore

A bit of googling can’t hurt if you’re seeking answers :wink:

Thank you for this, I’m going to find out how to actually set up a server using MySQL then use your advice on how to use it later with the two things you mentioned. Cheers!