UPDATE OPERATIONS FOR HIERARCHICAL STRUCTURES IN THE NESTED SETS MODEL

Authors

Keywords:

Hierarchical data, relational database, Nested Sets, subtree relocation, SQL

Abstract

The article examines an approach to storing hierarchical data in relational databases using the Nested Sets model. The fundamental principles of this model, its advantages and disadvantages compared to other methods, particularly the Adjacency List, are analyzed. Special attention is given to subtree movement and node deletion algorithms within the hierarchical structure, including the update of lft and rgt values. Examples of SQL queries for subtree movement and node deletion are provided. The Nested Sets model is advisable for use in relational databases when efficient querying of hierarchical data is required. However, inserting, moving, and deleting nodes require updating multiple records due to changes in lft and rgt values. Even if restructuring is performed infrequently, it can be very slow for large trees. Understanding the restructuring process helps determine whether Nested Sets should be used in a specific case or if alternative approaches to storing hierarchical data in relational databases should be considered.

References

Joe Celko's Trees and Hierarchies in SQL for Smarties. (2004). Elsevier. https://doi.org/10.1016/b978-1-55860-920-4.x5000-4

Celko J. Trees and Hierarchies in SQL for Smarties. – Morgan-Kaufmann, 2012. – 296 p.

Bulatetska L.V., Bulatetskyi V. V. Methods Of Modeling Hierarchical Structures In Relational Databases. Applied Problems of Computer Science, Security and Mathematics. 2024. № 1. P. 47–65. URL: https://apcssm.vnu.edu.ua/index.php/Journalone/article/view/126

Preservation Of Hierarchy Structures In Relative Databases / V. O. Markitan, M. A. Vozniak, L. V. Bulatetska, V. V. Bulatetskyi. Cybersecurity: Education, Science, Technique. 2022. Vol. 4, №16. P. 85–97. DOI: https://doi.org/10.28925/2663-4023.2022.16.8597

Markitan V. O., Vozniak M. A., Bulatetska L. V. Derevovydni struktury v SQL. Matematyka. Informatsiini tekhnolohii. Osvita. : materialy ХІ mizhnar. naukovo-prakt. konf. Lutsk, 3–5 chervn. 2022 r. Lutsk, 2022. S. 109–111.

Derevo katalohiv NESTED SETS (vkladeni mnozhyny) i upravlinnia nym | open2web. open2web | open2web. URL: https://open2web.com.ua/blog/derevo-katalogov-nested-sets -vlozhennye-mnozhestva-i-upravlenie-im.html

Published

2025-04-16

How to Cite

[1]
Laitaruk, I., Kurotych, A. and Bulatetska, L. 2025. UPDATE OPERATIONS FOR HIERARCHICAL STRUCTURES IN THE NESTED SETS MODEL. Applied Problems of Computer Science, Security and Mathematics. 4 (Apr. 2025), 40–49.