database

J

jagguy

This is a common problem but I haven't exactly found a standard answer as I
seem to have a few different opinions.
If you create a database (each record is stored in an object), then how do
program this for an unknown size of objects , Using C++.

q) what data structures would you use to create the database.

eg)Would a container (vector) with dynamically allocated objects be the
simplest solution?
 
J

Jonathan Mcdougall

jagguy said:
This is a common problem but I haven't exactly found a standard answer as I
seem to have a few different opinions.
If you create a database (each record is stored in an object), then how do
program this for an unknown size of objects , Using C++.

Two things. First, when you use a database, you usually don't want to
recreate its structure in memory. Query and the use the results
immediately.

Second, if you really want to put the database content in memory, use a
standard container, such as std::vector or std::list. If you insert
once (after querying) and then look up elements frequently, I suggest
using std::vector.


Jonathan
 
J

jagguy

pp
Jonathan Mcdougall said:
Two things. First, when you use a database, you usually don't want to
recreate its structure in memory. Query and the use the results
immediately.

Second, if you really want to put the database content in memory, use a
standard container, such as std::vector or std::list. If you insert
once (after querying) and then look up elements frequently, I suggest
using std::vector.


Jonathan
 
J

jagguy

Two things. First, when you use a database, you usually don't want to
recreate its structure in memory. Query and the use the results
immediately.

Second, if you really want to put the database content in memory, use a
standard container, such as std::vector or std::list. If you insert
once (after querying) and then look up elements frequently, I suggest
using std::vector.


Jonathan

I hit the reply instead of reply to group so sorry about that.
I can see why so many other people gave me blank answers to my question, as
it isn't a common problem.
With so many 3rd party databases around you don't need to worry about
creating a database structure in your code.
Maybe I was being a little impractical for sure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top