| | |
Creating a simple relational database
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 7
Reputation:
Solved Threads: 0
I am having some trouble wrapping my head around this project. I am needed to code a relational database in C++ making use of the sql selection and projection operators. I can use a 2d array to create the 'database'.
Please, if anyone could just point me in the right direction as to where to begin... I would be so grateful. I'm not looking to leech any code or get anything here I don't deserve, I'm just new to this and have very little experience with databases let alone C++.
Description of the assignment:
http://img.photobucket.com/albums/v2...g?t=1216828413
Please, if anyone could just point me in the right direction as to where to begin... I would be so grateful. I'm not looking to leech any code or get anything here I don't deserve, I'm just new to this and have very little experience with databases let alone C++.
Description of the assignment:
http://img.photobucket.com/albums/v2...g?t=1216828413
•
•
Join Date: Apr 2008
Posts: 70
Reputation:
Solved Threads: 18
One way I might think of doing this is:
1) develop an object (call it "ColumnDef") to represent a single value of one of your columns. It would contain a type property (int, string, etc), and a buffer to hold the data.
2) develop a C++/STL Map of these "ColumnDefs". This would represent a row in your table. The map would let you associate a column name with a "ColumnDef" entry.
3) develop an array of the Map objects.
That, in essence is the database. When looking for matching values of a SQL-like clause, you would start at the top of the array, evaluating each "row" by checking for a map entry matching a column in the query.
You would then build another structure like above to hold the results (an array of Map objects, each entry in the Map is a ColumnDef). This is because for the projection operation, you need to remove any possible duplicates from the results. So, you would have to also search the result structure during the insertion to ensure a duplicate is not being added.
Finally, you print out the contents of the result structure which (hopefully!) contain the actual results of the query.
Hopefully this helps!
1) develop an object (call it "ColumnDef") to represent a single value of one of your columns. It would contain a type property (int, string, etc), and a buffer to hold the data.
2) develop a C++/STL Map of these "ColumnDefs". This would represent a row in your table. The map would let you associate a column name with a "ColumnDef" entry.
3) develop an array of the Map objects.
That, in essence is the database. When looking for matching values of a SQL-like clause, you would start at the top of the array, evaluating each "row" by checking for a map entry matching a column in the query.
You would then build another structure like above to hold the results (an array of Map objects, each entry in the Map is a ColumnDef). This is because for the projection operation, you need to remove any possible duplicates from the results. So, you would have to also search the result structure during the insertion to ensure a duplicate is not being added.
Finally, you print out the contents of the result structure which (hopefully!) contain the actual results of the query.
Hopefully this helps!
-Mike
![]() |
Similar Threads
- I am New In MySQL. Problem With MySQL Database Plz Help. (MySQL)
- hover over text tips (JavaScript / DHTML / AJAX)
Other Threads in the C++ Forum
- Previous Thread: capturing audio with C++
- Next Thread: access serial device via network
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library lines linker list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting spoonfeeding string strings struct temperature template templates text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets





