EFFICIENT MECHANISM FOR MANAGING HIERARCHICAL RELATIONSHIPS IN A RELATIONAL DATABASE SYSTEM

20190073399 ยท 2019-03-07

    Inventors

    Cpc classification

    International classification

    Abstract

    A method and apparatus for managing hierarchical relationships in a relational database system is provided. An orderkey data type, which is native within a relational database system, is disclosed. The orderkey type is designed to contain values that represent the position of an entity relative to the positions of other entities within a hierarchy. Such values represent hierarchical relationships between those entities. Values that are of the orderkey type have properties that allow hierarchy-oriented functions to be performed in an especially efficient manner. Database functions, which operate on and/or produce values that are of the orderkey type, are also disclosed. Such functions can be placed within SQL statements that a database server executes, for example. In response to executing SQL statements that contain such functions, the database server performs hierarchy-oriented operations in a highly efficient manner.

    Claims

    1. A computer-implemented method comprising: receiving, as input to a previously defined function within a database, a value, of a particular data type, that indicates a respective position within a hierarchy; wherein the value indicates a complete hierarchical lineage of the respective position within the hierarchy; and the function returning a result value based on both: a predefined hierarchical relationship with respect to the respective position within the hierarchy.

    2. The method of claim 1, wherein the predefined hierarchical relationship is selected from the group consisting of: first child, left sibling, right sibling, and parent.

    3. The method of claim 1, wherein the result value is of the particular data type.

    4. The method of claim 1, wherein the respective position is a first respective position; and wherein the result value indicates a complete hierarchical lineage of a second respective position within the hierarchy, the second respective position having the predefined hierarchical relationship with respect to the first respective position.

    5. The method of claim 1, wherein the value is a first value; wherein the respective position is a first respective position, and wherein the method further comprises: receiving, as input to the previously defined function within the database, a second value, of the particular data type, that indicates a second respective position within the hierarchy; wherein the second value indicates a complete hierarchical lineage of the second respective position within the hierarchy; and wherein the function returning the result value based on the predefined hierarchical relationship with respect to the first respective position in the hierarchy is based on the first respective position having the predefined hierarchical relationship with respect to the second respective position.

    6. The method of claim 1, wherein the function has a name and the name of the function indicates the predefined hierarchical relationship.

    7. The method of claim 1, wherein the value is represented by a first sequence of bytes; wherein the result value is represented by a second sequence of bytes; wherein the predefined hierarchical relationship is parent; wherein the second sequence of bytes is byte-wise less than the first sequence of bytes; and wherein the second sequence of bytes is a byte-wise prefix of the first sequence of bytes.

    8. One or more non-transitory computer-readable media storing one or more programs for execution by one or more processors, the one or more programs having instructions configured for: receiving, as input to a previously defined function within a database, a value, of a particular data type, that indicates a respective position within a hierarchy; wherein the value indicates a complete hierarchical lineage of the respective position within the hierarchy; and the function returning a result value based on a predefined hierarchical relationship with respect to the respective position within the hierarchy.

    9. The one or more non-transitory computer-readable media of claim 8, wherein the predefined hierarchical relationship is selected from the group consisting of: first child, left sibling, right sibling, and parent.

    10. The one or more non-transitory computer-readable media of claim 8, wherein the result value is of the particular data type.

    11. The one or more non-transitory computer-readable media of claim 8, wherein the respective position is a first respective position; and wherein the result value indicates a complete hierarchical lineage of a second respective position within the hierarchy, the second respective position having the predefined hierarchical relationship with respect to the first respective position.

    12. The one or more non-transitory computer-readable media of claim 8, wherein the value is a first value; wherein the respective position is a first respective position, and wherein the instructions are further configured for: receiving, as input to the previously defined function within the database, a second value, of the particular data type, that indicates a second respective position within the hierarchy; wherein the second value indicates a complete hierarchical lineage of the second respective position within the hierarchy; and wherein the function returning the result value based on the predefined hierarchical relationship with respect to the first respective position in the hierarchy is based on the first respective position having the predefined hierarchical relationship with respect to the second respective position.

    13. The one or more non-transitory computer-readable media of claim 8, wherein the function has a name and the name of the function indicates the predefined hierarchical relationship.

    14. The one or more non-transitory computer-readable media of claim 8, wherein the value is represented by a first sequence of bytes; wherein the result value is represented by a second sequence of bytes; wherein the predefined hierarchical relationship is right sibling; and wherein the second sequence of bytes is a byte-wise greater than the first sequence of bytes.

    15. A computing system, comprising: one or more processors; storage media; one or more programs stored in the storage media and configured for execution by the one or more processors, the one or more programs having instructions configured for: receiving, as input to a previously defined function within a database, a value, of a particular data type, that indicates a respective position within a hierarchy; wherein the value indicates a complete hierarchical lineage of the respective position within the hierarchy; and the function returning a result value based on a predefined hierarchical relationship with respect to the respective position within the hierarchy.

    16. The computing system of claim 15, wherein the predefined hierarchical relationship is selected from the group consisting of: first child, left sibling, right sibling, and parent.

    17. The computing system of claim 15, wherein the result value is of the particular data type.

    18. The computing system of claim 15, wherein the respective position is a first respective position; and wherein the result value indicates a complete hierarchical lineage of a second respective position within the hierarchy, the second respective position having the predefined hierarchical relationship with respect to the first respective position.

    19. The computing system of claim 15, wherein the value is a first value; wherein the respective position is a first respective position, and wherein the instructions are further configured for: receiving, as input to the previously defined function within the database, a second value, of the particular data type, that indicates a second respective position within the hierarchy; wherein the second value indicates a complete hierarchical lineage of the second respective position within the hierarchy; wherein the first value is a first sequence of bytes; wherein the second value is a second sequence of bytes; wherein the result value is a third sequence of bytes; wherein the predefined hierarchical relationship is left sibling; and wherein the third sequence of bytes is byte-wise greater than the first sequence of bytes and byte-wise less than the second sequence of bytes.

    20. The computing system of claim 15, wherein the value is represented by a first sequence of bytes; wherein the result value is represented by a second sequence of bytes; wherein the predefined hierarchical relationship is first child; wherein the second sequence of bytes is byte-wise greater than the first sequence of bytes; and wherein the first sequence of bytes is a byte-wise prefix of the second sequence of bytes.

    Description

    BRIEF DESCRIPTION OF THE DRAWINGS

    [0009] The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which like reference numerals refer to similar elements and in which:

    [0010] FIG. 1 illustrates a conceptual example of a hierarchy, according to an embodiment of the invention;

    [0011] FIG. 2 illustrates a conceptual example of a relational database table that contains an orderkey-type column that stores various hierarchically-related entities' corresponding orderkey values, according to an embodiment of the invention; and

    [0012] FIG. 3 is a block diagram that illustrates a computer system upon which an embodiment of the invention may be implemented.

    DETAILED DESCRIPTION

    [0013] In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, that the present invention may be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to avoid unnecessarily obscuring the present invention.

    Overview

    [0014] According to one embodiment of the invention, a new data type, which is native within a relational database system, is introduced. This new orderkey data type is designed specifically to contain values that represent the position of an entity relative to the positions of other entities within a hierarchy. Values that are of the orderkey type represent hierarchical relationships (e.g., parent-child and sibling-sibling relationships) between entities within a hierarchy. Values that are of the orderkey type have properties that allow hierarchy-oriented functions to be performed in an especially efficient manner. Additionally, in one embodiment of the invention, several new database functions, which operate on and/or produce values that are of the orderkey type, are introduced. Such functions can be placed within SQL statements that a database server executes, for example. In response to executing SQL statements that contain such functions, the database server performs hierarchy-oriented operations in a highly efficient manner. For example, in one embodiment of the invention, a database server that executes such a function determines all descendants of a specified entity within a hierarchy by performing a range-based scan on a B-tree index on orderkey values of the entities within that hierarchy.

    Orderkey Native Data Type

    [0015] According to one embodiment of the invention, a database server is enhanced to recognize and understand an orderkey native data type. The orderkey data type is native to the database server in the same way that data types such as number, date, and string are native to the database server. Columns of a relational database table may be specified to contain values that are of the orderkey type. Beneficially, the orderkey data type is capable of capturing and representing not only the immediate parent or child of a specified entity, but also is capable of capturing and representing the entire lineage of such an entity; specifying such a lineage is not a task that other native data types were designed to do.

    [0016] In one embodiment of the invention, the orderkey data type is an opaque data typeopaque like a number or a string. A value that is of an orderkey data type encompasses and encapsulates the notion of the lineage of (i.e., the complete ancestry of) an entity that is specified in a record within a row of a relational database table. In the same manner that columns of a relational database table can be created with types such as number or string, in one embodiment of the invention, such columns can be created with the orderkey data type. A column having the orderkey data type stores values that are of type orderkey. In one embodiment of the invention, values of type orderkey specify sets of bytes.

    [0017] According to one embodiment, the hierarchical order information is represented using a Dewey-type value. Specifically, in one embodiment, the orderkey of a node is created by appending a value to the orderkey of the node's immediate parent, where the appended value indicates the position, among the children of the parent node, of that particular child node.

    [0018] For example, a particular node D might be the child of a node C, which itself might be a child of a node B that is a child of a node A. Node D might have the orderkey 1.2.4.3. Under such circumstances, the final 3 in the orderkey indicates that the node D is the third child of its parent node C. Similarly, the 4 indicates that node C is the fourth child of node B. The 2 indicates that Node B is the second child of node A. The leading 1 indicates that node A is the root node (i.e., has no parent).

    [0019] As mentioned above, the orderkey of a child may be easily created by appending, to the orderkey of the parent, a value that corresponds to the number of the child. Similarly, the orderkey of the parent is easily derived from the orderkey of the child by removing the last number in the orderkey of the child.

    [0020] According to one embodiment, the composite numbers represented by each orderkey are converted into byte-comparable values, so that a mathematical comparison between two orderkeys indicates the relative position, within a hierarchy, of the nodes to which the orderkeys correspond.

    [0021] For example, the node associated with the orderkey 1.2.7.7 precedes the node associated with the orderkey 1.3.1 in a theoretical hierarchical structure. Thus, the database server uses a conversion mechanism that converts orderkey 1.2.7.7 to a first value, and to convert orderkey 1.3.1 to a second value, where the first value is less than the second value. By comparing the second value to the first value, the database server can easily determine that the node associated with the first value precedes the node associated with the second value. Various conversion techniques may be used to achieve this result, and embodiments of the invention are not limited to any particular conversion technique.

    Orderkey-Based Database Functions

    [0022] In one embodiment of the invention, a database server is enhanced to recognize, understand, and execute database language functions that involve values that are of the orderkey type. Database users and database applications may specify these functions within SQL queries, for example. Some example functions, according to various embodiments of the invention, are described below. First, functions for obtaining new orderkey values, to be inserted into relational database table rows, are described. After these, functions for querying existing orderkey values that already exist within relational database table rows are described.

    [0023] In one embodiment of the invention, a database server is designed to recognize, understand, and execute a function called GET_NEW_OKEY. GET_NEW_OKEY does not require any input parameters. In response to evaluating GET_NEW_OKEY, a database server returns a new value that is of type orderkey. The new value corresponds to a new root. As used herein, a root is the entity that is represented at the root node of a hierarchy; such a root node has no parent, but may have or gain any number of children. Thus, in one embodiment of the invention, the evaluation of GET_NEW_OKEY causes the database server to create, conceptually, a new hierarchy and return the value (of type orderkey) that, among other qualities, corresponds to the entity that is at the root node of that hierarchy. In typical usage, after obtaining the returned value from GET_NEW_OKEY, a user or application would actually create (if they had not already done so) a row in a relational database table, and would populate an appropriate column (of type orderkey) of that row with the returned value.

    [0024] In one embodiment of the invention, a database server is designed to recognize, understand, and execute a function called GET_FIRST CHILD OKEY. In one embodiment of the invention, GET_FIRST_CHILD_OKEY accepts, as input, a parameter that specifies a value (of type orderkey) that corresponds to a parent entity. In one embodiment of the invention, GET_FIRST_CHILD_OKEY returns a value (of type orderkey) that corresponds to an entity that is the first-ordered immediate child of the parent entity. Thus, in one embodiment of the invention, the children of a particular parent are ordered relative to one another; for example, if there are three children of a particular parent, then one child is the first child, one child is the second child, and one child is the third child. In typical usage, after obtaining the returned value from GET_FIRST_CHILD_OKEY, a user or application would actually create (if they had not already done so), in a relational database table, a row that corresponded to the first child of the specified parent, and would populate an appropriate column (of type orderkey) of that row with the returned value. The returned value would indicate, among other qualities, that the entity represented by that row is the first-ordered child of the entity that is represented within the parent's row.

    [0025] In one embodiment of the invention, a database server is designed to recognize, understand, and execute a function called GET_SIBLING_OKEY. In one embodiment of the invention, GET_SIBLING_OKEY accepts, as input, a first parameter that specifies a value (of type orderkey) that corresponds to a higher-ordered sibling entity. In one embodiment of the invention, GET_SIBLING_OKEY additionally accepts, as input, an optional second parameter that specifies a value (of type orderkey) that corresponds to a lower-ordered sibling entity. In one embodiment of the invention, GET_SIBLING_OKEY returns a value (of type orderkey) that corresponds to an entity that is an immediately lower-ordered sibling of the higher-ordered sibling (as indicated by the first parameter). In one embodiment of the invention, if the second, optional parameter of GET_SIBLING_OKEY has been specified, then the returned value corresponds additionally to an immediately higher-ordered sibling of the lower-ordered sibling (as indicated by the second parameter).

    [0026] For example, if the first input parameter of GET_SIBLING_OKEY specifies the currently first-ordered child of a particular entity, and if the second input parameter of GET_SIBLING_OKEY specifies the currently second-ordered child of the particular entity, then GET_SIBLING_OKEY returns a value that corresponds to a sibling (of the currently first- and second-ordered children) whose order is in between the first-ordered child and the second-ordered childunder such circumstances, the current second-ordered child essentially becomes the new third-ordered child (although, in one embodiment of the invention, the orderkey values for the already existing children do not change), and the returned value corresponds to a new second-ordered child. The parent of the new sibling is the same as the parent for the siblings whose orderkey values were specified as input parameters to GET_SIBLING_OKEY. In typical usage, after obtaining the returned value from GET_SIBLING_OKEY, a user or application would actually create (if they had not already done so), in a relational database table, a row that corresponded to the new sibling, and would populate an appropriate column (of type orderkey) of that row with the returned value.

    [0027] The foregoing functions just described are for obtaining new orderkey values that are to be inserted into relational database table rows. Below, functions for querying existing orderkey values that already exist within relational database table rows are described.

    [0028] In one embodiment of the invention, a database server is designed to recognize, understand, and execute a function called GET_PARENT_OKEY. In one embodiment of the invention, GET_PARENT_OKEY accepts, as input, a parameter that specifies a value (of type orderkey) that corresponds to a particular entity. In one embodiment of the invention, GET_PARENT_OKEY returns a value (of type orderkey) that corresponds to an existing parent of the entity that corresponds to the input parameter.

    [0029] In one embodiment of the invention, a database server is designed to recognize, understand, and execute a function called GET_OKEY_LEVEL. In one embodiment of the invention, GET_OKEY_LEVEL accepts, as input, a parameter that specifies a value (of type orderkey) that corresponds to a particular entity. In one embodiment of the invention, GET_OKEY_LEVEL returns a value (e.g., of type number) that indicates the level of the hierarchy at which the particular entity exists. This value essentially expresses how many entities hierarchically intervene between (a) the entity at the root node of the hierarchy and (b) the particular entity. For example, the entity at the root node of the hierarchy might exist at level one. The immediate children of that entity might exist at level two. The immediate children of those entities might exist at level three, and so on.

    [0030] In one embodiment of the invention, a database server is designed to recognize, understand, and execute a function called IS_PARENT_OF. In one embodiment of the invention, IS_PARENT_OF accepts, as input, two parameters. Each such parameter specifies a value (of type orderkey) that corresponds to a separate entity. In one embodiment of the invention, IS_PARENT_OF returns a value (e.g., of type Boolean) that indicates either true (or 1) or false (or 0). In one embodiment of the invention, if (a) the entity that corresponds to the first parameter is the immediate parent of (b) the entity that corresponds to the second parameter, then IS_PARENT_OF returns true. Otherwise, IS_PARENT_OF returns false.

    [0031] In one embodiment of the invention, a database server is designed to recognize, understand, and execute a function called IS_ANCESTOR_OF. In one embodiment of the invention, IS_ANCESTOR_OF accepts, as input, two parameters. Each such parameter specifies a value (of type orderkey) that corresponds to a separate entity. In one embodiment of the invention, IS_ANCESTOR_OF returns a value (e.g., of type Boolean) that indicates either true (or 1) or false (or 0). In one embodiment of the invention, if (a) the entity that corresponds to the first parameter is a hierarchical ancestor (not necessarily immediate) of (b) the entity that corresponds to the second parameter, then IS_ANCESTOR_OF returns true. Otherwise, IS_ANCESTOR_OF returns false.

    [0032] Beneficially, by using the functions described above, database users and database applications do not need to formulate queries using the relatively complicated CONNECT-BY syntax.

    Orderkey Properties

    [0033] According to one embodiment of the invention, each value of type orderkey possesses and satisfies the set of properties that are described below. First, each orderkey value reflects a hierarchical ordering. This means that if a hierarchy is represented as a tree structure, and if each node in the tree structure is numbered according to some ordering scheme (e.g., depth-first traversal), such that each node has a unique number that at least partially signifies its position in the tree structure relative to other nodes therein, then the bytes of an orderkey value that corresponds to a particular node in the tree structure will at least represent the number that corresponds to the particular node. Additionally, in one embodiment of the invention, if a first entity is a child of a second entity, then the orderkey value for the first entity's row will be larger than the orderkey value for the second entity's row. Similarly, in one embodiment of the invention, if a first entity is a lower-ordered sibling of a second entity, then the orderkey value for the first entity's row will be larger than the orderkey value for the second entity's row.

    [0034] Second, each particular value of type orderkey, except for a value that corresponds to a root node in a hierarchy, has a prefix (in bytes) that is identical to the orderkey value of the immediate parent of the node to which that particular value corresponds. For example, if the orderkey value for a particular entity is represented as 1, then the orderkey values for the immediate children of the particular entity might be represented (conceptually) as 1.1, 1.2, 1.3, and so on. Extending the example, if the orderkey value for a particular entity is 1.3, then the orderkey values for the immediate children of the particular entity might be represented (conceptually) as 1.3.1, 1.3.2, 1.3.3, and so on. Thus, each orderkey value identifies an entire hierarchical lineage of an entity to which that orderkey value corresponds. Because each orderkey value identifies such a lineage, the orderkey-based functions described above can be performed using relatively few index scans.

    [0035] Third, a new orderkey can be constructed such that the value of that new orderkey exists between the values of two existing orderkeys. For example, if the orderkey values for two orderkeys are represented (conceptually) as 1.1 and 1.2, then, in one embodiment of the invention, a new orderkey can be created (e.g. as a sibling of the orderkey whose value is 1.1 and/or as a child of the orderkey whose value is 1, using functions discussed above) with a value that is between 1.1 and 1.2. In one embodiment of the invention, in order to make in-between orderkey creation possible, orderkey values take the form of floating-point numbers rather than integers. For example, the value of an orderkey that is created to be in between the orderkeys with values of 1.1 and 1.2 might be represented (conceptually) as 1(1) (which is not the same, conceptually, as 1.1.5.while 1.(1) is on the second hierarchical level and is an immediate child of 1, 1.1.5 is on the third hierarchical level and is an immediate child of 1.1).

    [0036] Thus, in one embodiment of the invention, each orderkey has all of the properties that are discussed above. However, orderkeys and the values thereof might be encoded in a variety of different ways while still possessing all of these properties. Various manners of encoding orderkeys and the values thereof are within the scope of various embodiments of the invention. In one embodiment of the invention, each orderkey is a sequence of bytes; for example, each byte in the sequence may correspond to a different level in a hierarchy. For a more specific example, if a particular orderkey value was 1.3.5, then the first byte of that orderkey might represent 1 (corresponding to the first hierarchical level), the second byte of that orderkey might represent 3 (corresponding to the second hierarchical level), and the third byte of that orderkey might represent 5 (corresponding to the third hierarchical level).

    Efficiencies Gained from Orderkey Properties

    [0037] Due to at least some of the orderkey properties described above, in one embodiment of the invention, many of the orderkey-based functions described above (e.g., IS_ANCESTOR_OF) can be implemented as, or re-written by a database server as, relatively simple byte-level comparisons. For example, to find all of the descendants of a particular entity, a database server can simply determine the set of entities, in the hierarchy, whose orderkey values are prefixed by the orderkey value of the particular entity; each entity in such a set is a descendant of the particular entity. Thus, a problem which previously would have been solved in N steps is reduced to a range-based problem that can be solved in fewer than N steps. A single index range scan on a B-tree can be used to find, relatively quickly, all entities whose orderkey values have a specified prefix.

    Maximum Child Orderkey

    [0038] In one embodiment of the invention, for each entity in a hierarchy, a maximum child orderkey is defined for that entity. The maximum child orderkey of a particular entity represents the theoretical maximum value that any orderkey of any child of that particular entity could have. In one embodiment of the invention, to find all immediate children of a particular entity in a hierarchy, a range-based index scan is performed to determine all entities whose orderkey values are both (a) greater than the orderkey value of the particular entity (i.e., the parent) and (b) less than or equal to the maximum child orderkey for the particular entity.

    Example Hierarchical Relational Data Structures

    [0039] FIG. 1 illustrates a conceptual example of a hierarchy 100, according to an embodiment of the invention. Each node in hierarchy 100 corresponds to a separate real-world entity (in this example, each node corresponds to a person in a corporate organization). Additionally, in hierarchy 100, each node is labeled with a value of type orderkeythe orderkey value that corresponds to that node's entity. Such values may be generated using functions such as GET_NEW_OKEY, GET_FIRST_CHILD_OKEY, and GET_SIBLING_OKEY, as discussed above. The values shown are conceptual in nature; actual orderkey values may be in a more highly compressed form that those shown.

    [0040] At the first level of hierarchy 100, node 102 has an orderkey value of 1, indicating that node 102 is the root node of hierarchy 100.

    [0041] At the second level of hierarchy 100, node 104 has an orderkey value of 1.1, indicating that node 104 is a child of node 102. Node 106 has an orderkey value of 1.2, indicating that node 106 is a child of node 102 and is a lower-ordered sibling of node 104. Node 108 has an orderkey value of 1.3, indicating that node 108 is a child of node 102 and is a lower-ordered sibling of nodes 104 and 106.

    [0042] At the third level of hierarchy 100, node 110 has an orderkey value of 1.1.1, indicating that node 110 is a child of node 104. Node 112 has an orderkey value of 1.1.2, indicating that node 112 is a child of node 104 and is a lower-ordered sibling of node 110. Node 114 has an orderkey value of 1.3.1, indicating that node 114 is a child of node 108.

    [0043] At the fourth level of hierarchy 100, node 116 has an orderkey value of 1.3.1.1, indicating that node 116 is a child of node 114. Node 118 has an orderkey value of 1.3.1.2, indicating that node 118 is a child of node 114 and is a lower-ordered sibling of node 116. Node 120 has an orderkey value of 1.3.1.3, indicating that node 120 is a child of node 114 and is a lower-ordered sibling of nodes 116 and 118. Node 122 has an orderkey value of 1.3.1.4, indicating that node 122 is a child of node 114 and is a lower-ordered sibling of nodes 116, 118, and 120.

    [0044] Such orderkey values may be inserted into an orderkey-type column of a relational database table. A B-tree index may be created on such a column to enable more efficient performance of hierarchy-based operations on the data in such a relational database table. FIG. 2 illustrates a conceptual example of a relational database table 200 that contains an orderkey-type column that stores various hierarchically-related entities' corresponding orderkey values, according to an embodiment of the invention.

    [0045] Relational database table 200 contains four columns. Among these columns, column 202 specifies values of people's names and might contain values of type string. Column 204 specifies values of people's social security numbers and might contain values of type number. Column 206 specifies values of people's birthdates and might contain values of type date. Column 208 specifies values of people's corresponding orderkeys and contains values of type orderkey (and only values of type orderkey).

    [0046] In relational table 200, the record for Dorian Giesler specifies, in column 208, an orderkey value of 1. Thus, Dorian Giesler is the entity that corresponds to node 102 in hierarchy 100.

    [0047] In relational table 200, the record for Sindy Omara specifies, in column 208, an orderkey value of 1.1. Thus, Sindy Omara is the entity that corresponds to node 104 in hierarchy 100.

    [0048] In relational table 200, the record for Gallagher Northey specifies, in column 208, an orderkey value of 1.2. Thus, Gallagher Northey is the entity that corresponds to node 106 in hierarchy 100.

    [0049] In relational table 200, the record for Beatrice Stall specifies, in column 208, an orderkey value of 1.1.1. Thus, Beatrice Stall is the entity that corresponds to node 110 in hierarchy 100.

    [0050] In relational table 200, the record for Gardenia Nicola specifies, in column 208, an orderkey value of 1.3. Thus, Gardenia Nicola is the entity that corresponds to node 108 in hierarchy 100.

    [0051] In relational table 200, the record for Tanner Ream specifies, in column 208, an orderkey value of 1.3.1. Thus, Tanner Ream is the entity that corresponds to node 114 in hierarchy 100.

    [0052] In relational table 200, the record for Lauressa Newman specifies, in column 208, an orderkey value of 1.3.1.1. Thus, Lauressa Newman is the entity that corresponds to node 116 in hierarchy 100.

    [0053] In relational table 200, the record for Opal Cavalet specifies, in column 208, an orderkey value of 1.3.1.2. Thus, Opal Cavalet is the entity that corresponds to node 118 in hierarchy 100.

    [0054] In relational table 200, the record for Randolf Quinn specifies, in column 208, an orderkey value of 1.1.2. Thus, Randolf Quinn is the entity that corresponds to node 112 in hierarchy 100.

    [0055] In relational table 200, the record for Temple Knight specifies, in column 208, an orderkey value of 1.3.1.3. Thus, Temple Knight is the entity that corresponds to node 120 in hierarchy 100.

    [0056] In relational table 200, the record for Geffrey Fulton specifies, in column 208, an orderkey value of 1.3.1.4. Thus, Geffrey Fulton is the entity that corresponds to node 122 in hierarchy 100.

    [0057] Based on the values in column 208, a database server can quickly determine, with reference to a B-tree index formed on column 208, various relationships between the entities that are represented in hierarchy 100. For example, the database server can quickly determine that the children of Dorian Giesler are Sindy Omara, Gallagher Northey, and Gardenia Nicola. For another example, the database server can quickly determine that the children of Sindy Omara are Beatrice Stall and Randolf Quinn. For another example, the database server can quickly determine that the descendants of Gardenia Nicola are Tanner Ream and his children, Lauressa Newman, Opal Cavalet, Temple Knight, and Geffrey Fulton. For another example, the database server can quickly determine that the ancestors of Temple Knight are Tanner Ream, Gardenia Nicola, and Dorian Giesler. For another example, the database server can quickly determine that the siblings of Gardenia Nicola are Sindy Omara and Gallagher Northey. The database server can determine such relationships even without the use of the CONNECT-BY SQL construct.

    [0058] In one embodiment of the invention, the hierarchical relationships between entities (such as the hierarchical relationships depicted in FIG. 1) are real-world relationships that indicate some real hierarchical relationship between real-world entities (such as people). For example, in hierarchy 100, parent-child relationships between nodes may represent real-world manager-subordinate employee relationships in a corporation.

    Hardware Overview

    [0059] FIG. 3 is a block diagram that illustrates a computer system 300 upon which an embodiment of the invention may be implemented. Computer system 300 includes a bus 302 or other communication mechanism for communicating information, and a processor 304 coupled with bus 302 for processing information. Computer system 300 also includes a main memory 306, such as a random-access memory (RAM) or other dynamic storage device, coupled to bus 302 for storing information and instructions to be executed by processor 304. Main memory 306 also may be used for storing temporary variables or other intermediate information during execution of instructions to be executed by processor 304. Computer system 300 further includes a read only memory (ROM) 308 or other static storage device coupled to bus 302 for storing static information and instructions for processor 304. A storage device 310, such as a magnetic disk or optical disk, is provided and coupled to bus 302 for storing information and instructions.

    [0060] Computer system 300 may be coupled via bus 302 to a display 312, such as a cathode ray tube (CRT), for displaying information to a computer user. An input device 314, including alphanumeric and other keys, is coupled to bus 302 for communicating information and command selections to processor 304. Another type of user input device is cursor control 316, such as a mouse, a trackball, or cursor direction keys for communicating direction information and command selections to processor 304 and for controlling cursor movement on display 312. This input device typically has two degrees of freedom in two axes, a first axis (e.g., x) and a second axis (e.g., y), that allows the device to specify positions in a plane.

    [0061] The invention is related to the use of computer system 300 for implementing the techniques described herein. According to one embodiment of the invention, those techniques are performed by computer system 300 in response to processor 304 executing one or more sequences of one or more instructions contained in main memory 306. Such instructions may be read into main memory 306 from another machine-readable medium, such as storage device 310. Execution of the sequences of instructions contained in main memory 306 causes processor 304 to perform the process steps described herein. In alternative embodiments, hard-wired circuitry may be used in place of or in combination with software instructions to implement the invention. Thus, embodiments of the invention are not limited to any specific combination of hardware circuitry and software.

    [0062] The term machine-readable medium as used herein refers to any medium that participates in providing data that causes a machine to operation in a specific fashion. In an embodiment implemented using computer system 300, various machine-readable media are involved, for example, in providing instructions to processor 304 for execution. Such a medium may take many forms, including but not limited to storage media and transmission media. Storage media includes both non-volatile media and volatile media. Non-volatile media includes, for example, optical or magnetic disks, such as storage device 310. Volatile media includes dynamic memory, such as main memory 306. Transmission media includes coaxial cables, copper wire and fiber optics, including the wires that comprise bus 302. Transmission media can also take the form of acoustic or light waves, such as those generated during radio-wave and infra-red data communications. All such media must be tangible to enable the instructions carried by the media to be detected by a physical mechanism that reads the instructions into a machine.

    [0063] Common forms of machine-readable media include, for example, a floppy disk, a flexible disk, hard disk, magnetic tape, or any other magnetic medium, a CD-ROM, any other optical medium, punchcards, papertape, any other physical medium with patterns of holes, a RAM, a PROM, and EPROM, a FLASH-EPROM, any other memory chip or cartridge, a carrier wave as described hereinafter, or any other medium from which a computer can read.

    [0064] Various forms of machine-readable media may be involved in carrying one or more sequences of one or more instructions to processor 304 for execution. For example, the instructions may initially be carried on a magnetic disk of a remote computer. The remote computer can load the instructions into its dynamic memory and send the instructions over a telephone line using a modem. A modem local to computer system 300 can receive the data on the telephone line and use an infra-red transmitter to convert the data to an infra-red signal. An infra-red detector can receive the data carried in the infra-red signal and appropriate circuitry can place the data on bus 302. Bus 302 carries the data to main memory 306, from which processor 304 retrieves and executes the instructions. The instructions received by main memory 306 may optionally be stored on storage device 310 either before or after execution by processor 304.

    [0065] Computer system 300 also includes a communication interface 318 coupled to bus 302. Communication interface 318 provides a two-way data communication coupling to a network link 320 that is connected to a local network 322. For example, communication interface 318 may be an integrated services digital network (ISDN) card or a modem to provide a data communication connection to a corresponding type of telephone line. As another example, communication interface 318 may be a local area network (LAN) card to provide a data communication connection to a compatible LAN. Wireless links may also be implemented. In any such implementation, communication interface 318 sends and receives electrical, electromagnetic or optical signals that carry digital data streams representing various types of information.

    [0066] Network link 320 typically provides data communication through one or more networks to other data devices. For example, network link 320 may provide a connection through local network 322 to a host computer 324 or to data equipment operated by an Internet Service Provider (ISP) 326. ISP 326 in turn provides data communication services through the world-wide packet data communication network now commonly referred to as the Internet 328. Local network 322 and Internet 328 both use electrical, electromagnetic or optical signals that carry digital data streams. The signals through the various networks and the signals on network link 320 and through communication interface 318, which carry the digital data to and from computer system 300, are exemplary forms of carrier waves transporting the information.

    [0067] Computer system 300 can send messages and receive data, including program code, through the network(s), network link 320 and communication interface 318. In the Internet example, a server 330 might transmit a requested code for an application program through Internet 328, ISP 326, local network 322 and communication interface 318.

    [0068] The received code may be executed by processor 304 as it is received, and/or stored in storage device 310, or other non-volatile storage for later execution. In this manner, computer system 300 may obtain application code in the form of a carrier wave.

    [0069] In the foregoing specification, embodiments of the invention have been described with reference to numerous specific details that may vary from implementation to implementation. Thus, the sole and exclusive indicator of what is the invention, and is intended by the applicants to be the invention, is the set of claims that issue from this application, in the specific form in which such claims issue, including any subsequent correction. Any definitions expressly set forth herein for terms contained in such claims shall govern the meaning of such terms as used in the claims. Hence, no limitation, element, property, feature, advantage or attribute that is not expressly recited in a claim should limit the scope of such claim in any way. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.