Relational database management systems (RDBMS) are built for exactness. They excel at answering binary questions: Does this ID match? Is this timestamp greater than X? To do this efficiently, they rely on structured indexes like B-trees that rapidly prune search spaces.
Conversely, real-world applications—such as Case-Based Reasoning (CBR), data deduplication, and example-based natural language processing—rely on similarity. Finding the "most similar" case or a "near-miss" problem description traditionally requires calculating a distance metric between an input query and every single record in a database. This $O(N)$ pairwise comparison destroys the performance benefits of database indexing, forcing developers to pull massive datasets into the application layer for processing.
To bridge this gap, a rich line of research focuses on a powerful paradigm: transforming similarity requirements into structured database queries. By mapping fuzzy similarity concepts into exact-match query constraints or native database primitives, systems can execute complex similarity searches directly within optimized database engines.
Query Relaxation and the Art of Trickery
In the early 1990s, the primary challenge was deploying advanced AI systems, like Case-Based Reasoning, on top of existing corporate IT infrastructure without requiring specialized hardware. The breakthrough insight was that a similarity search could be decomposed into a sequence of exact-match SQL queries.
Consider a system trying to find a past technical support case that matches a new customer issue. Instead of evaluating a complex distance function across all rows, the system performs query relaxation. As detailed in the CARET system (Retrieving Cases from Relational Data-Bases: Another), similarity-scored combinations of attributes are translated directly into standard SQL SELECT-FROM-WHERE statements.
How does this work under the hood? Hideo Shimazu et al. in Retrieving Cases from Relational Data-Bases: Another Stride Towards Corporate-Wide Case-Base Systems and Hiroaki Kitano et al. in Case-Method: A Methodology for Building Large-Scale Case-Based Systems proposed pre-computing attribute value hierarchies (such as taxonomies or system diagrams). When a query is executed, the system generates a series of SQL queries representing progressive levels of attribute relaxation. If an exact match isn't found, the query constraints are widened step-by-step based on the hierarchy.
[Fuzzy Query] ──> [Exact Match Query?] ──(No)──> [Relax Constraints via Hierarchy]
│ │
(Yes) ▼
└──> [Return Rows] <────── [Execute Relaxed SQL Query]
Because each generated query is a standard, exact-match SQL statement, the database engine can use its native, highly optimized indexes to find candidates instantly. This shifts the computational burden of similarity from application-layer loops to the database's native query processor. This approach was successfully adapted by Hideo Shimazu et al. in Case-Based Retrieval Interface Adapted to Customer-Initiated Dialogues in Help Desk Operations to handle customer-initiated help desk dialogues, and by Takehito Utsuro et al. in Thesaurus-based Efficient Example Retrieval by Generating Retrieval Queries from Similarities to accelerate example retrieval in natural language processing by encapsulating similarity characteristics directly into targeted search criteria.
Moving In-Engine: Declarative Similarity Predicates
As database engines evolved, the strategy shifted from wrapping the database in an external query-generation layer to embedding similarity directly into the query language itself. This transition allowed developers to express similarity declaratively while letting the database optimize the execution plan.
Amit Chandel et al. in Benchmarking declarative approximate selection predicates demonstrated this by implementing declarative approximate selection predicates directly in SQL. By embedding similarity functions into the database's native execution capabilities, data cleaning and deduplication tasks could be performed inline without exporting data.
For more complex data types, such as high-dimensional vectors or metric spaces, Haixiang Li et al. introduced MSQL+ in MSQL+: a Plugin Toolkit for Similarity Search under Metric Spaces in Distributed Relational Database Systems, a plugin toolkit that supports similarity searches under metric spaces using standard SQL syntax. MSQL+ works by generating compact "signatures" for data points and building standard B+-trees over them. When a user runs a similarity query, the system uses fast index seeks on the B+-tree to filter out the vast majority of non-matching candidates before performing a final, expensive verification step on the remaining rows.
Distributed and Graph-Based Extensions
Modern data scales require these similarity-aware query engines to operate across distributed environments. Systems like Dima, developed by Ji Sun et al. in Dima: A Distributed In-Memory Similarity-Based Query Processing System and later enhanced with balance-aware signatures by Ji Sun et al. in Balance-Aware Distributed String Similarity-Based Query Processing System, extend standard SQL with domain-specific operations for similarity selections and similarity joins. By integrating directly with distributed in-memory frameworks like Spark, these systems balance the computational load across clusters while maintaining a familiar declarative syntax.
This concept extends beyond relational data to graph databases and semantic webs. For instance, Wei Emma Zhang et al. in SECF: improving SPARQL querying performance with proactive fetching and caching applied query-level similarity to SPARQL querying. By calculating structural and textual similarity between graph queries (using Graph Edit Distance and modified Levenshtein distance), their framework can proactively fetch and cache results for anticipated queries, dramatically reducing response times over distributed knowledge bases.
Why It Works: The Core Intuition
The enduring success of this research direction relies on a simple, elegant realization: you do not need to compute exact distances to prune a search space.
Whether through early 90s query relaxation or modern distributed signature indexing, the core mechanism remains identical:
- Abstract: Map continuous or complex similarity spaces into discrete, hierarchical, or structured representations (taxonomies, signatures, or relaxed constraints).
- Filter: Use these structured representations to generate standard database queries or index lookups. This allows the database engine to instantly discard millions of irrelevant rows using native indexing (like B-trees).
- Refine: Perform the actual, computationally expensive similarity calculations only on the tiny fraction of candidate rows that survive the filter step.
By aligning the mathematics of similarity with the engineering of relational indexes, this paradigm transforms an intractable $O(N)$ application-layer bottleneck into a highly optimized, scalable database operation.
Key Foundational Work
Case-Based Retrieval Interface Adapted to Customer-Initiated Dialogues in Help Desk Operations (1994) — contributed 2 concept elements to this direction.
Retrieving Cases from Relational Data-Bases: Another Stride Towards Corporate-Wide Case-Base Systems (1993) — contributed 2 concept elements to this direction.
Retrieving Cases from Relational Data-Bases: Another Stride Towards Corporate-Wide Case-Base Systems (1993) — contributed 2 concept elements to this direction.