• Advertisement
Sign in to follow this  

Where should I store data?

This topic is 2036 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
[img]http://filebeam.com/6e6670f6d916f7fae9ea7ce9e3bb3de0.jpg[/img]

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.

Share this post


Link to post
Share on other sites
Advertisement
[quote name='Zubadar' timestamp='1340332531' post='4951585']
Apparently SQL is a bad choice and mostly used for online games and such.[/quote]
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!

[quote]
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).

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

You're in luck. You can get [url=http://www.microsoft.com/sqlserver/en/us/editions/2012-editions/express.aspx]SQL Server Express[/url] for free, and .NET library [url=http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx]interfaces amazingly well[/url] 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 [url=http://www.microsoft.com/en-us/download/details.aspx?id=8961]SQL Server Management Studio Express[/url] 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. Edited by fastcall22

Share this post


Link to post
Share on other sites
Also, another option available to you is to use various free libraries such as [url=http://www.codeproject.com/Articles/9258/A-Fast-CSV-Reader]LumenWorks.Framework.IO.Csv[/url] and [url=http://dotnetzip.codeplex.com/]Ionic.Zip[/url] to create your own sort of "flat-file database" and use the C# [url=http://msdn.microsoft.com/en-us/library/bb397933.aspx]LINQ[/url] to do SQL-like queries on [url=http://msdn.microsoft.com/en-us/library/system.data.dataset]System.Data.Dataset[/url]s. 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... Edited by fastcall22

Share this post


Link to post
Share on other sites
Thanks for the reply. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

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. Edited by Zubadar

Share this post


Link to post
Share on other sites
I haven't done it myself, but [url=http://stackoverflow.com/questions/2442635/can-i-deploy-sql-server-express-with-my-desktop-application-just-like-builtin-da]this[/url] looks promising.

Share this post


Link to post
Share on other sites
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:[list]
[*]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
[/list]
Any ideas? Edited by Zubadar

Share this post


Link to post
Share on other sites
You could look into SQLite.

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

[url="http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki"]http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki[/url] provides .NET bindings to SQLite.
[url="http://code.google.com/p/csharp-sqlite/"]http://code.google.com/p/csharp-sqlite/[/url] 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.)

Share this post


Link to post
Share on other sites
[url="http://www.sqlite.org/"]SQLite3[/url]? 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]

[url="http://www.codeproject.com/Articles/236918/Using-SQLite-embedded-database-with-entity-framewo"]You may be interested in this article on using SQLite and LINQ in C#[/url]. Edited by Cornstalks

Share this post


Link to post
Share on other sites
Thanks everyone for the responses.

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement