arXiv:2610.36418cs.DBOct 2026

Manuscript Offprint

arXiv:2610.36418

When the Application Layer Is Disposable: Putting Integrity Constraints Back in the Database

Hasara Kalumin, Amol Deshpande

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

ABSTRACT

Integrity constraints have been a key part of the relational model since the beginning. However, outside of keys, single-row CHECKs, and referential integrity, most other constraints are handled by the application layers on top today. SQL ASSERTIONS, standardized in SQL-92, remain poorly supported by most major RDBMSs. This has become increasingly unacceptable due to two major developments. First, LLM-driven applications/agents increasingly issue query and update statements directly against the databases, often bypassing the application layer where the invariants live today. Such code is envisioned to be generated on demand and discarded afterwards, and as such, the database becomes the only durable component that can encode and enforce them. Second, natural constraints in higher-level conceptual models such as the E/R model and property graphs get fragmented across relations under the physical mappings chosen for performance; the resulting multi-relation constraints are not directly supported by most databases and only some are efficiently enforceable by mechanisms (like triggers) available today.

These developments lead us to argue for an overhaul of how constraints are defined, mined, managed, and enforced in data management systems. As a first concrete step, we present constraint indexes, which represent constraints spanning multiple relations as transactional access paths, and implement a proof of concept as a PostgreSQL extension. Constraint indexes enforce constraints arising from distributed inheritance hierarchies, folded relationships, and folded weak entities, as well as cardinality bounds and functional dependencies, at low overheads relative to no enforcement. Across these workloads, they outperform the better of the correctness-preserving baselines by up to 2.41×2.41\times. We also show that LLM-driven writers violate such unenforced constraints at high rates, and behave erratically when provided with a list of constraints to enforce. We close with a discussion of a few research challenges this agenda raises.

1 INTRODUCTION

Integrity constraints have been integral to the relational model since its inception, and were intended to be an intrinsic part of a relation’s meaning 1^{1}. However, although the SQL standard has supported arbitrary assertions through the CREATE ASSERTION

Amol Deshpande

University of Maryland at College Park

USA

amol@umd.edu

command since 1992, most database systems today support a limited set of built-in constraints. To our knowledge, Oracle 26ai is the only major database system that supports CREATE ASSERTION, but that too comes with significant limitations 2^{2}.

This lack of support primarily stems from the high and unpredictable costs of enforcing complex constraints, especially those that span multiple tables, or even multiple rows in a single table. Constraint enforcement also has implications for concurrency control, and the semantics of updates under lower isolation levels like read committed become harder to convey. Although it is possible to implement complex constraints using triggers or shadow tables, over time, enforcement of such constraints naturally migrated up the stack to the application layer, where it largely lives today.

We argue that this is no longer a reasonable division of responsibility, and that databases must take a far more active role in identifying and enforcing multi-table constraints. Two developments motivate this argument. First, data is increasingly modeled and accessed through higher-level abstractions that sit above the relational model. Commonly used relational mappings transform constraints that are naturally local in these higher-level models into invariants spanning multiple relations or involving values embedded within folded structures, placing them beyond the constraints directly supported by most databases. Second, the application layer is no longer the sole place where updates originate. LLM-driven applications and autonomous agents increasingly generate database updates directly, often without generating durable application code in which such constraints can be maintained. Our controlled study of LLM-generated SQL shows that even supplying the constraints explicitly does not reliably produce correct enforcement, especially under concurrent execution. The database must therefore provide both a durable specification of these constraints and enforcement that is independent of the behavior of individual writers. Standardized middleware, that all writes are required to go through, could also provide a durable interface for such writers; that only shifts where our proposed components live, but doesn't affect the rest of our argument.

In this paper, we present an architecture centered around a constraint governor, envisioned as the central component for managing the lifecycle of constraints, from their declaration or discovery through validation, enforcement, revision, and eventual removal. Constraints may be supplied as part of a conceptual schema or mined from application code, workloads, or data. The governor keeps track of these constraints and their status, and decides how each is handled: by which mechanism, at which enforcement point, with which failure action, and with what feedback to the writer. These decisions may change over time. For example, a candidate

1^{1}Integrity constraints specific to a particular relational data base must be definable in the relational data sublanguage and storable in the catalog, not in the application programs." (Ted Codd's Rule 10)

This paper is published under the Creative Commons Attribution 4.0 International (CC-BY 4.0) license. Authors reserve their rights to disseminate the work on their personal and corporate Web sites with the appropriate attribution, provided that you attribute the original work to the authors and CIDR 2027. 17th Annual Conference on Innovative Data Systems Research (CIDR '27). January 24-27, Amsterdam, The Netherlands.

2^{2}https://docs.oracle.com/en/database/oracle/oracle-database/26/sqlrf/create-assertion.html constraint may initially be checked provisionally against live traffic, promoted to blocking enforcement as evidence supports it, or revised or dropped as application requirements change. A compiler would translate the governor's decisions into the structures and operations needed for enforcement, including their maintenance, synchronization, and recovery.

As a first concrete step toward realizing this vision, we present constraint indexes, a database mechanism that represents supported conceptual constraints through mapping-specific, transactionally maintained access paths. A constraint index materializes the compact auxiliary state needed to detect violations efficiently, avoiding repeated multi-table validation queries. The approach brings together the index structures, maintenance operations, and synchronization required for constraints that span multiple relations or involve folded structures. We implement a proof of concept as a PostgreSQL extension, with hand-written structures and operations for the evaluated constraints. The extension stores the auxiliary state in shared memory and integrates its maintenance with transaction processing through fine-grained logical locking and a unified per-transaction undo journal. Updates to the constraint indexes are atomic with the corresponding relational updates, while transactions that conflict on constrained values are serialized. Our evaluation covers constraints arising from distributed inheritance hierarchies, folded relationships, and folded weak entities, as well as cardinality bounds and functional dependencies. Across these workloads, constraint indexes provide efficient validation and scalability under concurrent execution, outperforming the best baselines by up to 2.41×2.41\times at 256 concurrent clients. These results provide evidence that specialized transactional access paths can make a substantial class of nonlocal constraints practical to enforce.

The rest of the paper is organized as follows. Section 2 elaborates on the two motivating scenarios. Section 3 reviews existing enforcement mechanisms and related work. Section 4 presents the constraint-governor architecture and develops constraint indexes. Sections 5 and 6 describe the PostgreSQL implementation and experimental evaluation, respectively. Section 7 concludes with research challenges.