This article describes a method for manipulating hierarchies in DB2 Universal Database through a user-defined node type. This method can greatly enhance performance and simplify developments for database applications that can benefit from a hierarchical data structure. Sample code included.
- The problem with hierarchies
- Nodes and hierarchies
- Node vs. relational implementation
- Implementing the node type
- Indexing and SQL statements
- Using the node data type
- Solving hierarchical problems
- Appendix: Function descriptions
The world is full of hierarchies. We see them everywhere. In data management, we talk about management hierarchies, bills-of-material, product classification, object hierarchies, XML, LDAP, and so on. It is a natural way to divide problems into smaller parts so they are more manageable.
Relational databases are not inherently very good at manipulating hierarchies. With the introduction of object-relational technology, it is now possible to extend the type of data and the operations available in the relational model to accommodate business problems that require types and operations that are not included in a relational database system. The user-defined type is one of those object-relational features that have been implemented in DB2 Universal Database for Windows, UNIX and Linux.
The node type is an implementation of a user-defined type. Together with its related opera-tions, the node type is useful in handling hierarchical structures. In this article, I describe the capabilities of this new type that is provided as sample code with this article.
| Description | Name | Size | Download method |
|---|---|---|---|
| Article in PDF format | 0302roy.pdf | 65KB | HTTP |
| Code sample | DB2Node.zip | 21KB | HTTP |
Information about download methods Get Adobe® Reader®
Learn
-
developerWorks Information Management zone: Learn more about DB2. Find technical documentation, how-to articles, education, downloads, product information, and more.
-
Stay current with developerWorks
technical events and webcasts.
Get products and technologies
-
Build your next development project with
IBM
trial software, available for download directly from developerWorks.
Discuss
-
Participate in developerWorks blogs and get involved in the developerWorks community.

Jacques Roy is a member of IBM's worldwide sales support organization. He has over 20 years of industry experience and over five years of experience with database extensibility. He is the author Informix Dynamic Server.2000: Server-Side Programming in C and co-author of Open-Source Components for the Informix Dynamic Server 9.x.
