help on Indexing contents in file

N

Nash

Hi All,
I have set of data which needs to be stored in a file. The data is
classified into categories say Cat 1, Cat 2... Cat 10 each category
can have any number of entries. The program allows user to rate items
of each category as 1,2&3. Now i need to store the ratings in a file
and whenever the items of categories are listed i should show rating
along with it.
Initially file should be empty. Whenever the user rates an item then
only i need to add an entry into a file. I dono in what format i
should store the data in the file so that i can access the data
quickly. Please provide some pointers.

Thanks in advance.
 
G

Giovanni Dicanio

I have set of data which needs to be stored in a file. The data is
classified into categories say Cat 1, Cat 2... Cat 10 each category
can have any number of entries. The program allows user to rate items
of each category as 1,2&3. Now i need to store the ratings in a file
and whenever the items of categories are listed i should show rating
along with it.
Initially file should be empty. Whenever the user rates an item then
only i need to add an entry into a file. I dono in what format i
should store the data in the file so that i can access the data
quickly. Please provide some pointers.

In these days, XML (which is very eXtensible :) format is widely used.
I would suggest that, too.

But if you really need performances and speed of reading, you may use an ad
hoc optimized binary format for your file.
In fact, XML needs advanced parsing, while a "flat" binary file (designed ad
hoc) can be read and processed more quickly.

(However, it all depends on your particular problem; talking about
performances *in general* has little sense.)

Giovanni
 
D

David Lowndes

Initially file should be empty. Whenever the user rates an item then
only i need to add an entry into a file. I dono in what format i
should store the data in the file so that i can access the data
quickly.

Your question is too general to provide a good answer to.

How fast and frequent is "quickly"? What information do you have to
reference the data by when you want to access it? How many processes
are accessing it at the same time? Do you need concurrent access over
the network?

An XML format would be flexible, but XML is rarely fast or efficient -
though it may well be fast enough for your requirements.

Dave
 
J

James Kanze

I have set of data which needs to be stored in a file. The data is
classified into categories say Cat 1, Cat 2... Cat 10 each category
can have any number of entries. The program allows user to rate items
of each category as 1,2&3. Now i need to store the ratings in a file
and whenever the items of categories are listed i should show rating
along with it.
Initially file should be empty. Whenever the user rates an item then
only i need to add an entry into a file. I dono in what format i
should store the data in the file so that i can access the data
quickly. Please provide some pointers.

The obvious answer would be to use a data base, something like
mySQL (probably adequate here) or PostgreSQL. If that's more
than you need, and the data set fits into memory, a simple file
with attribute value pairs might be sufficient. The choice of
one or the other, or something in between, depends a lot on
factors we don't know: the size of the data set, the frequence
and pattern of accesses, etc.
 

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

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,383
Latest member
EzraGiffor

Latest Threads

Top