Database Reference
In-Depth Information
Figure 14-13. Nested Sets
Listing 14-16. Nested Sets DDL
create table dbo.OrgChart
(
ID int not null,
Name nvarchar(64) not null,
Title nvarchar(64) not null,
LeftBower float not null,
RightBower float not null,
constraint PK_OrgChart
primary key clustered(ID),
);
Materialized Path . This persists the hierarchical path in every node by concatenating
information about the parents up to the root of the hierarchy. As a result, you can
find all child nodes by performing a prefix lookup based on the parent path. Some
implementations store actual key values of the nodes in the path, while others store the
relative position of the node in the hierarchy. Figure 14-14 shows an example of the latter.
Listing 14-17 shows one possible implementation of such a method.
 
Search WWH ::




Custom Search