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:

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.