Skip to main content
GameDev.net gamedev.net
🔒 Locked

Database tutorial?

Started by maya18222 Dec 20, 2011 at 10:32 AM 5 replies 1.6k views
Original Post
maya18222
maya18222
I really have had no experience what so ever with databases, neither setting them up or using them. I was wondering if someone could point me into the right direction for a tutorial that would allow me to create a database and then access it and query it from C++.

There seems to be quite the array of C++ sql libraries.

Am I right in thinking that I could just use the current machine as the database server?
NDraskovic
NDraskovic

I really have had no experience what so ever with databases, neither setting them up or using them. I was wondering if someone could point me into the right direction for a tutorial that would allow me to create a database and then access it and query it from C++.

There seems to be quite the array of C++ sql libraries.

Am I right in thinking that I could just use the current machine as the database server?

I'm not sure about C++, but I used C# .NET and it was simple enough - even without any specific tutorial's. What programming environment are you using?


Kraecker
Kraecker
You should to know what DBMS you want to use.

For me, SQlite works just fine, cause it has a simple API and is very lightweight.

Just take a look at http://www.sqlite.org/quickstart.html
There is also a C style example.

Using your current machine as "database server" for SQlite (it's just a file) is the easiest thing you can do, everything else will require extra setup.
maya18222
maya18222
Im using Microsoft SQL Server R2 Express atm with Sqlapi so I can access the data from C++. Any ideas what API you're supposed to use with Microsoft SQL server? I know theres many third party ones, but what is the Microsoft one?
TheTroll
TheTroll

You should to know what DBMS you want to use.

For me, SQlite works just fine, cause it has a simple API and is very lightweight.

Just take a look at http://www.sqlite.org/quickstart.html
There is also a C style example.

Using your current machine as "database server" for SQlite (it's just a file) is the easiest thing you can do, everything else will require extra setup.


Go download the "Microsoft ODBC 3.0 Software Development Kit and Programmer's Reference" that will give you what you need.

Now how complicated is this database? There is a lot more that does into making a good database then people think.

theTroll
Matt-D
Matt-D
SOCI is easy enough and actively maintained:
http://soci.sourceforge.net/
http://soci.sourceforge.net/doc/

DbiXX is an alternative:
http://art-blog.no-ip.info/wikipp/en/page/ref_dbixx
larsbutler
larsbutler

I really have had no experience what so ever with databases, neither setting them up or using them. I was wondering if someone could point me into the right direction for a tutorial that would allow me to create a database and then access it and query it from C++.

There seems to be quite the array of C++ sql libraries.

Am I right in thinking that I could just use the current machine as the database server?


If you're completely new to databases, I recommend this: http://sql.learncodethehardway.org/book/ It looks like the book isn't quite complete, but it should at least serve as a good intro. Personally, I've found Zed Shaw's books to be very practical and helpful.

This doesn't cover using a DB in C++, but you need to learn how to use them first.

In what capacity are you going to be using a database? Does the database need to serve multiple client machines, or this is simply going to be used on the local machine as storage for your game? If the latter, go with SQLite.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.