Relatively simple question. Help greatly appreciated :-)

  • Thread starter Thread starter Simon Harvey
  • Start date Start date
S

Simon Harvey

Hi everyone,

I have a question about how data is stored and persisted in a realworld
application. I am currrently making an email client, newsreader and RSS
Agregator application. I'm just using this as a practice application to
learn some new skills.

My question(s) concerns what I should do to store information. In
particular, the email messages, and news group posts etc.

To focus on the email that will need to be stored - I'm wondering about how
applications like Outlook would store this information.

I was wondering -

1. What data structure do you suppose I should use for internal storage? I
don't have a lot of knowledge about how effective the structures would be in
this sort of scenario.
2. What mechanism of persistence should I use? Again, I don't know too much
about this. I was thinking about binary serialisation. Or maybe outputting
the folders and email messages as XML?

Any advice about what I should do would be great.

One other thing I was wondering about was - how do you suppose an
application like Outlook loads its messages? I mean, do you think it loads
all the messages into memory at startup? That could be quite inefficient.
Perhaps it loads a key of some sort that identifies a message still stored
on the hard disk?

I'm just thinking how to get a balance between carrying out actions quickly,
and not using copius amounts of memory. Bearing in mind that some people can
have hundreds of messages in tens of folders.

I'd really appreciate some advice on the sort of approach I should take

Thanks Everyone!

Simon
 
How I would probably do it (and I'm working on an app with similar data, and
I am doing it this way), is to store the header information (from, to, date,
time, etc) in one place, and the actual body of the text separately, with
indexes in the header information to where the body can be found.

This doesn't necessarily have to mean two separate files, but for
simplicity, that would be the best approach, I think.

You could then load all the header information on startup. Sort the e-mails,
etc, but only pull up the actual text on demand.

Hope this helps.

Pete
 
Hi Pete,

Thats a great help. I was begining to think more and more along those lines
as well.

I am still stuck on a couple of thngs though:

1. What sort of data structure do you think I should use for the header
objects that I'll create.

2. Do you have any suggestions what I should use as a 'primary key' - to
identify messages uniquely. I'm thinking I would need some sort of key to
index each message. I'm not sure what I could use to make the key unique
though.

3. What sort of file format should I use for persistence? If I use a header
file in memory, it will somehow have to point to a message on the disk
drive. Do you have any suggestions as to what I could use to store the email
messages on the disk drive. I'm not really sure what my options are in this
respect.

I guess we have serialization of a 'Message' object as binary data. Or maybe
XML. But then I'm just trying to think how this would work in terms of
accessing the messages at runtime as they are stored on the disk.

Thanks again for your help. I really appreciate it.

Take Care

Simon
 
Back
Top