Solved

XML and file of records

Posted on 2002-03-04
5
167 Views
Last Modified: 2013-11-23
hi...i'm basically new to XML and i'd like to learn about how i could use XML as a database as a substitute to using a file of records. how can i implement a database using an XML? i've downloaded samples and parsing component but i'm not quite sure how to implemetn them...can anyone offer some help?
thanks! :)
0
Comment
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:edsteele
Comment Utility
Take this for what it is: my opinion.

You probably don't want to use XML as your final storage and retrieval format.  It will make the size of the files you store much larger than need be.  XML is very useful for passing data from one location to another in an independent fashion.  It's not well suited for storing a lot of data.

If you have a small amount of data that you always want to access using XML, then maybe you have an argument to go in that direction.  But every time you want to add new data, you will have to add it formatted in your XML format.

The parsing routines are for tearing the XML apart.  Given a stream, file, etc. containing XML, the parser can traverse the tree and retrieve the requested data.

I believe your best bet is to store your data in a database and either let the database return the results in XML format, if it supports that, or to have your SELECT statements return formatted XML.  This has the added benefit of only returning the data you need right then and allows you to sort the data before it is placed in the XML format.

Please follow-up with more information as to how this data is stored and used if you would like more help (assuming this was helpful :)  ).
0
 

Author Comment

by:dabestprogrammerindauniverse
Comment Utility
hi edsteele...
my database is composed of files only...different files per record type. so if i have a record type 'A', and record types 'B', 'C' and 'D' which have different fields, then i'd have to store them in different files because they can't be uniformly read.  meaning, i have to program how i would like to treat the different files (opening, reading, searching, writing).  but if i use XML then i can store multiple record types within 1 XML file.  there will be no problem in opening the file since XML is text. so when i want to add a new record type which have fields in it all i have to do is add tags and its subnodes.

sample:

 dealtypeA = record
      field1 : integer;
      field2 : str4;
      field3 : str25;
 end;

 dealtypeB = record
      field1 : str1;
      field2 : str40;
      field3 : double;
      field4 : str5
 end;
 
 dealtypeA = record
      field1 : integer;
      field2 : integer;
 end;

 dealtypeA = record
      field1 : integer;
 end;

manipulate 4 record types, if u have and xml database you can define these 4 as

<dealtypes>
  <dealtypeA>
    <field1> </field1>
    .
    .
    .
  </dealtypeA>

  <dealtypeB>
    <field1> </field1>
    .
    .
    .
  </dealtypeB>

  <dealtypeC>
    <field1> </field1>
    .
    .
    .  
  </dealtypeC>

  <dealtypeD>
    <field1> </field1>
    .
    .
    .  
  </dealtypeD>

</dealypes>

also for search the database all you have to do is pass the tag name...much like a query and the parser returns the results. so it simplifies things because you have the field names specified unlike having to define 'specific' records'. so when i want to add a new field to a certain deal type, all i have to do is add a new tag under that deal type which makes all other previous data of that deal type still readable unlike when adding a new field to a record type, it will render all old record types unreadable or useless.

is what i have in mind correct? pardon me for any mistakes, i'm new to this thing and i'd like to find out if what i have in mind is applicable.
thanks a lot!
0
 
LVL 1

Expert Comment

by:edsteele
Comment Utility
It sounds like you have the majority of what you need already straight in your mind.  What you want to do is definitely possible.  I want to get some assumptions straight.  My assumptions are:

- You have an XML parsing component and can use it.
- You are OK with the fact that your text files will be bigger in XML format.
- You want to know how to utilize these in a database-like fashion.

You can use the XML parser for searching and querying, however, you still need to write the parts that populate the file.  There are no provisions for deleting or updating without traversing the file as normal.  XML is used primarily to pass data to and from disparate systems that would otherwise not be able to do so.  Therefore, the data doesn't exists very long in that format.  If changes need to be made, the new data is recreated as XML from the original format.  Any individual "snapshot" of XML data almost never gets updated.

If you have your mind set on doing it this way, you currently have only the reading/querying piece in your hands.  You will need to write code to:

- Create new records and append them to the file.
- Delete records from the file.
- Update records in the file (This might be a delete followed by a create, to save code).

If these different record configurations are not related or are related in very predictable ways, I would still recommend an actual database with a different table per file record configuration.

I'm trying to help here, but I feel like I'm not doing you a great deal of good.  If any of my assumptions are wrong, please correct me so I can give you a better answer.

Eric
0
 

Author Comment

by:dabestprogrammerindauniverse
Comment Utility
actually you're right on track, and yes i figured that to update, create and append, and delete new records i'd have to rewrite the whole thing...but since my boss won't allow us to use a database such as SQL Server (to cut the cost of the application...no license fees needed for the database)...i figured searching and querying would be faster(?) and efficient and very much flexible...but the drawback is writing the database...i guess i'll have to treat that independently...thank you very much for ur answer and ideas...if there's anything more you can add i'd greatly appreciate it! thanks again!
0
 
LVL 1

Accepted Solution

by:
edsteele earned 100 total points
Comment Utility
Well, if your stopping point is the cost of a database, look at the open source version if InterBase.  We use it for a couple of production systems with no complaints.  The link is:

http://www.ibphoenix.com/

It requires very little maintenance once it is up and running.  It runs on Windows, Linux and other Unix flavors.  I highly recommend it.

Good Luck!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now