Temporal Dependencies - Semantic Scholar

13 downloads 170 Views 119KB Size Report
with a caret (∧). For example, John Smith's salary increased from 10K to 12K. Such a relation that juxtaposes old and new values is called action relation. ⊣ old.
Temporal Dependencies Jef Wijsen University of Mons-Hainaut SYNONYMS None

DEFINITION Static integrity constraints involve only the current database state. Temporal integrity constraints involve current, past, and future database states; they can be expressed by essentially unrestricted sentences in temporal logic. Certain syntactically restricted classes of temporal constraints have been studied in their own right for considerations of feasibility or practicality; they are usually called temporal dependencies. Most temporal dependencies proposed in the literature are dynamic versions of static functional dependencies.

HISTORICAL BACKGROUND Static dependencies (functional, multivalued, join, and other dependencies) have been investigated in depth since the early years of the relational model. Classical problems about dependencies concern logical implication and axiomatization. The study of a particular dependency class is often motivated by its practical importance in databases. This is undeniably the case for the notion of functional dependency (FD), which is fundamental in database design. A dynamic version of functional dependencies was first proposed by Vianu [7]. Since the mid 90s, several other temporal variants of the notion of FD have been introduced.

SCIENTIFIC FUNDAMENTALS This section gives an overview of several temporal dependency classes proposed in the literature. With the exception of the notion of dynamic algebraic dependency (DAD) [2], all temporal dependencies here presented can be seen as special cases of the notion of constraint-generating dependency (CGD) [1]. The formalism of CGD, presented near the end, thus allows to compare and contrast different temporal dependency classes.

Functional Dependencies Over Temporal Databases Since the semantics of temporal versions of FDs will be explained in terms of static FDs, the standard notion of FD is recalled next. All the following definitions are relative to a fixed set U = {A 1 , . . . , An } of attributes. Definition A tuple over U is a set t = {A1 : c1 , . . . , An : cn }, where each ci is a constant. If X ⊆ U , then t[X] denotes the restriction of t to X. A relation over U is a finite set of tuples over U . A functional dependency (FD) over U is an expression X → Y where X, Y ⊆ U . A relation I over U satisfies the FD X → Y if for all tuples s, t ∈ I, if s[X] = t[X], then s[Y ] = t[Y ]. 2 When evaluating FDs over temporal relations, one may want to treat timestamp attributes differently from other attributes. To illustrate this, consider the temporal relation EmpInterval with its obvious meaning. EmpInterval

Name Ed Ed Ed

Sex M M M

Sal 10K 10K 12K

Project Pulse Wizard Wizard

From 1 2 4

To 3 3 4

An employee has a unique sex and a unique salary, but can work for several projects. The salary, unlike the sex, may change over time. The relation EmpInterval is “legal” with respect to these company rules, because for any time point i, the snapshot relation {t[Name, Sex , Sal , Project] | t ∈ EmpInterval , t(From) ≤ i ≤ t(To)} satisfies Name → Sex and Name → Sal . Note that the relation EmpInterval violates the FD Name → Sal , because the last two tuples agree on Name but disagree on Sal . However, since these tuples have disjoint periods of validity, they do not go against the company rules. Hence, the intended meaning of an FD expressed over a temporal relation may be that the FD must be satisfied at every snapshot. To indicate that Name → Sal has to be evaluated on snapshots, Jensen et al. [6] use the T

notation Name → Sal . The FD Name → Sex need no change, because the sex of an employee should be unique not only at each snapshot, but also over time. Chomicki and Toman [3] note that no special syntax is needed if tuples are timestamped by time points. For example, given the following point-stamped temporal relation, one can simply impose the classical FDs Name → Sex and Name, T → Sal . Name Ed Ed Ed Ed Ed Ed

EmpPoint

Sex M M M M M M

Sal 10K 10K 10K 10K 10K 12K

Project Pulse Pulse Pulse Wizard Wizard Wizard

T 1 2 3 2 3 4

Vianu’s Dynamic Functional Dependency [7] Consider an employee table with attributes Name, Sex , Merit, and Sal , with their obvious meanings. The primary key is Name. Assume an annual companywide update of merits and salaries. In the relation shown next, every tuple is followed by its updated version. Old values appear in columns with a caron ( ∨ ), new values in columns with a caret (∧ ). For example, John Smith’s salary increased from 10K to 12K. Such a relation that juxtaposes old and new values is called action relation. old

`

a

new

`

a

















Name John Smith An Todd Ed Duval

Sex M F M

Merit Poor Fair Fair

Sal 10K 10K 10K

Name John Smith An Todd Ed Duval

Sex M F M

Merit Good Good Fair

Sal 12K 12K 10K

The company’s policy that “Each new salary is determined solely by new merit and old salary” can be expressed ∨ ∧ ∧ by the classical FD Sal , Merit → Sal on the above action relation. In particular, since John Smith and An Todd agree on old salary and new merit, they must have the same new salary. Such FDs on action relations were introduced by Vianu [7] and called dynamic functional dependencies. ∨





Definition





For each Ai ∈ U , assume that Ai and Ai are new distinct attributes. Define U = {A1 , . . . , An } and ∧ ∧ ∧ U = {A1 , . . . , An }. For t = {A1 : c1 , . . . , An : cn }, define: ∨







