From: Robert Klemme Date: 2008-04-02T00:18:12+09:00 Subject: Re: should I use a database or a flat file? 2008/4/1, James Dinkel : > I need to store some information with my ruby program and I am not sure > on what would be the best method. I'm mostly concerned about what would > be the most efficient use of cpu resources. > > Basically, I will have a list of names each belonging to one of 5 > categories. Sort of like this: > > Cat1 > -name1 > -name2 > -name3 > -etc... > > Cat2 > -name4 > -name5 > -name6 > -etc... > > Cat3 > -name7 > -name8 > -name9 > -etc... > > There will be hundreds of names, evenly divided between the categories. That's not much. I'd probably use XML - but that also depends on what generates the data and what needs to be able to read it. You can efficiently generate it and read it (using a stream parser for example, but that seems unnecessary for hundreds of names only). But ultimately it depends on what you want to do with the data. In some cases a DB might be a better choice. Also, if your volume is going to increase dramatically etc. > But each name will go in only one category, there is no relation between > categories or anything like that. All the information will be > completely rewritten once a day and then read several times throughout > the day. > > My choices for storage are an sqlite database (using ActiveRecord), a > flat text file of my own design, a YAML file, or an XML file. YAML is another nice alternative because it is human readable. And you can use Marshal if producer and consumer of the data are Ruby programs. Kind regards robert -- use.inject do |as, often| as.you_can - without end