Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XML and file of records

Posted on 2002-03-04
5
Medium Priority
?
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:edsteele
ID: 6841334
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
ID: 6843736
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
ID: 6845625
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
ID: 6846251
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 400 total points
ID: 6847676
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

715 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