arXiv:2609.03538cs.DBSep 2026

Manuscript Offprint

arXiv:2609.03538

Tree Databases

Nicolas Spyratos

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Nicolas Spyratos

Abstract We propose a novel database model whose basic structure is a labeled, directed tree with node identities. Intuitively, the root of the tree is seen as an object (or entity), the non-root nodes as attributes of the object and the semantics of each attribute is represented by the unique path leading from the root to the attribute. We define a tree database to be a set of such trees. The trees of the database can be combined to produce new trees using a set of operations on trees that we define in the paper. The query language of our model offers two types of queries, traversal queries and analytic queries. A query (whether traversal or analytic) is always defined over a tree, which is either a tree in the database or a tree derived from other trees using tree operations. The operations on trees and the query language are both defined using a simple functional algebra whose operations are: restriction of a function, composition of functions, pairing of functions and Cartesian product of sets.

A distinctive feature of our model is that traversal queries and analytic queries are both defined within the same formal framework; and in fact, traversal queries serve as the building blocks for analytic queries. This is in sharp contrast to the relational model, where analytic queries are defined outside the relational algebra, in the form of SQL Group-by queries. Therefore our model supports data access and data analysis within the same formal framework.

We demonstrate the expressive power of our model by showing: (a) how our model can support inheritance in a seamless manner, (b) how one can define consistent relational databases on top of a tree database - with the tree database playing the role of an underlying semantic layer and (c) how a tree database can be used as a user-friendly interface for accessing and analyzing relational data.

Keywords Data model. Graph database model. Conceptual modeling. Query language. Data Analysis. Interface

LISN Laboratory - University Paris-Saclay, CNRS, INRIA, France Affiliated Scientist, FORTH Institute of Computer Science, Greece nicolas.spyratos@lri.fr

