I'm working on a single player sports game for a year or so and this doubt came up: how should I treat/store big amounts of data, like player names.

Let's take an arbitrary number as example: 10000 names, 5000 first names and 5000 surnames. These names would be equally divided between 100 countries, which give us 50 first names and 50 surnames per country.

Should I have a local database with these names (or even these countries) considering this data will be needed to generate new players names during the course of the game? Would that introduce limitations, considering I want to make my game moddable by players, as much as possible?

These doubts can be extended to other, more complex game entities, such as:

  • Players - each one with their own face, attributes, team etc...
  • Teams - each one with its own crest, kit, squad etc...

In my previous research about that, the SQLite popped up as a seemingly viable solution. It happens that I have almost no experience with DB's (specially in games) and would like to know if this is a good direction before start to study and try to implement it.


1 Answer 1


When the data is static while the game is running or small enough to fit into RAM, then databases have very little benefit compared to the technical complexity they add. You can just as well store all that data in text files (TextAssets). When the game starts, then you parse those files, store all that data in adequate data-structures and then access those data-structures at runtime.

When you would like to maintain the data in a more organized way within the Unity editor, then ScriptableObjects are your friends. This is a feature which allows you to create custom Unity asset types which you can then create, manage, edit and use like any other Unity asset. You could, for example, create a ScriptableObject class "Country" which has three text assets, a "nameFileMale", "nameFileFemale" and a "nameFileLastname", plus all the other data you have about a counry. You can then create one of these assets for every country in your game and assign the threee text files which list the names for that country.

And just by the way: Did you know that C# can do SQL queries on arrays and other containers which implement IEnumerable?

  • \$\begingroup\$ Thanks you. Ok, correct if I'm wrong at some point.To store simple things like names I could use a .xml file cache that as a List<string>, even with a lot of names. Scriptable objects seemed a good choice for some situations, but a friend of mine said that it cannot be edited at the runtime. For static things like countries, maybe it's a good choice, but for things that meant to be edited it wouldn't work, or my information is just wrong. No, I didn't know that C# could do that, if I understand right, I could use this feature combined with the TextAsset to cache data at runtime, seems cool. \$\endgroup\$ Sep 12, 2020 at 22:40
  • \$\begingroup\$ @GabrielMinosso I am not entirely sure what "your friend" is talking about. When you have data in a ScriptableObject asset, then you can change that data while the game is running. Both via scripts and in the editor. But when you restart the game, those changes get discarded. Which is just the same as with all other assets in Unity. So no, they can not be used to create savegames. But that's not what they are supposed to be for. \$\endgroup\$
    – Philipp
    Sep 13, 2020 at 0:07
  • \$\begingroup\$ Well, maybe I misunderstood his answer, can't remember very well what I asked tbh. I think I was looking for a way to store data that can be modded and saved at runtime, his suggestion was xml files. The thing is, if I got it right, I can't use SOs to store teams for example, or at least I shouldn't if I want to enable players to modify, apply modifications or even create new teams. About my last commentary, does the rest of my considerations are correct? \$\endgroup\$ Sep 13, 2020 at 2:46
  • \$\begingroup\$ @GabrielMinosso I wouldn't use XML. When it's really just a list, I would use a flat file. When it's hierarchical data, I would use JSON. But that's more of a personal preference. Creating savegames in Unity is another complicated problem with many, many different solutions. This is a topic too complex to debate in comments. But we already got several questions on this site which deal with that topic. \$\endgroup\$
    – Philipp
    Sep 13, 2020 at 9:45
  • \$\begingroup\$ Ok, but it still doesn't clear to me what should I do regarding complex data like teams, (pardon if I misunderstood some of your previous comments).Is there a good solution for this subject or the best I'll get is a "it depends" kinda of answer? I left the question open for a few days waiting for other opinions, but I don't think this will happen soon enough, so I'll accept yours. \$\endgroup\$ Sep 15, 2020 at 18:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .