2005-09-01

DTD中的属性类型ID和IDREF与SQL中的primary key和forein key

Aus: An Introduction To Database, Kapitel 27

Attributes of type ID behave a little bit like primary keys, and attributes of type IDREF behave a little bit like foreign keys. However, the analogies are not very strong:

■ There is no way to specify a “key” value that is anything but a simple character string.
■ There is no way to specify a “key” value that involves more than one attribute.
■ In the example, SNUM values in SupplierTuple elements are not merely unique with
respect to all such elements, they are unique with respect to all attributes of type ID in
the entire document, and similarly for PNUM values in PartTuple elements. (In particular,
therefore, no SNUM value is equal to any PNUM value.)
■ Moreover, SNUM values in ShipmentTuple elements are not guaranteed to be equal
to the SNUM value in some SupplierTuple element—they are merely guaranteed to
be equal to the value of some attribute of type ID, somewhere in the document.
■ Most important, referential constraint checking—such as it is—is performed only
within the context of a single document. There is no cross-document checking.

没有评论:

发表评论