Archived

This topic is now archived and is closed to further replies.

krez

c++ database

Recommended Posts

krez    443
i''m working on my RPG engine (like everyone else who isn''t doing a 3D engine or an RTS) and i have come to a point where i no longer want to load stuff from individual files. when i used to play with VB i used a ms-access database for this type of thing, so I could build classes and fill them in with SQL and recordsets and whatnot. so, does anyone know of any database-things i could use for this in c++? i don''t want to use ms-access, and i don''t want to pay [much if anything] for it; i just want the ability to create tables, link them (or use SQL for this), and get data to put in my classes. i was considering writing my own format, but that would take time away from the game itself (plus why the hell would i want to program an SQL parser in c++ when i can possibly use someone elses stuff?). any suggestions? --- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
CaptainJester    523
Try mySQL. It is a great little SQL database that is also free. Plus they provide APIs for many languages to get direct access to the database. You can also do it with indirect access by using command line options and text files.

---
Make it work.
Make it fast.

Share this post


Link to post
Share on other sites
steg    390
Just a thought, you could use ADO, that way you can easily modify which database you are using via ODBC i.e.access, SQL server....

I know MySQL is free on Unix/Linux platform, maybe the same for Windows platform ?

Reg''ds,
sTeVe

Share this post


Link to post
Share on other sites
krez    443
wow that was fast!
i will check out mySQL now... feel free to recommend anything else though, just in case

