2.2.1 Logical Definition

A hierarchy tree is an abstract ordered tree. This means that for each node n, there is a "less-than" (<) order relation on all children of n. This tree has infinite depth. For each node n in the tree, the children of n are in 1-to-1 correspondence with finite nonempty sequences of integers, which are called node labels. Given any two children m1 and m2 of n, m1 < m2 if and only if the label of m1 comes before the label of m2 in the lexicographical order in integer sequences. Thus, for a node n, each child of n has siblings before and after it, and any two children of n have siblings between them.

The logical representation of a node label for a child of a given node is a sequence of integers separated by dots (for example, 1, 1.3, or -7.0.-8.9). The hierarchyid<5> data type logically encodes information about a single node in the hierarchy tree by encoding the path from the root of the tree to the node. Such a path is logically represented as a sequence of node labels of all children visited after the root. Each label is followed by a slash, and a slash begins the representation. Thus, a path that visits only the root is represented by a single slash. For example, /, /1/, /0.3.-7/, /1/3/, and /0.1/0.2/ are valid hierarchyid paths of lengths 1, 2, 2, 3, and 3, respectively.

The hierarchyid data type represents a node in the hierarchy tree based on a binary encoding of the following logical representation. This encoding is described in section 3.2.