473,320 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

What is used for storage

Hello all,

I am a C++ beginner.

I would like to know where and how a C++ application stores it's data.

For example, imagine an application to manage your DVD collection. DVD can
be enterd into it by typing a name, duration, description. What is most
common, best practice: to store the DVD's entrys in a flatfile, in a
database (what database) or is there another solution.

I can imagine that maybe for not much data a flatfile is the best solution
but as the DVD collection will grow over time maybe a database is a better
solution?

Marcel
Jan 11 '06 #1
11 1885
Marcel wrote:
Hello all,

I am a C++ beginner.

I would like to know where and how a C++ application stores it's data.
Where you tell it to.
For example, imagine an application to manage your DVD collection. DVD can
be enterd into it by typing a name, duration, description. What is most
common, best practice: to store the DVD's entrys in a flatfile, in a
database (what database) or is there another solution.
Well, RAM, initially, and then if you need it to persist, then a file
and a database or probably two most common options.
I can imagine that maybe for not much data a flatfile is the best solution
but as the DVD collection will grow over time maybe a database is a better
solution?


Correct.

For now, I suggest you use a file. When performance becomes a problem,
work out another solution.

If you abstract the reading and writing behind an interface, then you
should be able to change the implementation from a file to a database
without changing too much code.

#include <vector>
#include <string>

class myData {};

// Pure abstract Interface
class serialiser {
public:
virtual ~serialiser() = 0 {}

virtual std::vector<myData> read() = 0 {}
virtual bool write(const std::vector<myData>& vec) = 0 {}
};

class file : public serialiser {
public:
file(std::string& filename) {/*open file*/}
~file() {/*close file*/}
std::vector<myData> read() { return std::vector<myData>(); }
bool write(const std::vector<myData>& vec) { return false; }
};
class database : public serialiser {};

int main() {
std::string filename("filename");
std::auto_ptr<serialiser> dataStore(new file(filename));
std::vector<myData> data = dataStore->read();
}

That should give you the basic idea, obviously all the difficult bits
are missing.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Jan 11 '06 #2
As you are a C++ beginner you should go for flat files first.
The disadvantage is that it can be accessed from the local machine only
(unless you're using shared file systems (NFS, Samba, ...)).
The design should encapsulate the I/O of an entry in the collection:
define the necessary interface in an abstract base class and provide
a concrete implementation that works with flat files.

Later you can expand your design by the strategy pattern and provide
an I/O interface to a database.

Regards, Stephan

Jan 11 '06 #3

"Marcel" <so***************@nospam.com> schreef in bericht
news:fc**************************@cache40.multikab el.net...
Hello all,

I am a C++ beginner.

I would like to know where and how a C++ application stores it's data.

For example, imagine an application to manage your DVD collection. DVD can
be enterd into it by typing a name, duration, description. What is most
common, best practice: to store the DVD's entrys in a flatfile, in a
database (what database) or is there another solution.

I can imagine that maybe for not much data a flatfile is the best solution
but as the DVD collection will grow over time maybe a database is a better
solution?

Marcel


Ok thanks for your advice friends!

Marcel
Jan 11 '06 #4
On Wed, 11 Jan 2006 12:21:22 +0100, "Marcel"
<so***************@nospam.com> wrote:

Ok thanks for your advice friends!


Three small posts in an ocean of indifference.

Need I say more? No, no more. I will try to do my part as well.

[In a quiet humble voice]
"No crime is so great as daring to excel."
- Winston Churchill
Jan 11 '06 #5

"JustBoo" <Ju*****@BooWho.com> wrote in message
news:tp********************************@4ax.com...
On Wed, 11 Jan 2006 12:21:22 +0100, "Marcel"
<so***************@nospam.com> wrote:

Ok thanks for your advice friends!


Three small posts in an ocean of indifference.

Need I say more? No, no more. I will try to do my part as well.

[In a quiet humble voice]
"No crime is so great as daring to excel."
- Winston Churchill


What????? Perhaps you wanted alt.poetry?

-Howard
Jan 11 '06 #6
Ben Pope wrote:
Marcel wrote:
Hello all,

I am a C++ beginner.

I would like to know where and how a C++ application stores it's
data.


Where you tell it to.
For example, imagine an application to manage your DVD collection.
DVD can be enterd into it by typing a name, duration, description.
What is most common, best practice: to store the DVD's entrys in a
flatfile, in a database (what database) or is there another
solution.


Well, RAM, initially, and then if you need it to persist, then a file
and a database or probably two most common options.
I can imagine that maybe for not much data a flatfile is the best
solution but as the DVD collection will grow over time maybe a
database is a better solution?


Correct.

Depends. The size doesn't matter all that much, especially with modern
computers. You can rip through even a sizeable flatfile in short order.
It's really more of how you're using the data. If there are going to be
lots of complicated searches and such, then a relational database will
become important. Naturally, proper design of the tables becomes vital
at that point, but that's well outside the scope of this newsgroup.

Brian
Jan 11 '06 #7
On Wed, 11 Jan 2006 17:49:32 GMT, "Howard" <al*****@hotmail.com>
wrote:
"JustBoo" <Ju*****@BooWho.com> wrote in message
news:tp********************************@4ax.com.. .
On Wed, 11 Jan 2006 12:21:22 +0100, "Marcel"
<so***************@nospam.com> wrote:
[In a quiet humble voice]
"No crime is so great as daring to excel."
- Winston Churchill


What????? Perhaps you wanted alt.poetry?
-Howard


Don't quit your day job Howie. If you have one....

Men occasionally stumble over the truth, but most
of them pick themselves up and hurry off as if
nothing had happened. - Winston Churchill
Jan 11 '06 #8
JustBoo wrote:
[insult redacted]


*PLONK*
Jan 11 '06 #9

"JustBoo" <Ju*****@BooWho.com> wrote in message
news:rf********************************@4ax.com...
On Wed, 11 Jan 2006 17:49:32 GMT, "Howard" <al*****@hotmail.com>
wrote:
"JustBoo" <Ju*****@BooWho.com> wrote in message
news:tp********************************@4ax.com. ..
On Wed, 11 Jan 2006 12:21:22 +0100, "Marcel"
<so***************@nospam.com> wrote:
[In a quiet humble voice]
"No crime is so great as daring to excel."
- Winston Churchill


What????? Perhaps you wanted alt.poetry?
-Howard


Don't quit your day job Howie. If you have one....

Men occasionally stumble over the truth, but most
of them pick themselves up and hurry off as if
nothing had happened. - Winston Churchill


Ooh, it called me "Howie"! A touch, I do confess it! I fear I breathe my
last. Oh woe...

*plonk*


Jan 11 '06 #10
On Wed, 11 Jan 2006 19:32:14 GMT, "Howard" <al*****@hotmail.com>
wrote:
"JustBoo" <Ju*****@BooWho.com> wrote in message
news:rf********************************@4ax.com.. .
On Wed, 11 Jan 2006 17:49:32 GMT, "Howard" <al*****@hotmail.com>
wrote:Ooh, it called me "Howie"! A touch, I do confess it! I fear I breathe my
last. Oh woe...


Yeesh, like I said, don't quit your day job. And if this is what the
witless sheep call "Sarcasm...." Man, I mean, what would an actual
joke look like to the gray robots. A nut with a screw in it?

"The dullness of the fool is the whetstone of the wits." Indeed.

They fall in line in such a predictable manner. Almost as if
scripted... mmm.
*plonk*


Wow, a sheep with two heads! What a concept. I wonder if sheep, two
heads or one, realize they get what they give... Nah! Don't be silly,
that would require actual thought and not just repetitive Pavlovian
braying.

"There is real magic in enthusiasm. It spells the difference between
mediocrity and accomplishment." - Norman Vincent Peale

Gray Sheep never understand that.
Jan 11 '06 #11

Correct.

Depends. The size doesn't matter all that much, especially with modern
computers. You can rip through even a sizeable flatfile in short order.
It's really more of how you're using the data. If there are going to be
lots of complicated searches and such, then a relational database will
become important. Naturally, proper design of the tables becomes vital
at that point, but that's well outside the scope of this newsgroup.

Thanks for your help Brian,

I have a www/PHP background and i was learned that I/O on plaintext files is
potentially slow. But maybe i have to turn the switch in my head because now
we are talking about C++ applications.....

Regards,

Marcel
Jan 12 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Steven T. Hatton | last post by:
I just read this in the description of how C++ is supposed to be implemented: "All external object and function references are resolved. Library components are linked to satisfy external...
5
by: Olaf Gschweng | last post by:
We're new into DB2 and have some problem with DB2 8.1 (?) on a Linux system. We load some big tables of a DB2 database from files every day. We do a "DELETE FROM table" for each table and then we...
4
by: Kums | last post by:
Step 1: Write suspend for database. Connect to database. Issue the following command: db2 set write suspend for database Step 2: Create True Image Create a True Image of the required NAS...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
7
by: MrNobody | last post by:
I was a Java developer so I'm used to using property files as a means to keep configuration settings for my apps. I'm wondering what options are there with ..NET? Some settings I want to include...
2
by: Ma Xiaoming | last post by:
Dear ladies and gentlemen, I don't understand what the difference between the Heap and the Stack is. Could you please explain the difference between the both for me? Thank you very much. ...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Group, After a long week end I am back again. Its nice and refreshing after a short vacation so lets get started with .NET once again. Today we will discuss about Isolated Storage. This is...
18
by: rajpal_jatin | last post by:
int main() { int k; union jatin{ int i :5; char j :2; }; union jatin rajpal; k= sizeof(rajpal);
20
by: jacob navia | last post by:
Consider this code static typedef struct { int boo; } FOO; This provokes with MSVC: ------------------------------ Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for x64...
33
by: James H. Newman | last post by:
I have a portion of code along the following lines: volatile unsigned char x ; unsigned int f(unsigned char *y) ; When I do unsigned int z = f(&x) ;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.