Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


Share this Page URL
Help

Chapter 3: Path Enumeration Models - Pg. 49

CHAPTER 3 Path Enumeration Models O ne of the properties of trees is that there is one and only path from the root to every node in the tree. The path enumeration model stores that path as a string by concatenating either the edges or the keys of the nodes in the path. Searches are done with string functions and predicates on those path strings. For other references, you should consult Advanced Transact-SQL for SQL Server 2000 (Chapter 16) by Itzak Be-Gan and Tom Moreau (ISBN 978-1893115828). They made the path enumeration model popular with this book. The code in this book is product specific, but easily generalized. There are two methods for enumerating the paths: edge enumeration and node enumeration. Node enumeration is the most commonly used of the two, and there is little difference in the basic string operations on either model. However, the edge enumeration model has some numeric properties that can be useful. It is probably a good idea to give the nodes a CHAR(n) identifier of a known size and format to make the path concatenations easier to handle. The other alternative is to use VARCHAR(n) strings, but put a separator character between each node identifier in the concatenation--a character that does not appear in the identifier itself. To keep the examples as simple as possible, let's use my five-person Personnel_OrgChart table and a CHAR(1) identifier column to build a path enumeration model.