Sign In/My Account | View Cart  
advertisement

Article:
 Storing XML in Relational Databases
Subject: HELP! newbie needing to do something tricky...
Date: 2005-04-08 15:08:16
From: RacerZack

Wow, what a cool site. I'm new to working with XML (although I am familiar with relational databases). I currently need to import a hierarchical XML file into MS Access or SQL Server. My problem is that child nodes in the XML document do not contain any key data from the parent. How do I get this data imported into a relational database and make sense of it?


Example:
<rootNote>
<Customer>
<Name>Zack</Name
<CustomerID>123</CustomerID>
<Order>
<OrderID>888</OrderID>
<PartNumber>176</PartNumber>
</Order>
<Order>
<OrderID>355</OrderID>
<PartNumber>999</PartNumber>
</Order>
</Customer>
</rootNode>


This XML will give me 2 tables in Access. One table, [Customer] contains 2 fields: [Name] and [CustomerID]. The other table, [Order], also contains 2 fields: [OrderID] and [PartNumber]. Once inside of Access, I have nothing to connect the data in the [Order] table with the data in the [Customer] table.


Within the hierarchical XML, the relationship is obvious from the fact that <Order> nodes are children to <Customer>.


Is there ANY solution for this? I've had an open issue with Microsoft on this for a week now and it pretty much looks like the answer from them is "can't be done." Grrr.


The only solution I can see is to include parent key data (such as <CustomerID>) at each child node. But that would suck. My example is little, but the real XML file I have is huge and has *multiple* levels of hierarchy.


Thanks!


Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • HELP! newbie needing to do something tricky...
    2005-04-09 09:55:03 Igor Dayen

    If you are using MS SQL Server 2000 / 2005 you may consider using OPENXML for storing XML in a single,
    flat table; and thereafter transform the latter one into two tables.


Sponsored By: