language-icon Old Web
English
Sign In

Nested set model

The nested set model is a particular technique for representing nested sets (also known as trees or hierarchies) in relational databases.Nested Sets is a clever solution – maybe too clever. It also fails to support referential integrity. It’s best used when you need to query a tree more frequently than you need to modify the tree. The nested set model is a particular technique for representing nested sets (also known as trees or hierarchies) in relational databases. The standard relational algebra and relational calculus, and the SQL operations based on them, are unable to express directly all desirable operations on hierarchies. The nested set model is a solution to that problem. An alternative solution is the expression of the hierarchy as a parent-child relation. Celko called this the adjacency list model. If the hierarchy can have arbitrary depth, the adjacency list model does not allow the expression of operations such as comparing the contents of hierarchies of two elements, or determining whether an element is somewhere in the subhierarchy of another element. When the hierarchy is of fixed or bounded depth, the operations are possible, but expensive, due to the necessity of performing one relational join per level. This is often known as the bill of materials problem. Hierarchies may be expressed easily by switching to a graph database. Alternatively, several resolutions exist for the relational model and are available as a workaround in some relational database management systems:

[ "Relational database", "Database model", "Relational model", "Database", "Programming language", "Alpha (programming language)", "Relational Model/Tasmania", "Codd's 12 rules", "Tuple relational calculus", "Nested SQL" ]
Parent Topic
Child Topic
    No Parent Topic