Acknowledgment: Work conducted while the author was visiting with the HCI Group at FORTH Institute of Computer Science, Greece (https://www.ics.forth.gr/)

1 Introduction

The basic idea underlying this work is that the data sets of an application and their relationships can be modeled as a labeled, directed tree with node identities. Each node of the tree stores a data set of the application and each edge stores a total function (i.e. a set of key-value pairs) from its source node to its target node. A set of such trees is what we call a tree database (or simply database, hereafter). Intuitively, the root of a tree in the database is seen as an object (or entity), the non-root nodes as attributes of the object and the semantics of each attribute is represented by the unique path leading from the root to the attribute.

An example of a tree database is shown in Figure 1. It contains four trees, T1,T2,T3,T4\mathcal{T}_1, \mathcal{T}_2, \mathcal{T}_3, \mathcal{T}_4, storing data concerning a distribution center (e.g. Walmart) which delivers products of various types in a number of branches. A delivery invoice contains the following data: the date of delivery, the branch in which the delivery took place, the type of product delivered (e.g. CocaLight) and the quantity (i.e. the number of units delivered of that type of product). There is a separate invoice for each type of product delivered, and the data on all invoices during the year are stored in T1\mathcal{T}_1 for yearly analyses and planning purposes. At any given moment during the year, the root InvInv of T1\mathcal{T}_1 stores the set of all invoice identifiers so far (e.g. a set of integers) and the non-root nodes store the data appearing on the invoices (e.g. the node 'Date' stores the delivery dates appearing on the invoices, the node 'Branch' stores all identifiers of branches to which deliveries were made, and so on). As for the edges of T1\mathcal{T}_1, each edge e:Inv→Xe: Inv \to X stores a function (i.e. a set of key-value pairs) associating each invoice number ii of InvInv with the corresponding data e(i)e(i) stored in node XX (e.g. the edge b:Inv→Branchb: Inv \to Branch associates each invoice number ii of InvInv with the branch identifier b(i)b(i) of BranchBranch appearing on invoice ii). By the way, to simplify our discussions, we shall use the terms 'edge' and 'function' interchangeably whenever no ambiguity is possible; and similarly we shall use interchangeably the terms 'node' and 'set'.

The remaining trees of our example database store auxiliary information needed for the analysis of the data stored in tree T1\mathcal{T}_1. Thus T2\mathcal{T}_2 stores the region in which each branch is located; T3\mathcal{T}_3 stores the supplier and the category of each product type; and T4\mathcal{T}_4 stores the unit price of a product as a function of its supplier and its category. Now, the trees of a database can be combined to produce new trees using a set of operations on trees that we shall define in the paper. Such operations on trees create new trees and therefore new ways of accessing information. An example of tree operation is 'tree composition' defined as follows: a tree T\mathcal{T} is composable with tree T′\mathcal{T}' if the root of T′\mathcal{T}' is a node of T\mathcal{T}, and additionally, this is the only node shared by the two trees (this unique shared node is then called the 'link' of the composition). If T\mathcal{T} is composable with tree T′\mathcal{T}' then their composition is denoted by T′∘T\mathcal{T}' \circ \mathcal{T} and the result is a new 'larger' tree. Figure 1 shows three examples of tree composition. First, T1\mathcal{T}_1 is composable with T2\mathcal{T}_2 (with the node BranchBranch as the link) and the result of their composition is the tree T5=T2∘T1\mathcal{T}_5 = \mathcal{T}_2 \circ \mathcal{T}_1 as shown in the figure; similarly, T1\mathcal{T}_1 is composable with T3\mathcal{T}_3 (with the node ProdProd as the link) and the result of their composition is the tree T6=T3∘T1\mathcal{T}_6 = \mathcal{T}_3 \circ \mathcal{T}_1; and finally, T6\mathcal{T}_6 is composable with T2\mathcal{T}_2 (with the node BranchBranch as the link) and the result of their composition is the tree T7=T2∘T6\mathcal{T}_7 = \mathcal{T}_2 \circ \mathcal{T}_6. By the way, we shall use the tree T7T_7 in most of our examples throughout the paper.

Figure

Fig. 1 A tree database and examples of tree composition

Suppose now that T\mathcal{T} is a tree, which is either in the database or derived from those in the database as explained above. Then the question is: how can one extract information from T\mathcal{T}? To this end, we need operations to combine nodes and edges in T\mathcal{T} so as to formulate queries. In our model we use one operation to combine sets, namely Cartesian product; and three operations on functions, namely restriction of a function to a subset of its domain of definition, composition of two functions, and pairing of two functions with the same source. We shall refer to these operations, collectively, as the functional algebra. Note that these are well known, elementary operations except possibly for pairing which is defined as follows: given two functions f:X→Yf: X \to Y and g:X→Zg: X \to Z with XX as their common source, we call pairing of ff and gg, denoted as f∧gf \wedge g, the function defined by:

f∧g:X→Y×Z such that (f∧g)(x)=(f(x),g(x)) for all x in Xf \wedge g : X \to Y \times Z \text{ such that } (f \wedge g)(x) = (f(x), g(x)) \text{ for all } x \text{ in } X

Note that pairing works as a tuple constructor. Indeed, if we view the elements of XX as identifiers (or 'keys'), then for each xx in XX the pairing constructs a tuple (x,f(x),g(x))(x, f(x), g(x)) of xx and the images of xx under the input functions. Clearly, the definition of pairing can be extended to more than two functions with the same source in a straightforward manner. Also note that function composition and function pairing express the only two ways edges combine in a graph (i.e. either forming a path or a fork).

Our model offers a query language comprising two types of queries, traversal queries and analytic queries. They are both defined using the functional algebra defined above. Given a tree T\mathcal{T}, a path expression over T\mathcal{T} is just the composition of the edges of a path of T\mathcal{T}; and a traversal query over T\mathcal{T} is either a single path expression or the pairing of two or more path expressions having the same source. Referring to Figure 1, here are two examples of path expressions over the tree T7T_7:

PE1:r∘bPE_1 : r \circ b, returning, for each i∈Invi \in \text{Inv}, the region associated with ii

PE2:s∘pPE_2 : s \circ p, returning, for each i∈Invi \in Inv, the product associated with ii

By pairing these two path expressions we obtain the following traversal query: Q=((r∘b))∧(s∘p)Q = ((r \circ b)) \wedge (s \circ p), returning for each i∈Invi \in Inv, the region-product pair associated with ii

Note that the answer of a path expression is a function from the source of the path to its target; and the answer of a traversal query is a function from the common source of its path expressions to the Cartesian product of the targets of its path expressions. In order to simplify our discussions, we will often confuse a traversal query with its answer, which is a function. For example we will say 'the function r∘b′r \circ b' to mean the answer to query r∘br \circ b.

Similarly, an analytic expression over a tree T\mathcal{T} is a triple of the form ⟨g,m,op⟩\langle g, m, op \rangle, where gg and mm are traversal queries over T\mathcal{T} with the same source (serving for grouping and measuring, respectively) and opop is an aggregate operation applicable on the target of mm; and an analytic query is either a single analytic expression or the pairing of two or more analytic expressions having the same source. Referring to Figure 1, here are two examples of analytic expressions over the tree T7T_7:

AE1:(b,q,sum)AE_1 : (b, q, sum) is an analytic expression returning the total quantity delivered by Branch

AE2:(b,q,avg)AE_2 : (b, q, avg) is an analytic expression returning the average quantity delivered by Branch

To compute the answer to AE1AE_1 we proceed as follows: first, given a branch xx, we group together all invoices that refer xx (actually, this is the set S=b−1(x)S = b^{-1}(x)); then we apply the function qq to every invoice ii in SS to find the quantity corresponding to ii; and finally, we sum up the quantities for all i∈Si \in S to find the total quantity for branch xx (and similarly for computing the answer of AE2AE_2). Note that the answer to an analytic expression is a function from the target of the grouping query bb to the target of the aggregate operation (and as this target is a node not appearing in the tree, the user is asked to name it (e.g. BranchTot in our example). The answer to AE2AE_2 is computed in a similar manner returning the average quantity delivered by branch, say BranchAvg. Next, by pairing these two analytic expressions we obtain the following analytic query:

Q′=(b,q,sum)∧(b,q,avg)Q' = (b, q, sum) \wedge (b, q, avg),

returning, for each i∈Invi \in Inv, the pair (BranchTot,BranchAvg)(BranchTot, BranchAvg) associated with ii

Note that the answer of a analytic expression (g,m,op)(g, m, op) is a function from the target of gg to the target of opop; and the answer of an analytic query is a function from the common source of its analytic expressions to the Cartesian product of the targets of its analytic expressions.

Roughly speaking, traversal queries parallel relational algebra queries, whereas analytic queries parallel SQL Group-by queries. A distinctive feature of our model is that traversal queries and analytic queries are both defined within the same formal framework; and in fact, traversal queries serve as the building blocks for analytic queries. This is in sharp contrast to the relational model, where analytic queries are defined outside the relational algebra, in the form of SQL Group-by queries. Therefore our model supports data access and data analysis within the same formal framework.

We demonstrate the expressive power of our model by showing: (a) how our model can support inheritance in a seamless manner, (b) how one can define consistent relational databases on top of a tree database - with the tree database playing the role of an underlying semantic layer and (c) how a tree database can be used as a user-friendly interface for accessing and analyzing relational data.

A fundamental aspect of our model is that data is stored in the form of trees that is data is not stored sequentially (i.e., not in a linear order). Instead, data is organized across multiple levels, forming a hierarchical structure. Graph data models in general have gained considerable attention in the last few decades since they use nodes, relationships between nodes and key-value properties instead of tables to represent information [2][6]. Therefore they are typically substantially faster for associative data sets. While other database models compute relationships expensively at query time, a graph database stores connections as first-class citizens, readily available for any 'join-like' navigation operation. Any purposeful query over a graph database can be easily answered, as data is easily accessed using traversals. A traversal is how you query a graph, navigating from starting nodes to related nodes according to an algorithm [1]. Graph-based models present a high degree of flexibility and are able to capture complex non-linear relationships. In a graph data model relationships are of equal importance to the data itself. This means you are not required to infer connections between entities using special properties such as foreign keys or out-of-band processing like map-reduce.

In contrast, relational databases store highly-structured data in tables with predetermined columns and rows of specific types of information. Due to the rigidity of their organization, relational databases require developers and applications to strictly structure the data used in their applications. In relational databases, references to other rows and tables are indicated by referring to primary key attributes via foreign key columns; joins are computed at query time by matching primary and foreign keys of all rows in the connected tables. These operations are compute-heavy and memory-intensive, and have an exponential cost; and when many-to-many relationships occur in the model, you must introduce a join table (or associative entity table) that holds foreign keys of the participating tables, further increasing join operation costs.

Graph databases have become a cornerstone of modern data management, enabling complex queries, pattern discovery, and knowledge inference in highly connected datasets [6]. There is a substantial body of literature around the use of graphs in computer science, including several tools to support graph management by means of digital technology, as well as data models and query languages based on graphs. The reader is referred to [2][3][7][8][23] for a comprehensive analysis of graph-based approaches to data and knowledge management, emphasizing the relation between graph databases and knowledge graphs, and including an extensive bibliography. A rather detailed discussion on the power and limitations of graph databases can be found in [13]. Moreover, several graph database systems have appeared in recent years such as Neo4j Graph Database, ArangoDB, Amazon Neptune, Dgraph and a host of others¹. A comparison of the main graph database models can be found in [5].

¹ https://www.g2.com/categories/graph-databases (retrieved on March 4, 2026)