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

Databasing

Started by Deamonslayer Jan 14, 2005 at 8:57 PM 4 replies 1.1k views
Original Post
Deamonslayer
Deamonslayer
Hello All, i have been trying to figure out how to make a database in C++ heres what i want to do: Items: ID# , Name, and other stats in a database but can be called on easily by the databasing. How would you make a database with this? i thought it would be similar to Delphi, using Alpha 5 Tables. sorry it seems vague. ask away on more questions. or if you have answers to this heheh thanks for the help.
Kewl Softwarez -Time is what you make of it.
Drew_Benton
Drew_Benton
Well this is what I would do:

Overview:
1. Make a structure holding all the elements of the database.
2. Create a vector of those elements.
3. Create the functions to process them (save,add,etc...)

Pseudo-Code:1. struct delement{   int Age;   char Gender;   string Name;   string Description;   string Location;}2. vector<delement> mydatabase;3. void Add( delement newentry ){   mydatabase.push_back(newentry );}void AddAt( delement newentry,int index ){   mydatabase.at(index) = newentry;}


Those are just a few examples of what you would do. I would personally make a wrapper class for the data base after the element structure is done. That way you can use all those functions in a C++ style way>

Ex:
class Database{   vector<delement> mydatabase;public:   void Add();   delement* Get(string name);   ...};


I hope this helps some. If you need any clarifications or more explanation feel free to ask.

- Drew
DudeMiester
DudeMiester
A related question, how is a relational database structure? That is, what is the theoritical concept behind it?
[s] [/s]
I can see the fnords.
jdhardy
jdhardy
Quote:
Original post by DudeMiester
A related question, how is a relational database structure? That is, what is the theoritical concept behind it?
The Entity-Relationship Model and Relational Algebra. Google should turn up some hits.
jdhardy
jdhardy
To the OP: if you want a real database engine, take a look at SQLite. It implements a pretty good subset of SQL in a database that can be embedded in your programs and stores the entire DB in a single file.

It's quite easy to use, and powerful enough for most simple purposes.

Implementing query semantics is hard, which is why there aren't a lot of really good databases. (I tried doing it using template & preprocessor metaprogramming in C++, until I got stuck on joins. I need to get my Databases textbook back to figure out join processing...)
Deamonslayer
Deamonslayer
i was looking at the SQLite, it is okay, but i think i'll want to look at the struct way of doing it for now.

To Drew, i would love to have a more detailed idea of it, i have MSN, and ICQ if you need it so we can talk better,

MSN: dsmike1487@hotmail.com

ICQ: 72780144

but an explaination would be awesome i have 3 structs as it is with values.
Objects
Mobs
Turfs

please get back to me soon, thanks for the first reply to my post. and thanks to all those who answered my post.
Kewl Softwarez -Time is what you make of it.

Topic Locked

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

Sign in to reply to this topic.