Algorithm Search⌘K

Problemadvanced

Database repair

Also called minimum-cost repair, constraint-based data repair.

Change a database that violates integrity constraints so that it satisfies them, by deletions, insertions or value updates that are minimal under a chosen measure of change.

Database repair asks for a consistent database that is as close as possible to a given database that violates its constraints. It differs from consistent query answering: there the repairs are only a way to define which answers are safe, and no repair is chosen, while here the output is one repaired database that later queries run on. The problem has many versions, one for each kind of change allowed and each way to measure the change. This page treats deletions of facts in detail and value updates more briefly.

In plain words

A table breaks a rule, such as "each person has one department". You want to fix the table so that it follows the rule, and you want to change as little as you can, since most of the data is probably right.

There are several ways to fix it. You can delete rows until no rule is broken. You can delete as few rows as possible, or rows that you trust less. Or you can change single values in place, such as a misspelled department name. Each choice gives a different idea of the best fix, and some of them are easy to compute while others are as hard as the hardest search problems.

Definition

Let DD be a finite database and Σ\Sigma a set of constraints. Set semantics holds. A repair is a database D′D' that satisfies Σ\Sigma and is minimal for some measure of change. The main kinds are these.

  • Subset repair. D′⊆DD' \subseteq D is consistent and no consistent D′′D'' has D′⊊D′′⊆DD' \subsetneq D'' \subseteq D. These are the repairs of Arenas, Bertossi and Chomicki when only deletions are needed, which is the case for denial constraints.
  • Cardinality repair. D′⊆DD' \subseteq D is consistent and has the largest number of facts among consistent subsets. With a weight w(f)>0w(f) > 0 for each fact, an optimal subset repair has the largest total weight.
  • Symmetric-difference repair. For constraints that ask for facts to exist, such as inclusion dependencies, D′D' may add facts, and D△D′D \mathbin{\triangle} D' is minimal under inclusion.
  • Update repair. D′D' has the same facts as DD with some cell values changed. The measure is the number of changed cells, or a sum of costs per cell.

The computational questions are:

  • Repair checking. Given DD and D′D', is D′D' a repair of DD?
  • Finding. Compute one repair, or an optimal one.
  • Counting and enumeration. Count or list all repairs.

The constraints are fixed, so the complexity is data complexity unless stated.

The conflict graph. For functional dependencies, the facts are the vertices and an edge joins two facts that violate a dependency together. A subset of DD is consistent if and only if it is an independent set. So the subset repairs are the maximal independent sets, and the cardinality repairs are the maximum independent sets, the complements of the minimum vertex covers. For denial constraints with more than two tuple variables, the conflicts are hyperedges and the deleted facts form a hitting set.

Variants

  • The constraints. Functional dependencies, keys, conditional functional dependencies, denial constraints, or inclusion dependencies.
  • The kind of change. Deletions, insertions, updates of values, or a mix.
  • The measure. Minimal under inclusion, smallest number, smallest total weight, or a cost per changed cell that depends on how far the new value is from the old one.
  • Priorities. A preference among conflicting facts, for example the newer fact wins, which narrows the set of repairs.
  • Statistical repair. Choose the most likely values under a model learned from the data, as HoloClean does. This drops the exact notion of minimality.

Examples

The table Emp has the attributes name, dept and phone, and the functional dependency name →\to dept.

row name dept phone
0 ann sales 1
1 ann sales 2
2 ann hr 3
3 bob it 4
  • Subset repairs. Row 2 conflicts with rows 0 and 1. There are two subset repairs: rows {0, 1, 3} and rows {2, 3}. Both are maximal: adding any deleted row brings back a conflict.
  • Cardinality repair. Rows {0, 1, 3}, with one deletion. The subset repair {2, 3} needs two.
  • Weighted repair. If row 2 comes from a trusted source with weight 3 and the others have weight 1, the optimal subset repair is {2, 3}, with weight 4 against 3.
  • Update repairs. Changing the dept of row 2 to sales fixes the table with one changed cell. So does changing the name of row 2 to a new value. The second fix is cheap by count but probably wrong, which is why update repairs often fix which attributes may change or give each change a cost.

