Big data storage in quiz game

Hi,
I’m creating a geography quiz in which questions will be drawn randomly, about the flag, capital, population and other data.
How can I store all this data in array structure and then randomly select questions from selected categories?
For example, if the player selects questions about “population” in the “europe” category, how do I “pull them out”
I would like to create the entire database in one file.

Example:
CountryData[1][0] = “CountryName”
CountryData[1][1] = 15000000; //Population
CountryData[1][2] = //img //Flag
CountryData[1][3] = “Capital City”

CountryData[2][0] = “CountryName”
CountryData[2][1] = 15000000; //Population
etc

If you insist on that, just store it in a Google spreadsheet and make a script to download it into your project.

If you stay in Unity, use ScriptableObjects and make one per question, perhaps group them into batches.

Any other storage media (like JSON or XML) will require you to write a lot more support editor scripts just to see and reason about the data.

You WILL need to see and reason about the data as you debug. That’s not optional.

ScriptableObject usage in RPGs:

https://discussions.unity.com/t/798767/2

https://discussions.unity.com/t/803356/2

Usage as a shared common data container:

https://www.youtube.com/watch?v=PVOVIxNxxeQ

I think you’re asking about text files? Which I wouldn’t recommend :

For one I think JSON is better…

But you’re probably better off just making classes that contain the data. Say a parent class called “Countries” and then each child class from that is “America.cs, Argentina.cs, etc…”.

Then in specific questions, that would require said country, you have a setup that gets each country you define. And in the particular facts you want from said country would just be pulled from said country class(dateOfOrigin, grossPopulation, incomePerCapita, etc…).

That way each child class of Countries can be used easily for multiple questions, you just give parameters of which countries and which data type you want from them.

Sounds like an awful lot of typing, I tip my hat to you good sir. :slight_smile:

Yes, JSON is usually the way to go as most sources for this kind of information will already provide you the data in JSON. Some sources offer CSV files, but I would always prefer json. It’s a better and more sophisticated standard (CSV is not). A 10 second google search brought up this static data collection. Though there are usually other sources, often by governments, which are updated regularly. So that data could be pulled from a web source dynamically and cached locally. You can find a lot such sources by just looking around. Here’s another one. Though always make sure you check the license

If you have less than 10000 questions then json is fine, above you can consider using realm or sqlite.