Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML and DB...

Status
Not open for further replies.

davism

MIS
Nov 9, 2002
140
US
Hi all,

I have a question that you may have some information for...

What is the best way to take an existing in-depth XML based application that stored the entire XML in a database but also stores each of one the nodes in the the database tables as well.

So basically (a very simplistic and *small* example) something like the entire XML:

<Person ID="50224">
<Basic>
<FirstName>TestFirst</FirstName>
<LastName>TestLast</LastName>
<City>Fountain</City>
<State>CA</State>
<Zip>90032</Zip>
</Basic>
<Status>
<Perished>No</Perished>
<Age>50</Age>
<Sex>Female</Sex>
<Relation>Mother</Relation>
<Dependants>Yes</Dependants>
</Status>
<Dependent ID=1>
<FirstName>TestChildFirst</FirstName>
<LastName>TestChildLast</LastName>
<Sex>Male</Sex>
<Age>14</Age>
</Dependent>
</Person>

Now,all of the above Person XML (all nodes and everything) is stored in a Database (XMLStore) with a key a separate column of the ID of the Person as the key.

The application will pull the information from the database based off the ID the return will be the XML which is then put into a DOM object and processed throughout the application.

It will also store the "Basic" information a a "Basic" table and the "Status" information in a Status table, and same with the dependent but it will store in not an an XML but each individual field where the key is for the Person ID.

At the end of processing in the application it will save any changed values for the Basic, Status, etc into the respective tables and then also the combined XML back into the database (XMLStore).

Now, the question is how can we get rid of the XMLStore but still be able to pull all the data from the database tables and create an XML to put into an DOM object? I was thinking like SQLXML4 but is there something else or another way?

Any information would be greatly appreciated.

Thanks



 
What version of SQL Server are you using? SQL 2000, 2005, 2008 or 2008R2?

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Right now, we're using SQL Server 2000 but we're pursuing upgrading to SQL 2008. But that's not there yet, so I would say it should be looked at under those 2.
 
With SQL 2000, you can generate XML right from the database in a query. I assume that a person can probably have multiple dependents, right? This makes generating the XML a bit more difficult, but it is possible.

With SQL2005 (and newer), generating XML the way you want it is a lot easier.

There's a nice tutorial on using "For XML Explicit" here:



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Yes, there would be more than one dependent in that case.

I will look at that link as well and get back...

Any other possible links would be great as well to review/research.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top