Introduction to Database Design
48
Uniqueness, Keys, References
<element name="w:widget" xmlns:w="http://www.widget.org">
<complexType>
...
</complexType>
<key name="my_widget_key">
<selector xpath="w:components/w:part"/>
<field xpath="@manufacturer"/>
<field xpath="w:info/@productid"/>
</key>
<keyref name="annotation_references"
refer="w:my_widget_key">
<selector xpath=".//w:annotation"/>
<field xpath="@manu"/>
<field xpath="@prod"/>
</keyref>
</element>
unique: as key, but fields may be absent
in every widget, each part must have
unique (manufacturer, productid)
in every widget, for each annotation,
(manu, prod) must match a my_widget_key
only a “downward”
subset of XPath is used