Manuscript Offprint
arXiv:2608.26775Size Bounds for CQs Under Acyclic Constraints
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
We study size bounds for conjunctive query (CQ) results which in recent years have played a crucial role in database theory. In particular, we compare the so-called entropic bound which is known to be asymptotically tight but not known to be computable, and its computable relaxation called the polymatroid bound, which is generally not tight. We focus here on conjunctive queries under acyclic functional dependencies. These queries are known to be well-behaved in the sense that, in the case without projections, both bounds coincide. We show that this picture changes when projections are allowed: in this case, even for acyclic functional dependencies, there is in general a polynomial gap between the two bounds. We complement this negative result by showing a special case for which the polymatroid bound is tight under acyclic functional dependencies and projections that is characterized by the position of the output variables in a topological order of the query variables.
2012 ACM Subject Classification Theory of computation → Database theory; Mathematics of computing → Information theory
Keywords and phrases database theory, conjunctive queries, query size bounds, polymatroids, information theory
1 Introduction
Computing bounds on the size of query results is crucial in databases. In a database systems context, this task is called cardinality estimation and plays an important part in query optimization, see e.g. [23, 17]. There are different types of heuristics that solve it in practical systems with varying quality, and they have a great influence on query evaluation runtimes, see e.g. [17, 30]. In contrast to these heuristic estimates in systems work, in database theory the focus is on bounds for conjunctive queries that are provably correct. The idea is to compute bounds on the output size based on more or less detailed statistics of the input database. These statistics generally include the cardinalities of the input tables, but also more refined measures like degree information and functional dependencies (FDs).
Size bounds for query answers are not only intriguing by themselves, but have also played a crucial role for the development of algorithms. For example, the AGM-bound [4] has lead to a revolution in join evaluation by the development of worst-case optimal join algorithms [22, 21], i.e. algorithms whose runtime is linear in the size of the biggest possible query answer. The link between bounds and algorithms is even more direct when taking into account functional dependencies in the data or their generalization degree constraints: given statistics on the input database, the so-called polymatroid bound for the output size can be computed by solving a linear program. The solution to this program can then be translated into a sequence of operations that an algorithm, called PANDA [15], uses to evaluate the query. The computation of the bound thus guides the algorithm whose runtime turns out to be quasi-linear in the bound.
So to speed up the evaluation of queries, it is important that the runtime bounds are as small as possible while still being correct. For join queries with only cardinality constraints on the input database, it is known that the AGM-bound is tight [4], so for every query Q and every set of cardinality constraints, there is a database D satisfying the cardinality constraints such that the size of output size is up to a constant factor equal to the AGM-bound.
Size Bounds for CQs Under Acyclic Constraints
This is the underlying reason why we know that the worst-case optimal algorithms, whose runtime is proportional to the AGM-bound, are in fact worst-case optimal.
Once we add more refined constraints, the situation becomes less satisfying: when considering degree statistics and, as an important special case, functional dependencies for the computation of upper bounds, we know that the so-called entropic bound is a tight bound on the worst-case size of query results [15, 25]. While this sounds promising, this result comes with a catch: it is not known if the entropic bound is even computable! This is due to deep questions in information theory related to the lack in good understanding of the so-called entropic cone [27]. While there has been progress in that direction over the last few years, see e.g. [31, 18, 19, 9, 20, 8, 16] and the surveys in [29, 28, 7], fully understanding the situation seems to be far off. In database theory, one consequence of the resulting limited understanding of the entropic bound is that, in contrast to other bounds, so far it does not seem to lead to an algorithm for query evaluation.
One way of side-stepping this problem is considering looser bounds with better algorithmic properties. This is in fact what the already mentioned polymatroid bound does. It is an approximation of the entropic bound that can be computed with linear programming and leads to a fast evaluation algorithm for conjunctive queries, the PANDA algorithm. However, it is known that the polymatroid bound is in general not tight, i.e. the size bounds for query results that it gives can be off by a polynomial factor, even for the restricted case of join queries with functional dependencies. As a consequence, the PANDA algorithm is generally not worst-case optimal and there is in fact no known worst-case optimal algorithm in the setting. As a result, the complexity of conjunctive queries in the presence of FDs and more general degree constraints is less well understood than with only cardinality constraints. Moreover, unless there are breakthroughs in information theory, we seem to be stuck with this unsatisfying situation.
However, while in general the situation for bounds on query results under degree constraints might be difficult to understand, we can still aim to better understand it for restricted cases. For example, size bounds are better understood for the case in which all degree constraints are simple, i.e. the dependency is only on single attributes instead of sets [11, 10, 1, 25]. Another class of constraints that has attracted considerable interest is that of acyclic degree constraints. Roughly speaking, these are sets of constraints in which dependencies can only appear in a specific direction (see Section 2 for a formal definition). These constraints were introduced in [21] where it was shown that the entropic bound and the polymatroid bound coincide when restricted to acyclic degree constraints. This also results in worst-case optimal algorithms for join evaluation [21, 6]. Moreover, for this class of constraints there are efficient sampling algorithms [26, 6].
So far, the above positive results have only been shown for queries without any projections, i.e. all variables in the query are output variables. In practice however, projection is very common. After all, users might often be in a situation in which they do not care about some of the attributes in tables of a database. For example, when studying a large corpus of SPARQL queries, which is more general than what we study here, projection was found in 14.98% of all queries [5]. From a more theoretical perspective, projection is useful to materialize so-called bags in tree decomposition based approaches [12, 13, 15]. So studying the effect of projections on size bounds is certainly worthwhile. Concretely, the question we answer here is the following: do the entropic bound and the polymatroid bound for conjunctive queries with acyclic degree constraints still coincide for queries with projections?
We answer this question in the negative by constructing a query with acyclic functional dependencies for which the polymatroid bound exceeds the entropic bound by a polynomial factor. Consequently, the polymatroid bound is not tight for such queries, and existing algorithms are not worst-case optimal. This is in contrast to the setting without projections.
Our way of approaching the problem is as follows: we start with a known query with functional dependencies for which the polymatroid bound is known to be not tight from [14, 25]. The functional dependencies for this query are highly cyclic, so it does not answer our question directly. The key ingredient of our construction is then that we show of way of “untangling” the functional dependencies. To this end, for every variable involved in FDs that violate acyclicity, we break the cycles by adding a new variable that takes its role in the FDs. Doing this systematically and adding some more FDs between old and new variables, leads to a new query with a new set of FDs that are acyclic now. Our result then follows by showing that for the example query from [15, 25], this construction changes neither the entropic bound nor the polymatroid bound.
We complement these negative findings by showing that if in a query with acyclic FDs the output variables come “before” the projected variables in a well-defined sense, then the entropic bound and the polymatroid bound coincide.
Conjunctive Queries
We assume that the reader is familiar with the basics on conjunctive queries, see e.g. [3]. We write a conjunctive query Q as a comma-separated list of the form
where each is a relation symbol of the database schema and is the set of variables occurring in the atom . The terms are called atoms. The variables set is the set of output variables, denotes the set of all variables occurring in the query (or simply the variables set of ), and finally are the projected variables. As usual, is interpreted as a conjunction of atoms, with the existential quantifiers over all projected variables, i.e.,
Given a database that contains a relation for every relation symbol , we denote by the query result with respect to the usual set semantics. We will mostly be interested in the number of query answers , i.e. the number of tuples in .
We will consider functional dependencies of the form for . We require that every such functional dependency is covered by an atom, i.e., there is an atom with . We say that a database is consistent with the functional dependency if in the covering relation , for every assignment to the variables in , there is at most one extension to the variables in . The database is consistent with a set of functional dependencies if is consistent with all functional dependencies in .
We assign a directed graph to every set of functional dependencies as follows: the vertices are the variables appearing in , and for every functional dependency , the graph has the edges . We then call acyclic if is a directed acyclic graph.
▶ Example 1. Consider the query
Size Bounds for CQs Under Acyclic Constraints
with the set of FDs containing , , . The output variables are , , . The graph the contains the edges , , , , , . The FDs are acyclic which can be seen e.g. by the topological order
Polymatroids and Entropy
We only introduce some minimal notions from information theory here. The interested reader is referred to [27] for more background.
Fix a finite domain . Then a set function on is a function . We say that is monotone if for all we have . The function is called submodular if for all we have
Finally, is called a polymatroid if it is monotone and submodular and . We denote by the set of all polymatroids on a set .
To streamline notation on polymatroids, we make several conventions: for sets , we often write instead of . Similarly, for sets , we write for . We also mix this notation, e.g. stands for and similar.
One particular interesting class of polymatroids are entropic functions which we define next. Let Y be a random variable on a finite domain D. Then the entropy of Y is
with the usual convention if . Note that, since , we have that is always non-negative. The entropy of Y has an interpretation as the amount of information that one can get from sampling Y, but we do not need anything beyond some properties of entropy here.
Given a set and random variables , each with domain , we define a set function as follows: for every set , let be the random variable with domain with . Then . Functions which can be represented that way are called entropic. We denote by the set of all entropic functions over the set .
The following result goes back to Shannon's foundational work on information theory.
▶ Theorem 2. [24] All entropic functions are polymatroids.
In some cases (see Section 3.4) we abuse notation by allowing random variables (rather than their indices) as arguments of the set function . Thus, given a set of random variables , we write for . Similarly, given random variables , we write for .
We remark that the notation is slightly non-standard. Generally, in the literature, the notation is used for polymatroids on sets of size n. We chose our notation here because not only the size of will be important to us but also which elements contained in it.
Entropy can also be defined for continuous random variables with infinite domains. However, we will only restrict to finite domains since those are sufficient for our purposes.
▶ Definition 3. Given a polymatroid and not necessarily disjoint subsets , we define .
▶ Remark 4. The definition of is motivated by information theory, where the value is called the conditional entropy of given . In matroid theory, a similar transformation of the rank function appears in the contraction of (poly)matroids.
The following easy observation will be useful throughout this paper.
▶ Observation 5. Let be a polymatroid on the set and let . Then
Proof. Applying Definition 3, we get
▶ Observation 6. Let A, B, C be sets of variables and let h be a polymatroid. Then
Proof. By submodularity, we have
Rearranging according to Definition 3 directly yields the claim.
Size Bounds for Query Results
Entropic functions play a key role in size bounds for conjunctive queries under functional dependencies. To this end, consider a CQ
Let . Throughout the paper, we will let be the set of output variables and be all variables of the query. We assume that we have a set that contains for every relation a cardinality constraint on its size. Moreover, we have a set of FDs. We say that a set function satisfies and , in symbols if for every we have and for every FD in , we have .
Let K be a class of set functions over Y. Then we define the quantity
In what follows we discuss two important special cases of this bound: and .
▶ Theorem 7 (Entropic Bound [11]). Let be a conjunctive query with the set of variables , with cardinality constraints and FDs . If is a database with for every atom of , then .
It is known that the entropic bound is tight in an asymptotic sense [10]. However, unfortunately, it is not known if is even computable, so already in [11], the following approximation of the entropic bound was formulated.
Size Bounds for CQs Under Acyclic Constraints
▶ Theorem 8 (Polymatroid Bound [11]). Let be a conjunctive query with the set of variables , with cardinality constraints and . If is a database with for every atom of , then .
Note that the only difference between the entropic bound and the polymatroid bound is that in the former we take the supremum over all entropic functions while in the latter we maximize over the strictly bigger set of all polymatroids. As a consequence, we get that we always have .
3 Separating the Entropic and Polymatroid Bound
In this section we will show our main result that in general the entropic bound can be smaller by a polynomial factor than the polymatroid bound even for the case of acyclic FDs.
▶ Theorem 9. There is a conjunctive query with variable set , a set of cardinality constraints and a set of acyclic FDs such that
We will show Theorem 9 in the remainder of this section. The general idea is that we start from an instance with cyclic constraints for which we already know that it has a gap between the polymatroid bound and the entropic bound (Section 3.1). Then, we transform this instance in an example with similar properties but acyclic constraints. To this end, we introduce copies of variables to break the cycles (Section 3.2). To prove Theorem 9, it suffices to show that untangling the cyclic constraints in a query preserves both the polymatroid bound (we prove this Section 3.3) and the entropic bound (we prove this in Section 3.4).
3.1 Introducing the base instance
In this section, we begin the proof of Theorem 9 by introducing the query that in [15, 25] was used to show a gap between the entropic bound and the polymatroid bound. We will use this query to as the basic building block of for the proof of Theorem 9, as discussed before. The query from [15, 25], called the Zhang-Yeung query in [15], is defined as follows:
(1)
The variable set of this query is . As in [15, 25], we add the cardinality constraints for and and the functional dependencies
Clearly, these constraints are highly cyclic, but we will take care of this later. We transform the cardinality constraints into the constraints
Algorithm 1 The untangling algorithm
1: procedure UNTANGLE(Q, X, Π, Σ, π) 2: /* we assume Q is a query with output variables X and without projections / 3: 4: 5: 6: 7: for all variables X from X in order π do 8: if there is an offended FD for π via X in Σ' then 9: introduce new variable 10: 11: 12: 13: add to 14: for all FDs in offended for π via X do 15: delete from 16: add to 17: / by construction, is a query with variable set and output variables */ 18: return ,
The functional dependencies are transformed into the constraints
In [25, 15], it was shown that the polymatroid bound for this query and the size constraints and FDs is . However, the entropic bound is stronger: it implies for this query the bound at most , as shown in [15]. Let us recall how this inequality for the entropic bound was proven in [15]. The crucial ingredient of the argument is the following fact from information theory.
▶ Lemma 10 (see [31]). For every entropic function h in variables A, B, X, Y, we have
One can combine the inequality from Lemma 10 with the constraints in (8) and (9), and all polymatroid inequalities (monotonicity and submodularity), and then maximize the value of compatible with those constraints. We obtain a linear program for which the optimal value can be computed by a symbolical computation (by hand or with help of computer). The computed optimal value is the value claimed above, see [15, 25]. Thus the entropic bound for this query is at most (it remains possible that with a better understanding of the laws of Shannon entropy one could get an even tighter bound.)
3.2 Untangling the functional dependencies
For our purposes, the query from (1) is not immediately useful since its constraints are cyclic. So we transform it into another query with new functional dependencies . Rather than presenting an ad-hoc trick, we explain a general procedure that transforms
Size Bounds for CQs Under Acyclic Constraints
any given query Q without projected variables but with potentially cyclic FDs into another query with acyclic FDs but potentially with projections. So essentially in the transformation we gain acyclicity of the FDs at the price of introducing projections. We then show that the polymatroid bound of and is at least that of Q and . Moreover, applying this procedure on and yields and for which we can then show the required inequality for the entropic bound. This will prove the main result of this paper.
Consider any query Q without projected variables with a set of potentially cyclic functional dependencies. We fix an order of the variable set of Q. Essentially, is a guess for a topological order of the variables. We say that a constraint is offended for the order (via a variable V) if there are variables V, W such that V is before W in but W is in the body of this dependency and V is in its head. Clearly, there are no offended constraints for if and only if is a topological order of the dependency graph of Q. So the idea is to systematically untangle all offended constraints by adding new variables, and eventually end up with a topological order witnessing that the constraints are acyclic. To do so, we are using the procedure given in Algorithm 1 which we describe next.
Given a query with constraints , and a variable order , we go through the list of variables in the order and do the following: if the current variable is not in the head of an offended constraint for the current order, we skip it and proceed with the next variable. Otherwise, we introduce a new variable (which is essentially a “copy” of ) and make the link between the original variable and its copy by a new functional dependency . Since for each functional dependency there must be an atom that contains all of its variables, we also add an atom where is a fresh relation name. Moreover, in the set of output variables we replace the old variable by its copy . Observe that due to this, there are projections in the new query (even though the original query does not have any), since is not an output variable anymore. Finally, for every occurrence of in the head of an offended constraint, we replace by . This completes the construction of the new instance and the set of FDs.
▶ Observation 11. For every input , Algorithm 1 returns such that the obtained set of functional dependencies is acyclic.
Proof (sketch). The acyclicity condition can be violated only in the presence of offended constraints. When processing each variable in X, the algorithm eliminates every constraint offended via that variable. As for the newly introduced variables, they appear only in the heads of functional dependencies and therefore cannot violate the acyclicity condition.
Let us apply the Algorithm 1 to the example presented in Section 3.1. We fix the variable order . When running the algorithm, we first consider the variable A for which the constraints (4), (6) and (7) are offended. So we introduce a new variable and swap the offended constraints out for
Also, becomes an output variable instead of A, and we add a new functional dependency . Going through the list of all variables, we obtain the query
(10) with the extended variable set . The new set of functional dependencies consists of those in in which potentially some variables are swapped out,
and the additional dependencies we added when introducing new variables
We keep the same cardinality constraints as before.
Theorem 9 is a direct corollary of the following result, where , , , are taken from the query as defined above.
▶ Proposition 12. .
One can prove Theorem 12 with an assistance of a computer, as follows. First of all, we combine the inequalities for the FDs (11) and (12), the constraints from (8), and all polymatroid inequalities and Theorem 10, in one linear program (LP), feed this optimization problem into any LP solver, and compute the maximal value for . This computation gives the polymatroid bound, which in this case is 4. Further, if we include in this linear program one more constraint — the inequality from Theorem 10 — we obtain a smaller maximal value for , which in this case is . This mechanical computation concludes the proof of the proposition. In the appendix (see p. 17) we discuss this approach in more detail. However, a proof relying on heavy computation performed by a computer (calculating the optimal value of two huge linear programs) might look somewhat unsatisfactory. So in the following subsections we provide a fully human-checkable argument.
3.3 The Polymatroid Bound
In this section, we show the lower bound on from Proposition 12. More generally, we will show that the construction of Algorithm 1 never decreases the polymatroid bound. Let us formulate this statement more precisely.
▶ Proposition 13. Let be a CQ in variables without projected variables with cardinality constraints and functional dependencies . We apply Algorithm 1 to the input , , and any variable order . Let , be the output returned by the algorithm, and let be the variables set of the output query . Then
Proof. We assume that there is polymatroid in that respects all cardinality constraints and functional dependencies . By definition, the value of must be below the bound . We will construct another polymatroid defined on and respecting the constraints from and . Moreover, in our construction we will have
Size Bounds for CQs Under Acyclic Constraints
. Thus, the bound log-bound applies in particular to and, therefore, to . This implies the statement of the lemma.
To implement the plan sketched above, we define the inverse operation of the variable addition in Algorithm 1. For every variable , let stand for the variable such that (in the case ) or (in the case ). Essentially, copies of variables are mapped to their original, while the originals are mapped to themselves. For every variable set , we extend this definition to .
The operation plays well with the usual operations on sets:
▷ Claim 14. For all we have:
■ if , then (monotonicity),
■ , and
■
Proof. The first and second claims are immediately clear from the definition.
For the third claim, note that
△
Now assume that is a polymatroid on satisfying the constraints in and . We define a set function on as . Clearly, for the set we have , since . So to prove the lemma it remains to show that is a polymatroid that satisfies the constraints of .
We first show that is a polymatroid. For monotonicity, consider with , then
where we use the monotonicity of and . To show that is submodular, consider arbitrary sets . Then
[since h is submodular]
So, noting that , we conclude that is a polymatroid.
It remains to show that satisfies the functional dependencies in . For all variables and their copy , we have , so , and thus satisfies the unary functional dependencies the algorithms introduced.
Let be any other constraint of . Then by construction we have and . Since is a constraint in , we have and thus
Therefore, respects the functional dependency .
◀
3.4 The Entropic Bound
In this subsection we will show that the entropic bound for the query with the FDs we constructed in Section 3.2 is at most . As we have shown in Section 3.3, this bound is strictly less than the polymatroid bound. Our starting point is the proof of an upper bound for in [15, 25], where it was shown that for all entropic functions in variables the following inequality is valid:
(*)
This inequality follows from a combination of Theorem 10 with several polymatroid inequalities. In the application of (*) discussed in [15, 25], all terms on the right-hand side are bounded, so the inequality implies an upper bound for . This establishes a separation between the entropic bound and the polymatroid bound in the setting considered in [15, 25].
We cannot use () directly, since in our settings we do not have a bound on the terms appearing on the right-hand side. Moreover, we need to bound not the value of but (for that are defined in Algorithm 1). This is we need to prove that the following inequality inspired by () is true for all entropic functions :
(**)
With () we can show that is bounded by , which proves the upper bound for in Proposition 12. Indeed, we observe that for satisfying the FDs in (from Proposition 12), each term of conditional entropy in () is equal to zero, due to the functional dependencies in , see (11). Each term of non-conditional entropy on the right-hand side of (**) is bounded by the cardinality constraints in , see (8). Combining these bounds we obtain , as required.
It remains to prove () based on (*). It is not very hard to show that under the condition that is a polymatroid that satisfies and , so the left-hand side of () is smaller than that of (). However, this does not directly help us since the quantities of the conditional entropies in (**) can also be smaller than those in (). To resolve this issue, we show that when going from (*) to (**) the decrease in value on the left-hand side cannot be bigger than on the right-hand side. The main technical argument is the following lemma which lets us compute the change in conditional entropies when substituting a variable by in Algorithm 1.
▶ Lemma 15. Let be a polymatroid on a domain and let be disjoint. Let moreover elements not in such that . Then
Proof. By Observation 5 we have
Further, from Observation 5 and Observation 6 we obtain
So we get , and the lemma follows.
◀
Size Bounds for CQs Under Acyclic Constraints
Another ingredient that we need is the following.
▶ Lemma 16. Let be a polymatroid on a domain and let be disjoint. Let moreover elements not in such that . Then .
Proof. Expanding the definition of conditional entropy, we get
Moreover, by Lemma 15
So we obtain
and we are done.
In what follows we apply Lemma 15 and 16 to entropic functions which, by Theorem 2 are a special class of polymatroids.
We now come back to the proof of (**). We begin with () and substitute step-by-step the occurrences of A, B, X, Y by , as in the untangling construction of Algorithm 1. In the first step we substitute A by in several occurrences in (); this affects the terms , , , shown in bold below:
By Lemma 15, to balance each substitution, we have to add the value of . Summing the coefficients, we see that we have to add this quantity 11 times on the left-hand side and 5 times on the right-hand side. Since is non-negative, we may therefore conclude that
In the second step, we substitute by in the terms , , , , shown in bold below:
By Lemma 15, each of these substitutions can be balanced by adding the terms and respectively. By Lemma 16 we have ; it is important that the biggest “compensation terms” appears on the left-hand side of the inequality. So again, summing the coefficients, we conclude that that the overall decrease on the left-hand side is at least that on the right-hand side, so we get
(14)
In the third step we substitute X by in the terms , , ,
Each of these three substitutions can be balanced by adding the terms (with a factor of 11), (with a factor of 1), and again (with a factor of 2) respectively. Among all these added terms, the quantity of the entropy (appearing in the left-hand side) is the biggest. This implies
(15)
In the final step, we now substitute Y by in , , and . Similarly to the previous arguments, we obtain , which completes the proof.
4 A Tight Case
Let a conjunctive query and a set of functional dependencies. We say that is a prefix with respect to if there is a topological order of the dependency graph (see p. 3) in which all variables in come before all variables not in . We show here that if is a prefix with respect to , then the polymatroid bound is tight.
▶ Theorem 17. Let be a conjunctive query in variables , let be a set of cardinality constraints and be a set of functional dependencies such that is a prefix with respect to . Then
In the remainder of this section, we prove Theorem 17. To this end, we introduce some more definitions. Given that is a query in variables , we define its output restriction .
▶ Remark 18. The transformation of into is purely syntactical, we do not discuss the semantics of the atoms .
We also define to be the set of cardinality constraints that for every is the same as for in . Finally, contains for every FD in with
Size Bounds for CQs Under Acyclic Constraints
▶ Example 19. Consider again the query and the FDs from Example 1. Since in the order given there the output variables come before all non-output variables, they are a prefix with respect to the FDs. Moreover, we have
and the corresponding FDs are , . Note that the FD does not induce any FD for .
The next lemma states that if is a prefix with respect to , then the bounds for , , and for , , coincide.
▶ Lemma 20. Let be a set of variables, , a set of cardinality constraints and a set of functional dependencies such that is a prefix with respect to . Then
Proof. Claim 1: .
Consider any polymatroid on satisfying and . We will construct a polymatroid that satisfies and with . From this, the claim follows directly. To construct , we extend to a polymatroid on by setting for every the value . Clearly, is a polymatroid satisfying . We show that it also satisfies the constraints in . To this end, consider an FD from . We claim that
In this chain of equalities only the third one is non-trivial. In the case it is straightforward; and in the other case it holds because is an FD in and thus satisfied by . Since , it follows that , as claimed.
Claim 2: .
To prove this claim, consider any entropic function on that satisfies all constraints in and . We construct a new entropic function on by adding random variables for and letting their distribution be such that they only ever take a fixed value. Then for any subset we have by definition of the entropy . Since is entropic and thus a polymatroid, it follows that for every that , so . Now the claim follows exactly as for the polymatroid case.
Claim 3: .
To prove this claim, we consider a polymatroid satisfying the constraints in and . We define by setting for every . We claim that defined this way is a polymatroid.) Clearly, and is monotone, so it only remains to show that is submodular. So let . Then
which shows that is indeed a polymatroid.
We now claim that satisfies the FDs in . So consider an FD from . Assume first that . Then
where the inequality holds because is monotone and the final equality it true because satisfies and thus . Now consider the case that . Then, because is a prefix, we have that . It follows that
So in any case satisfies and thus .
We now define a set function on by restricting to the ground set . Then is a polymatroid that satisfies the constraints in . Moreover, we have . So for every polymatroid on respecting , we can construct a polymatroid on respecting such that , and it follows that .
Claim 4:
To prove this claim, we let be an entropic function on . Assume for simplicity that . Then there are random variables such that for every we have where . Then define a set of random variables having the same distribution for the as for and fixing all other variables to a constant value. Let be the entropic function induced by the set . Then we have for every that , since the corresponding random variables are constant. Since is entropic and thus a polymatroid, it follows that for every we have and thus . However, by definition of , we have since both values are the entropy of the same random variable . But then . Thus, is exactly as in Claim 3 (the case of polymatroids) but here has the additional property that it is entropic. The rest of the argument follows as the polymatroid case.
To prove Theorem 17, we now use the fact that without projections the polymatroid bound and the entropic bound coincide for acyclic sets of FDs. The following is stated as Proposition 4.4 [21], adapted to our slightly different notation.
▶ Proposition 21. Let be a conjunctive query without projection in variables , let be a set of cardinality constraints and an acyclic set of functional dependencies. Then
Proposition 17 now follows easily.
Proof of Proposition 17. Simply combine the two equalities from Lemma 20 with that of Proposition 21.
5 Conclusion
In this paper, we studied the relationship between the polymatroid and entropic bounds for conjunctive queries under acyclic functional dependencies. We showed that adding projections fundamentally change the picture: unlike the case of queries without projected variables [21], the two bounds do not coincide in general when projections are allowed. On the positive side, we identified a natural class of queries for which tightness is preserved, namely those whose output variables form a prefix with respect to the dependency graph. These results provide a better understanding of when the polymatroid bound remains tight.
Size Bounds for CQs Under Acyclic Constraints
References
1 Mahmoud Abo Khamis, Hung Q Ngo, and Dan Suciu. Computing join queries with functional dependencies. In Proceedings of the 35th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, pages 327–342, 2016.
2 David L Applegate, William Cook, Sanjeeb Dash, and Daniel G Espinoza. Exact solutions to linear programming problems. Operations Research Letters, 35(6):693–699, 2007.
3 Marcelo Arenas, Pablo Barceló, Leonid Libkin, Wim Martens, and Andreas Pieris. Database Theory. Open access at https://github.com/pdm-book/community, 2022. accessed March 2026, commit 9f403e4f8bb14eccca301eda2feafe90179b98df.
4 Albert Atserias, Martin Grohe, and Dániel Marx. Size bounds and query plans for relational joins. SIAM Journal on Computing, 42(4):1737–1767, 2013.
5 Angela Bonifati, Wim Martens, and Thomas Timm. An analytical study of large SPARQL query logs. VLDB J., 29(2-3):655–679, 2020.
6 Florent Capelli, Oliver Irwin, and Sylvain Salvati. A simple algorithm for worst case optimal join and sampling. In Sudeepa Roy and Ahmet Kara, editors, 28th International Conference on Database Theory, ICDT 2025, Barcelona, Spain, March 25-28, 2025, volume 328 of LIPIcs, pages 23:1–23:19. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2025.
7 Terence Chan. Recent progresses in characterising information inequalities. Entropy, 13(2):379–401, 2011.
8 László Csirmaz. Exploring the entropic region. arXiv preprint arXiv:2509.12439, 2025.
9 Randall Dougherty, Chris Freiling, and Kenneth Zeger. Non-shannon information inequalities in four random variables. arXiv preprint arXiv:1104.3602, 2011.
10 Tomasz Gogacz and Szymon Torunczyk. Entropy bounds for conjunctive queries with functional dependencies. In Michael Benedikt and Giorgio Orsi, editors, 20th International Conference on Database Theory, ICDT 2017, Venice, Italy, March 21-24, 2017, volume 68 of LIPIcs, pages 15:1–15:17. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2017.
11 Georg Gottlob, Stephanie Tien Lee, Gregory Valiant, and Paul Valiant. Size and treewidth bounds for conjunctive queries. J. ACM, 59(3):16:1–16:35, 2012.
12 Georg Gottlob, Nicola Leone, and Francesco Scarcello. Hypertree decompositions and tractable queries. J. Comput. Syst. Sci., 64(3):579–627, 2002.
13 Martin Grohe and Dániel Marx. Constraint solving via fractional edge covers. ACM Trans. Algorithms, 11(1):4:1–4:20, 2014.
14 Mahmoud Abo Khamis, Hung Q. Ngo, and Dan Suciu. What do shannon-type inequalities, submodular width, and disjunctive datalog have to do with one another? CoRR, abs/1612.02503, 2016.
15 Mahmoud Abo Khamis, Hung Q. Ngo, and Dan Suciu. What do shannon-type inequalities, submodular width, and disjunctive datalog have to do with one another? In Emanuel Sallinger, Jan Van den Bussche, and Floris Geerts, editors, Proceedings of the 36th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, PODS 2017, Chicago, IL, USA, May 14-19, 2017, pages 429–444. ACM, 2017.
16 Csirmaz Laszlo and Elod P Csirmaz. Information inequalities for five random variables. Computation, 14(2):42, 2026.
17 Viktor Leis, Andrey Gubichev, Atanas Mirchev, Peter Boncz, Alfons Kemper, and Thomas Neumann. How good are query optimizers, really? Proceedings of the VLDB Endowment, 9(3):204–215, 2015.
18 Konstantin Makarychev, Yury Makarychev, Andrei Romashchenko, and Nikolai Vereshchagin. A new class of non-shannon-type inequalities for entropies. Communications in Information and Systems, 2(2):147–166, 2002.
19 Frantisek Matus. Infinitely many information inequalities. In 2007 IEEE International Symposium on Information Theory, pages 41–44. IEEE, 2007.
20 František Matuš and Lászlo Csirmaz. Entropy region and convolution. IEEE Transactions on Information Theory, 62(11):6007–6018, 2016.
21 Hung Q Ngo. Worst-case optimal join algorithms: Techniques, results, and open problems. In Proceedings of the 37th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, pages 111–124, 2018.
22 Hung Q Ngo, Ely Porat, Christopher Ré, and Atri Rudra. Worst-case optimal join algorithms. Journal of the ACM (JACM), 65(3):1–40, 2018.
23 P Griffiths Selinger, Morton M Astrahan, Donald D Chamberlin, Raymond A Lorie, and Thomas G Price. Access path selection in a relational database management system. In Proceedings of the 1979 ACM SIGMOD international conference on Management of data, pages 23–34, 1979.
24 Claude Shannon. A mathematical theory of information. Bell Sys. Tech. Journal, 1948.
25 Dan Suciu. Applications of information inequalities to database theory problems. In 38th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2023, Boston, MA, USA, June 26-29, 2023, pages 1–30. IEEE, 2023.
26 Ru Wang and Yufei Tao. Join and subgraph sampling under degree constraints. J. Comput. Syst. Sci., 155:103693, 2026.
27 Raymond W Yeung. A first course in information theory. Springer Science & Business Media, 2012.
28 Raymond W Yeung. Facets of entropy. Commun. Inf. Syst., 15(1):87–117, 2015.
29 RW Yeung. A first course in information theory. IEEE Transactions on Information Theory, 49(7):1869, 2003.
30 Haozhe Zhang, Christoph Mayer, Mahmoud Abo Khamis, Dan Olteanu, and Dan Suciu. Lpbound: Pessimistic cardinality estimation using p-norms of degree sequences. Proc. ACM Manag. Data, 3(3):184:1–184:27, 2025.
31 Zhen Zhang and Raymond W Yeung. On characterization of entropy function via information inequalities. IEEE transactions on information theory, 44(4):1440–1452, 1998.
A Appendix: computer-assisted proof of the main technical result
In this section we sketch an approach that allows us to verify with the help of a computer the correctness of our main technical result (the first inequality of Proposition 12, which in turn implies Theorem 9). This provides a shortcut to the final result, allowing the reader to avoid carefully reading the details of the proof in Section 3.4. The approach involves extensive routine computations and is therefore impractical to carry out manually. Its main drawback is that it requires trusting the reliability of the computer hardware and software. Moreover, it gives the final answer without providing much insight into the structure underlying the computations.
Our goal is to prove a nontrivial upper bound on log-bound associated with the query (10) under the functional constraints (11) and (12) and the cardinality constraints (8). To this end, we transform this information-theoretic problem into a problem of linear optimization, and then solve it with the standard methods of linear programming.
The query (10) involves variables: . Thus, in the quantity log-bound we deal with 9 jointly distributed random variables (which we denote by the same symbols ). For a 9-tuple of random variables, we have 9 entropy quantities for individual random variables
entropy values for pairs
Size Bounds for CQs Under Acyclic Constraints
entropy values for all triples, etc., up to the entropy of the entire 9-tuple,
In total, we obtain entropy quantities. These quantities must satisfy the 6 constraints from (11)
and the 4 constraints from (12)
The cardinality constraints (8) can be reformulated as
where t stands for the threshold log N. Furthermore, the entropy quantities under consideration are non-negative and satisfy the axioms of polymatroids (monotonicity, subadditivity, and submodularity, also known as Shannon inequalities). For n = 9 random variables, all these inequalities are implied by
elemental Shannon inequalities, see, e.g., [27]. The description of the elemental inequalities is explicit, and the complete list of these inequalities can be generated mechanically by a simple computer program.
In addition to the constraints above, we add one more inequality
which is a form of the non-Shannon type inequality ( ).
Given all those constraints, we maximize the entropy . This is essentially an optimization problem with linear constraints, i.e., a linear programming problem (with one optimization variable for each of the 511 entropy quantities). It turns out that the optimal value of the resulting linear program is . This answer can be found up to floating-point rounding errors with standard industrial LP solvers, or exactly with an LP solver that computes rational optimal solutions based on the simplex algorithm implemented with arbitrary-precision rational arithmetic (see [2]). Although the resulting linear program is far too large to solve manually, it is can be solved easily by a computer with modern LP solvers.