Use a database or not use a database?

Howdy all,

  I have been writing a program for quite some time now and have come to a dilemma.  I have way more information than I could ever hard code into the program.  I have a lot of information that needs to be stored in some manner.  I’m just not sure how to store it in such a way that it will be easy for me to pass that information on to the end users of my application, AND easy for me to access and change.  
  Here’s the deal,  there will be about 12 main pieces.  Each with about 100 sub pieces of information, each sub piece has about 100 fields of information associated to each one.  Each one of those pieces can be a integer or a string or.. well you get the idea..
  Now its not random.. I know exactly what information I have to store, its just a matter of figuring out how to store it.  This has been the killer of my app up to date.  

Can anyone give me a clue as to how to do this? What would be the best method?  My main concern here is keeping the program itself small, and keeping the number of associated files down to a minimum.  I don’t want to have to pass out any cumbersome database.  

Any examples and ideas are always appreciated.. Thanks

-Pal (Delphi 5)

PS. I am completely database illiterate so keep it simple please.. thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Pal,

I Think you MUST use a database .. I am not sure about your data .. but I think you will need 1 Tabel to finish your work..

you must have three fields like:
Main, Sub, Data

mark Main and sub as Index using (*) on paradox tabel.

save all your data like:

Main1, Sub1, Data1
Main1, Sub1, Data2
Main1, Sub1, Data100

then ..

Main1, Sub2, Data1
Main1, Sub2, Data2
Main1, Sub2, Data100

and so on until you finish to:

Main12, Sub100, Data100

save all your data as STRING and use StrToInt() and IntToStr to save and read data.

use Tabel1.FindKey() to search through your tabel with Main(x) and Sub(x).


If the information is never going to change, then I would hard code it into the app, using enumerations and arrays of typed constants based on these enumerations.  

If there is any chance that the info will change during the life of the app, then either a database, an InifFile, or, probably best, an XML file.  The latter will be easiest to understand and manually edit, but Delphi components that can work XML are still pretty rare.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You may use a db or not.

If you use a db, the fields should be:
owner, id, data(s)

here, you build a tree in db. Owner field shows the master's id. id is the current record's unique number. (you can create it by incrementing some value). Data can be string or other types. This is a little hard to establish, but you can add lot's of different datas allocated in different items.

Another way is using directories and normal files for each data. You create 12 directories, and some files, some new directories containing other files or directories on the disk... The extention of the file can represent the data type. This will minimize the code.

The most complicated, but the fastest and the one I like most is using TCollection object.

You create a collection item class that holds one data (a variant) and some other children. Write loader and storer methods. TCollection will store the tree on a stream, the stream stores it on a file. Thats all.

Also you should write an editor for it :)

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Hi Again Palamedes,

I think denizcan wrote good ideas .. but it seems to be defficult for the begginners ..

using TCollection is a good Idea but it needs an advanced steps.
Hi Palamedes,

You can use INI file like this:

[Main Item 1]
[Main Item 2]

and so on.

In program:

  IniFile : TIniFile;
  IniName : String;
  sPiece  : String;
  IniName := 'c:\myini.ini';
  IniFile := TIniFile.Create(IniName);
  sPiece := TIniFile.ReadString('Main Item 2', 'Piece1', '');

I think it's functional as TIniFile object has many useful methods.
File to use - 1 (one);
Easy to manipulate manualy - text file;
Easy to read and write via program;

Regards, Geo
PalamedesAuthor Commented:
I have been getting errors when trying to reject answers.. Internal server error.. *sigh*  Lets try this one more time..
PalamedesAuthor Commented:
Yeah!! It finally worked..


Geobul,  I have tried the INI file route.. The INI file ended up being massive and unwieldy.. However, it may be the best way to do it.. not sure..

HamidHossan,  I understand the concept, its just a matter of actually doing that in Delphi..

Denzican,  I actually have a working model of the directory system on one of my servers.  A webpage that has a very large database uses grep and perl to sort through it in that manner.  Again, I understand the concept, its just a matter of making this work in Delhpi.  (And personally the directory system wont work for me here.. thanks)

PalamedesAuthor Commented:
I like the XML file idea the best I think.. Could you give an example?
Take a look at where there is an example of Delphi code for reading and writing XML files along with other resources about XML.  Most of the implemntations these days don't actually directly read or write to the XML file, but use the parser that comes free in a dll with MSIE 5 (one came with 4 also, but it is almost crippled).

There is also an excellent component published in Delphi Magazine,, but I'm not sure if the source is available to non-subscribers.

I like XML also, but using it will be challange.  I think it will be more than worth it, though.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.