t

=

{A1 : c1 , . . . , An : cn } , a tuple over U ; and



=

{A1 : c1 , . . . , An : cn } , a tuple over U .

t







∨ ∧

A Vianu dynamic functional dependency (VDFD) over U is an FD X → Y over U U such that for each A ∈ Y , ∧ ∨ XA contains at least one attribute from U and one attribute from U . An update over U is a triple hI, µ, Ji, where I and J are relations over U and µ is a bijective mapping from I to ∨ ∧ J. The update hI, µ, Ji satisfies the VDFD X → Y if the action relation { t ∪ s| t ∈ I, s = µ(t)} satisfies the FD X →Y. 2 The notion of VDFD directly extends to sequences of database updates. The interaction between dynamic VDFDs and static FDs is studied in [7]. 2

Temporal Extensions of Functional Dependency Proposed by Wijsen [9, 10, 11, 12] Instead of extending each tuple with its updated version, as is the case for VDFDs, one can take the union of the old relation and the new relation: Name John Smith An Todd Ed Duval John Smith An Todd

Sex M F M M F

Merit Poor Fair Fair Good Good

Sal 10K 10K 10K 12K 12K

> old ⊥

> new ⊥

The company’s policy that “Every change in merit (promotion or demotion) gives rise to a salary change,” is ◦ expressed by Name, Sal → Merit and means that the FD Name, Sal → Merit must be satisfied by the union of the old and the new relation. In particular, since Ed Duval’s salary did not change, his merit cannot have ◦ changed either. Likewise, “The sex of an employee cannot change” is expressed by Name → Sex . The construct ◦ → naturally generalizes to database histories that involve more than two database states. Definition where X, Y A database if for every



A Wijsen dynamic functional dependency (WDFD) over U is an expression of the form X → Y , ⊆ U. ◦ history is a sequence hI1 , I2 , I3 , . . .i, where each Ii is a relation over U . This history satisfies X → Y i ∈ {1, 2, . . . }, Ii ∪ Ii+1 satisfies X → Y . 2

Although Ii+1 can be thought of as the result of an update performed on Ii , there is no need to model a oneone relationship between the tuples of both relations, as was the case for VDFDs. VDFDs and WDFDs capture different types of constraints, even in the presence of some attribute that serves as a time-invariant tuple-identifier. This difference will be illustrated later on in the discussion of constraint-generating dependencies. In practice, database histories will be be stored in relations with timestamped tuples. Like FDs, WDFDs can result ◦ in predictable (i.e. redundant) values. For example, if the following relation has to satisfy Name, Sal → Merit, then the value for the placeholder † must be equal to “Poor.” Wijsen [9] develops temporal variants of 3NF to avoid data redundancy caused by WDFDs. Name Ed Ed

City Paris London

Merit Poor †

Sal 10K 10K

From 1 3

To 2 4

WDFDs can be naturally generalized as follows: instead of interpreting FDs over unions of successive database states, the syntax of FD is extended with a binary relation on the time domain, called time accessibility relation, that indicates which tuple pairs must satisfy the FD. Definition A time accessibility relation (TAR) is a subset of {(i, j) | 1 ≤ i ≤ j}. A generalized WDFD over U is an expression X→α Y , where X, Y ⊆ U and α is a TAR. This generalized WDFD is satisfied by database history hI1 , I2 , I3 , . . .i if for all (i, j) ∈ α, s ∈ Ii , t ∈ Ij , if s[X] = t[X], then s[Y ] = t[Y ]. 2 ◦

If the TAR Next is defined by Next = {(1, 1), (1, 2), (2, 2), (2, 3), (3, 3), (3, 4), . . . }, then X→ Next Y and X → Y are equivalent. TARs can also capture the notion of time granularity. For example, MonthTAR can be defined as the TAR containing (i, j) whenever i ≤ j and time points i, j belong to the same month. Then, Name→ MonthTAR Sal expresses that the salary of an employee cannot change within a month. The temporal functional dependencies proposed in [11] extend this formalism with a notion of identity, denoted by λ, similar to object-identity. The identity is time-invariant and allows to relate old and new versions of the same object. For example, Emp : λ→Next Name means that the name of an employee object cannot change from one time to the next. Trend dependencies [10, 12] extend generalized WDFDs in still another way by allowing both equalities and inequalities. They can be seen as a temporal extension of the concept of order dependency introduced by Ginsburg and Hull [4]. For example, (Name, =)→Next (Sal , ≤) expresses that the salary of an employee cannot decrease. Technically, it is satisfied by a database history hI1 , I2 , I3 , . . .i if for all (i, j) ∈ Next, if s ∈ Ii and t ∈ Ij and s(Name) = t(Name), then s(Sal ) ≤ t(Sal ).

3

Wang et al.’s Temporal Functional Dependency [8] The dynamic versions of FDs introduced by Vianu and Wijsen can impose constraints on tuples valid at successive time points. Wang et al.’s notion of temporal functional dependency (TFD) concentrates on temporal granularity and compares tuples valid during the same granule of some temporal granularity. The main idea is captured by the following definitions that are simplified versions of the ones found in [8]. Definition Assume a linear time domain (D,

Suggest Documents