Known algorithms

  • One subset repair. Start from the empty set and add the facts of DD one at a time, keeping a fact when the set stays consistent. Under denial constraints the result is a subset repair: a fact skipped at some step conflicts with facts already kept, and those stay. The time is polynomial for fixed constraints.
  • Repair checking for subset repairs. Under denial constraints, D′D' is a subset repair if and only if it is consistent and D′∪{f}D' \cup \{f\} is inconsistent for each f∈D∖D′f \in D \setminus D'. A larger consistent superset would make D′∪{f}D' \cup \{f\} consistent for each of its new facts, since deleting facts keeps denial constraints. Both checks take polynomial time.
  • One functional dependency. For X→YX \to Y, the groups of facts with the same XX value are independent. Within a group, a consistent subset uses one YY value. So the optimal subset repair keeps, in each group, the YY value with the largest total weight, in O(∣D∣)O(|D|) time with hashing.
  • Two dependencies A→BA \to B and B→AB \to A. A consistent subset pairs each AA value with at most one BB value and back. Give the edge (a,b)(a, b) of a bipartite graph the total weight of the facts with A=aA = a and B=bB = b. The optimal subset repairs are the maximum weight matchings, found in polynomial time.
  • Approximation. For functional dependencies, delete a vertex cover of the conflict graph found by the matching method: take both ends of each edge of a maximal matching. This gives a consistent subset with at most twice the smallest number of deletions. With kk tuple variables per constraint, the same method on hyperedges gives a factor kk.
  • Update repairs. Holistic data cleaning by Chu, Ilyas and Papotti chooses value changes for all violations of a set of denial constraints together. It is a heuristic, with no guarantee of the smallest change.
AlgorithmTimeSpacePropertiesCode
HoloClean probabilistic repairO(n^2 a v q p + e n a v (a + q)) worstO(n a (a + v (a + q))) extrarandomizednot exactnot in placeofflineiterative1 language

Bounds

All bounds are theorems in data complexity.

  • Repair checking. Polynomial for subset repairs under denial constraints, as shown above.
  • Number of repairs. Under one key, a database with ss blocks of 2 facts each has 2s2^s subset repairs, so listing them all takes exponential time.
  • Optimal subset repairs under functional dependencies. For each fixed set of functional dependencies, computing an optimal subset repair is either in polynomial time or APX-complete, and a simplification procedure on the dependencies decides which (Livshits, Kimelfeld and Roy). The two easy cases above are instances of the polynomial side. In the APX-complete cases, the factor 2 of the vertex cover method holds, but no polynomial-time approximation scheme exists unless P = NP.
  • Cardinality repairs in general. Every cardinality repair problem under functional dependencies is a minimum vertex cover problem on the conflict graph, so it is in NP as a decision problem for any fixed set.

Reductions

  • To vertex cover and hitting set. A cardinality repair under functional dependencies is the complement of a minimum vertex cover of the conflict graph. Under denial constraints with kk tuple variables, it is the complement of a minimum hitting set of a hypergraph with edges of size at most kk.
  • Hardness. For the hard sets of dependencies, Livshits, Kimelfeld and Roy prove APX-hardness by reductions from known APX-hard problems to the optimal subset repair.
  • To consistent query answering. The set of subset repairs is the set of possible worlds over which consistent query answering takes the intersection of the answers.

Applications

  • Data cleaning. Repair a table before analysis, either by deleting the facts in conflict or by changing values. Systems in this line include holistic data cleaning and HoloClean.
  • Data integration. Merging sources that disagree on a key gives a table with conflicts, which a repair resolves.
  • Error reports. The conflict graph and a small vertex cover point a person to the few facts most likely to be wrong.
  • Constraint maintenance. After a load that breaks a constraint, a repair restores it with few changes.

References

  1. Marcelo Arenas, Leopoldo Bertossi and Jan Chomicki, Consistent query answers in inconsistent databases, PODS 1999, pages 68-79, repairs as consistent databases at a minimal distance from the given one
  2. Jan Chomicki and Jerzy Marcinkowski, Minimal-change integrity maintenance using tuple deletions, Information and Computation 197(1-2), 2005, pages 90-121, repairs by deletions, the conflict hypergraph and repair checking
  3. Ester Livshits, Benny Kimelfeld and Sudeepa Roy, Computing optimal repairs for functional dependencies, PODS 2018, pages 225-237, the dichotomy for optimal subset repairs under functional dependencies
  4. Ester Livshits, Benny Kimelfeld and Sudeepa Roy, Computing optimal repairs for functional dependencies, ACM TODS 45(1), 2020, the journal version of the dichotomy and the simplification procedure
  5. Xu Chu, Ihab F. Ilyas and Paolo Papotti, Holistic data cleaning: putting violations into context, ICDE 2013, pages 458-469, repair by value updates under denial constraints
  6. Leopoldo Bertossi, Database Repairing and Consistent Query Answering, Morgan and Claypool, 2011, the chapters on repair semantics

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml