your personal choice for database handling and why?

Do you guys prefer to use JSON XML a scriptable object or something else for your database handling for items quests etc. in your larger scale games? I am looking for what the best option would be to learn and start implementing moving forward. Thank you for any information you can share regarding this database question.

1 Like

For a relational datase I would go for SqlLite.

I don’t have anything large scale yet, but at least it works really reliably to use WWW orders for PHP server which does its queries to MySQL database. And i’d propably consider it a security risk if using database directly from Unity.

Personal view and experience with the ones named:

I used XML for a small project long time ago. It is quite handy and easy to understand if you stay with XML only and it can be structured really well. It can also be even more powerful, especially in combination with stuff like XSD and XSL transformations. Downside: it’s most-likely getting a real mess as soon as your game grows. I haven’t tried it in bigger projects, but i cannot really imagine using it for (let’s say) a huge variety of items. However, I can imagine using it as my personal alternative for PlayerPrefs (never liked those), e.g. for a decent amount of user-related data and settings.

I remember Age of Empires 3 having all the data organized in XML files. They were huge and people could modify the heck out off it, but the bigger the files the more time it takes to modify and fix things, you’d be better off writing either a specific tool or editor extension.

ScriptableObjects are awesome and powerful. It think you’re aware of their power and advantages. I’d probably use them for items and such due to the ease of editing everything in the editor and the overall blueprint-like functionality. On top of that they totally fit into the Unity workflow and make use of its serialization system. I really like them.

JSON - haven’t used it in game dev so far, only when i had to work with JavaScript, jQuery, Ajax, Java-Servlet programming etc in university. Can’t really imagine to use it for huge amounts of data in a game environment but it’s surely nice for the communication with web services and such.

2 Likes

I think the OP refers to data that you store locally.

Some good info so far, but I just want to add a bit about JSON. Once you start working with JSON I don’t think you’ll ever consider XML again (if you have the choice). If you’re working with multilevel level data, which you’ll end up doing often, you’ll get away with a smaller file size in most cases with JSON.

That is to say even if you use attribute-heavy XML, once you get into multilevel, child element heavy data, you’ll probably come out smaller with JSON. And personally I just find JSON to be much more human readable. Maybe even more readable for Unity now with the JsonUtility helper.

As for whether or not it’s scalable and should be used with larger databases, working with lots of data: I’ve been following development of a game called Stonehearth for awhile now. If you haven’t heard of it, check it out. The game is sitting on top of a large data set, all handled in JSON. Here’s the Twitch channel. Watch some of their videos to get an idea of how they handle a large database using JSON.

2 Likes

+1 for JSON over XML, and there’s absolutely nothing wrong with tying it to enormous databases. Back when I wrote software for the largest bank in the world, we routinely schlepped around giant datasets as JSON, and you’re right, it’s typically far smaller than the XML equivalent and much easier to use. If it weren’t for that hideous mutant protocol called SOAP (so much promise, so much fail), I half expect XML would be dead and gone by now. There are a few things you can do more easily in XML but that’s more about the library support than the tech itself, and on a day to day basis everyone seemed to find JSON a lot easier to live with.

2 Likes