6.6. Modeling Relationships

Much of the power and complexity of mapping data to XML comes from mapping the relationships between pieces of data. In the relational world, this equates to the modeling of primary-foreign key relationships. Let's look at each in turn.

6.6.1. Primary Keys

A primary key provides a unique value by which a single row of a particular table may be accessed. XML has a similar concept of an ID attribute that provides unique access to an element. Many implementations of DOM provide indexed access to such elements, so leveraging the similarities is often desirable. However, a subtlety arises: XML IDs must be unique across the whole document, but a primary key is unique only within that column.

To provide the necessary global ...

Get Enterprise Application Integration With XML and Java™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.