[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Three ways to organize data

  • From: Roger L Costello <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Mon, 20 Mar 2023 16:02:19 +0000

Three ways to organize data

Hi Folks,

Below are three ways of organizing data for searching. I have seen all three ways in a project that I am working. The first way is how text data was organized in the 1970s. The second way is how data is organized by a database-oriented shop. The third way is the XML way.

The first way embeds codes in the records. Searching involves using the codes to narrow the search. Below is an example that uses these codes: Type = B (Book), Subtype = C (Computer), Type = W (Watch), Subtype = Q (Quartz), Type = A (Author), Subtype = P (Professor), Type = E (battEry), Subtype = L (Lithium).

<Records>
    <Record>
        <Type>B</Type>
        <Subtype>C</Subtype>
        <Title>Programming Languages Application and Interpretation</Title>
        <Date>2007</Date>
        <Author>Krishnamurti</Author>
        <Type>A</Type>
        <Subtype>P</Subtype>
    </Record>
    <Record>
        <Type>W</Type>
        <Subtype>Q</Subtype>
        <Brand>Timex</Brand>
        <Model>Indiglo</Model>
        <Power>Battery</Power>
        <Type>E</Type>
        <Subtype>L</Subtype>
    </Record>
    <Record>
        <Type>A</Type>
        <Subtype>P</Subtype>
        <Name>Shriram Krishnamurti</Name>
        <Employer>Brown University</Employer>
    </Record>
    <Record>
        <Type>E</Type>
        <Subtype>L</Subtype>
        <Chemistry>Lithium</Chemistry>
        <Volts>3</Volts>
    </Record>
</Records>

 

Suppose we want to search for the computer book written by Shriram Krishnamurti and then find his employer.  To find the computer book, search for the record with Type = B (Book), Subtype = C (Computer) and the author field containing Shriram Krishnamurti. That yields the first record shown above. Then use its second set of Type/Subtype fields (Type = A, Subtype = P) to locate the record about the author. That yields the third record, which shows that he is a professor at Brown University.

The second way is to use multiple documents – a document containing book data, a document containing author data, a document containing watch data, a document containing battery data – and use primary/foreign keys to connect the documents together. Here are the four documents:

Books.xml

<Books>
    <Book>
        <PrimaryKey>PLAI</PrimaryKey>
        <Title>Programming Languages Application and Interpretation</Title>
        <Date>2007</Date>
        <Author>Krishnamurti</Author>
        <ForeignKey>SK</ForeignKey>
    </Book>
</Books>

 

Authors.xml

<Authors>
    <Author>
        <PrimaryKey>SK</PrimaryKey>
        <Name>Shriram Krishnamurti</Name>
        <Employer>Brown University</Employer>
    </Author>
</Authors>

 

Watches.xml

<Watches>
    <Watch>
        <PrimaryKey>TimexInd</PrimaryKey>
        <Brand>Timex</Brand>
        <Model>Indiglo</Model>
        <ForeignKey>Lit</ForeignKey>
    </Watch>
</Watches>

 

Batteries.xml

<Batteries>
    <Record>
        <PrimaryKey>Lit</PrimaryKey>
        <Chemistry>Lithium</Chemistry>
        <Volts>3</Volts>
    </Record>
</Batteries>

 

Again, suppose we want to search for the computer book written by Shriram Krishnamurti and find his employer.  To find the computer book, search Books.xml for the record with the author field containing Shriram Krishnamurti. Use its foreign key to reference a record in Authors.xml.

The third way is to use the ID-IDREF capability of XML.

<BooksAndWatches>
    <Book id="PLAI">
        <Title>Programming Languages Application and Interpretation</Title>
        <Date>2007</Date>
        <Author idref="SK">Shriram Krishnamurti</Author>
    </Book>
    <Watch id="TimexInd">
        <Brand>Timex</Brand>
        <Model>Indiglo</Model>
        <Power idref="Lit">Battery</Power>
    </Watch>
    <Author id="SK">
        <Name>Shriram Krishnamurti</Name>
        <Employer>Brown University</Employer>
    </Author>
    <Battery id="Lit">
        <Chemistry>Lithium</Chemistry>
        <Volts>3</Volts>
    </Battery>
</BooksAndWatches>

 

To find the computer book written by Shriram Krishnamurti we search for the Book element with Author = Shriram Krishnamurti. To find his employer follow the idref value on the Author element.

TaDa!

Three different ways to organize data: the old (1970s) way, the database way, and the XML way.

/Roger

 

 

 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.