EDIT:
well, i can't download this at work, so i'll have to wait until tonight. but, i have a question for you.
from the screenshots it appears as if you have to run a database server (i've used similar things before, interbase with java for example) to get access to the database files. what i want is more of a "file structure" + "API to interact with it" than a "set up server, run server, call server to get data from a file". i mean, i will if i have to, but i'd rather not
maybe i misperceived mySQL (i did only see the screenshots, and i didn't download yet), hopefully i did in fact
but, if not, is there anything else similar to what i described? (for example, with VB and MS-Access, you can just include the "MS DAO Library", and use their database, recordset, whatever objects)

--- krez (krezisback@aol.com)

Edited by - krez on January 3, 2002 4:28:39 PM

Share this post


Link to post
Share on other sites
eldee    122
quote:
Original post by krez
i''m working on my RPG engine (like everyone else who isn''t doing a 3D engine or an RTS

hah, the truth is painful indeed




-eldee
;another space monkey;

Share this post


Link to post
Share on other sites
krez    443
quote:
me: i''m working on my RPG engine (like everyone else who isn''t doing a 3D engine or an RTS)
eldee: hah, the truth is painful indeed

even more painful: mine is going to be better than all those other ones, just like everyone else''s

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
DrPizza    160
Do not use MySQL.

Use Jet (Access) or PostgreSQL or sapDB or MS SQL Server or DB2 or Oracle or ANYTHING.

But not MySQL.

It... is... crap . Its lack of subselects, for instance, makes all manner of what should be simple things very fiddly to do.

ADO and DAO are database agnostic; however, if you want a file database (which stores its data in a single easily transportable self-contained file), your best bet is probably Access/Jet.


Share this post


Link to post
Share on other sites
alexk7    138
Is it a server-based multi-player game ? If yes, go ahead with a database. However, for a game, I suggest to create your own file format. Even if you don''t mind the performance hit of a huge database system, can you imagine a game in the store with this in the specs: "require MySQL installed on the system to run"...

Share this post


Link to post
Share on other sites
Brannon    122
Do a search on google for "xbase library". xbase is a very simple file-based database format. It uses the ISAM approach (Indexed Sequential Access Method), rather than SQL.. meaning that you iterate over records yourself, rather than writing a SQL query. If you use indexes correctly, then the iterating is "more" effecient (than if you iterate without indexes). There should be several libraries out there that will do it all for you. There is also database "management" software out there for xbase databases .. like dBase and FoxPro.

Once you look over the xbase file format though, you''ll want to create your own file format. the format is so simple (and so limiting in some ways).


-Brannon

Share this post


Link to post
Share on other sites
krez    443
yah, that's the thing... i just want a way to save and load a few characters information from a huge file that holds the information for all the characters in the game. my old way was to dynamically piece together an SQL:

Public Sub LoadCharacter(CharUID As String)
SQLString = "SELECT * FROM tblCharacters WHERE charUID='" + CharUID + "'"
'use the SQL to get a recordset from ms-access, and use that data
End Sub

i mean, i want to use it for loading the other data too (maps, whatever), but that is the basic functionality i want: save/load stuff with a bit of indexing and whatnot.
i definitely do not want to have to install anything (or run anything) extra, just a format and maybe a DLL for the API.
it is a single-player game, so all that is not necessary.
i was considering writing my own thing, and i'm pretty sure i could pull it off (at least for my limited goal), but that'd be a whole other project dropped right in the middle of my game project...

--- krez (krezisback@aol.com)

Edited by - krez on January 3, 2002 6:40:36 PM

Share this post


Link to post
Share on other sites
CaptainJester    523
Then you probably want to just create your own flat-file database format. All you have to do is use delimeters between fields and use a second, different delimeter, between records. This way, you could use the first field as an index, then you look for the record delimeter while throwing away everything else. Reading from a file is fairly quick, and if you use index numbers and random access, it is even quicker. If the file gets large, you shouldn''t have to worry too much about performance, as you are not writing a FPS.

---
Make it work.
Make it fast.

Share this post


Link to post
Share on other sites
Rube    122
mySQL isn''t crap, just has a niche use. I wouldn''t call it robust, but for a quick, easy to set up and roll out DB, it does it''s job. As for saying use Jet over mySQL, then you''re just crazy!

Anyways, doesn''t sound like you want a DB server, just a DB file format and a library of functions to manipulate it.

Look into DBM, or GDBM. It''s the Berkley DB format, which is just a flat file database format. The good part is that there are well documented libraries for the DBM/GDBM, so you won''t have to create your own file structure and functions. I know there are some ports to GDBM to windows, just do a search for GDBM+Windows+C++.

If you''re on Unix/Linux, then you probably have them already installed. Try "man gdbm" or "man dbm" to find out more.

G''luck with the project.

R.

Share this post


Link to post
Share on other sites
Cyberdrek    100
quote:
Original post by steg
Just a thought, you could use ADO, that way you can easily modify which database you are using via ODBC i.e.access, SQL server....

I know MySQL is free on Unix/Linux platform, maybe the same for Windows platform ?

Reg''ds,
sTeVe



Yep, MySQL is free also for windows...



"And that''s the bottom line cause I said so!"

Cyberdrek

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash

Share this post


Link to post
Share on other sites
Cyberdrek    100
quote:
Original post by krez
yah, that''s the thing... i just want a way to save and load a few characters information from a huge file that holds the information for all the characters in the game. my old way was to dynamically piece together an SQL:

Public Sub LoadCharacter(CharUID As String)
SQLString = "SELECT * FROM tblCharacters WHERE charUID=''" + CharUID + "''"
''use the SQL to get a recordset from ms-access, and use that data
End Sub

i mean, i want to use it for loading the other data too (maps, whatever), but that is the basic functionality i want: save/load stuff with a bit of indexing and whatnot.
i definitely do not want to have to install anything (or run anything) extra, just a format and maybe a DLL for the API.
it is a single-player game, so all that is not necessary.
i was considering writing my own thing, and i''m pretty sure i could pull it off (at least for my limited goal), but that''d be a whole other project dropped right in the middle of my game project...

--- krez (krezisback@aol.com)

Edited by - krez on January 3, 2002 6:40:36 PM


IMHO, I wouldn''t really recommend using a database to store info for a game as the access time to a database can be slower than the access time to a file. You should actually use binary files and not bother with Databases unless you''re creating a database app, like an invoicing program or an e-commerce web site...



"And that''s the bottom line cause I said so!"

Cyberdrek

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash

Share this post


Link to post
Share on other sites
krez    443
quote:
Original post by Cyberdrek
IMHO, I wouldn''t really recommend using a database to store info for a game as the access time to a database can be slower than the access time to a file. You should actually use binary files and not bother with Databases unless you''re creating a database app, like an invoicing program or an e-commerce web site...

yah, i''m probably not going to [now]... i was looking forward to fun and excitement of using SQL to pick the records, and it doesn''t have to be extremely fast as it would only matter during load time (once at the beginning, and a little bit every map change).
but most likely i''m going to just index the records and search them by that.

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites