473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1928
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<myD ata> read() = 0 {}
virtual bool write(const std::vector<myD ata>& vec) = 0 {}
};

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

int main() {
std::string filename("filen ame");
std::auto_ptr<s erialiser> dataStore(new file(filename)) ;
std::vector<myD ata> 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.mul tikabel.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.c om...
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*****@hotmai l.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.c om...
On Wed, 11 Jan 2006 17:49:32 GMT, "Howard" <al*****@hotmai l.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

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

Similar topics

20
3239
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 references to functions and objects not defined in the current translation. All such translator output is collected into a program image which contains information needed for execution in its execution environment." What I'm wondering is what exactly...
5
4024
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 load the data by something like that: LOAD FROM "/pathto/artikel.data" OF DEL MODIFIED BY DATESISO CHARDEL0xbf SAVECOUNT 50000 MESSAGES "/pathto/artikel.msg" INSERT INTO artikel;
4
1894
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 Volumes. Step 3: Write resume for database.
51
4567
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 there something wrong in there? -------------------------------------------------------------------- Types A type is a definition for a sequence of storage bits. It gives the meaning of the data stored in memory. If we say that the object a is an
7
5987
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 are like a root directory for a target program on the user's machine my app uses, which they would be prompted to supply at startup. Normally the registry is used for this but I'd rather not use the registry if possible. Isn't there some kind of...
2
13750
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. Best regards.
0
1881
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 one of the topics which I find interesting as I feel that it has a lot of practical usage or applicability. We all know that all applications need some storage space to archive certain
18
1953
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
3269
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 Copyright (C) Microsoft Corporation. All rights reserved.
33
5709
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
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.