Relative cardinality is the relationship of an element to another element in the XML hierarchy. An element can have a one-to-one, one-to-many, or many-to-many relationship to another element in the hierarchy.
An element has a one-to-one relationship with another element if every occurrence of one element can have one occurrence of the other element. For example, an employee element can have one social security number element. Employee and social security number have a one-to-one relationship.
An element has a one-to-many relationship with another element if every occurrence of one element can have multiple occurrences of another element. For example, an employee element can have multiple email addresses. Employee and email address have a one-to-many relationship.
An element has a many-to-many relationship with another element if an XML file can have multiple occurrences of both elements. For example, an employee might have multiple email addresses and multiple street addresses. Email address and street address have a many-to-many relationship.
The following figure shows the relative cardinality between elements in a sample XML file:
One-to-many relationship. For every occurrence of SNAME, there can be many occurrences of ADDRESS and, therefore, many occurrences of CITY.
Many-to-many relationship. For every occurrence of STATE, there can be multiple occurrences of YTDSALES. For every occurrence of YTDSALES, there can be many occurrences of STATE.
One-to-one relationship. For every occurrence of PNAME, there is one occurrence of PPRICE.