Where should I store data?

Started by
7 comments, last by Zubadar 11 years, 10 months ago
Hey everyone.

First year university student here studying games programming.

I'm designing a very primitive system to simulate realistic AI and virtual relationships (not uni stuff). There is going to be a LOT of data, so I'll need a database of some sort.

Here's an example of 2 snippets of tables I might have to store:
6e6670f6d916f7fae9ea7ce9e3bb3de0.jpg

Obviously it's very relational.

I've looked into databases for games, and I'm not really sure how I should go about tackling this. Apparently SQL is a bad choice and mostly used for online games and such. How would something like Skyrim store data? Flat file databases?

I want to be able to manipulate some sort of database using Visual C# 2010.
Advertisement

Apparently SQL is a bad choice and mostly used for online games and such.

Why is SQL a bad choice? What are your requirements? How much data do you expect to store? Keep in mind that the SQL language is very expressive; you can do more with fewer lines of code than you can otherwise, SQL is very adapt to database changes, and SQL has already been invented; there's no need for you to reinvent it!


How would something like Skyrim store data? Flat file databases?
[/quote]
Skyrim most likely uses some sort of SQL server. Flat file databases have (or may have) been phased out when memory/disk space requirements were tight (i.e., the DOS era).


I want to be able to manipulate some sort of database using Visual C# 2010.
[/quote]

You're in luck. You can get SQL Server Express for free, and .NET library interfaces amazingly well with databases. It's basically a service that runs on the client machine and acts as a professional SQL Server. This is a plus, since your application interfacing with the database won't need to care about where the data is stored. You can also get SQL Server Management Studio Express for free and use it to interact with your SQL Server on your local machine.

If you're not sure of what you want, then install SQL Server Express and try it out for yourself.
Also, another option available to you is to use various free libraries such as LumenWorks.Framework.IO.Csv and Ionic.Zip to create your own sort of "flat-file database" and use the C# LINQ to do SQL-like queries on System.Data.Datasets. The only disadvantage to this approach that I can think of is that the entire database will need to be read into memory, and any changes to a table will require rewriting the entire file the table is in...
Thanks for the reply. smile.png

What if I were to build the program and send it to somebody? Wouldn't they need to have an SQL service running on their PC for it to work properly? I just want to make sure it can be portable.

EDIT: With your second response, I think storing the whole database into the memory would be quite a disadvantage, because I can see this database getting very large.
I haven't done it myself, but this looks promising.
I don't really want an SQL server to be running in the background for this to work, unfortunately. It seems messy and bloated to me, and I've never heard of games running servers in the background to keep single-player data.

Here's what I need for this database:

  • Relational capability
  • Portability
  • Preferably doesn't have to load the entire database to memory to do things as that would be incredibly slow
  • Manipulable via Visual C# 2010

Any ideas?
You could look into SQLite.

SQLite is written in C but there are a few ways to use it from C#:

http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki provides .NET bindings to SQLite.
http://code.google.com/p/csharp-sqlite/ is a C# re-implementation (or more like a translation) of SQLite.

SQLite is absurdly portable and well-tested, and it's designed for embedding into applications (there is no separate server process.)
SQLite3? Contrary to what you may believe, you don't have to use a separate process, service, or even thread to use SQL. SQLite creates a database file which you can access through your code, where you can create queries and execute them.

[edit]

ninja'd

[edit edit]

You may be interested in this article on using SQLite and LINQ in C#.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Thanks everyone for the responses.

I'll definitely be using SQLite as it suits my needs perfectly.

This topic is closed to new replies.

Advertisement