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

many to many relationship to XML Schema

  • To: <xml-dev@l...>
  • Subject: many to many relationship to XML Schema
  • From: "Empowering You" <pam@e...>
  • Date: Sun, 10 Nov 2002 16:55:30 -0500
  • Importance: Normal
  • Organization: Empowering You!
  • Reply-to: <pam@e...>

many to many relationship
Title: Message
I'd appreciate help on mapping a SQL relational database with a many-to-many relationship to a XML schema in the .NET environment. 
 
Scenario:
In a Microsoft SQL 2000 database:
The Page table holds web pages. 
The Product table holds products.
 
Because many products can be contained on one web page, and a specific product can occur on more than one web page, I have a
PageProduct table for the 'many' side of the relationship of both Page and also Product.
 
Because I want to output web pages that contains a list of products and it looks like an XML schema, I decided to use XML instead of taking the data directly from the relational database. 
 
1.  I can create the XML schema to look like the relational tables and include the PageProduct table as a schema element.  And maybe I should do this if I want to allow the user to update the products from the website page. 
 
or 2.  I can create the XML schema to only use Page and Products and I don't think it needs the PageProduct element at all.  This way seems much more intuitive.  But it isn't the way the relational tables work. I am unclear about what would happen if I don't include a PageProduct element and then want to try doing semi-automatic updates (maybe using one of the grid controls) in ASP.NET and ADO.NET, probably using the built-in features in datasets, to the Page and Product tables.  I would think it might not work without a PageProduct table because Page and Product are not directly related.
 
Or maybe I should do it both ways:  Not use a dataset and not include PageProduct in the schema if I'm not going to update; and then include the PageProduct table in the schema and use a dataset if I am going to do updates.  In this case I'd have two schemas, one for read-only and one for updates.
 
Basically, all I've found on mapping relationships to schemas is what Microsoft has on their web site.  It has the pieces and parts, and even details about SQLXML, Managed XML, and extensions.  But I'm not getting the overall picture of how to set up my schema when I want to do updating back to the database.  When I don't want to update I don't think it matters since I can always do a one to one mapping of an element to a SQL database field.  It's when I want to consider updating the database that I don't understand the best way to write the schema.
 
Any suggestions on the best way to do this specific scenario?  And also I need to understand more about mapping relational databases to XML schemas in .NET, especially when updating back to the database.  Also it would help to see a list of rules about when an element or attribute becomes a field in a new table, or the name of table, or a field in an existing table if I'm using default mapping.  I've seen the rules spattered throughout the documentation, but am not sure of exactly what they are.
 
Thanks,
Pam
 
Pam Ammond

Empowering You!

website: http://www.empoweringyou.com/

Please buy the "Wow! Look At Windows XP" book I wrote at http://www.windowsxpbook.com/

 

 

 

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.