Presentation is loading. Please wait.

Presentation is loading. Please wait.

The need for Temporal Databases (1)Need for coping with temporal data (both VT and TT) (2)Just adding 1 (or 2, or 4) temporal attributes (and maybe some.

Similar presentations


Presentation on theme: "The need for Temporal Databases (1)Need for coping with temporal data (both VT and TT) (2)Just adding 1 (or 2, or 4) temporal attributes (and maybe some."— Presentation transcript:

1 The need for Temporal Databases (1)Need for coping with temporal data (both VT and TT) (2)Just adding 1 (or 2, or 4) temporal attributes (and maybe some ad-hoc procedures) does not work! (3)First, a rigorous semantic framework is needed, to give formal specification to the implementation. Properties: clearness, expressiveness, upward compatibiliy. Ex. BCDM (4)Second, the implementation must be proven to respect the semantics. Core issue here: efficient (1-NF) implementations hardly grant uniqueness of representation. Ex TSQL2

2 Ad-hoc approaches are complex and are not likely to work Example 1. Projection (and temporal coalescing) NameSalaryTitleVT_startVT_end Andrea60000Ass. Provost1/1/199330/5/1993 Andrea70000Ass. Provost1/6/199330/9/1993 Andrea70000Provost1/10/199331/1/1994 Andrea70000Professor1/2/199431/12/1994 Question: salary history of Andrea “Intuitive” SQL query: SELECT Salary,VT_start,VT_end FROM Employee WHERE Name=“Andrea”

3 Ad-hoc approaches are complex and are not likely to work Result obtained: SalaryVT_startVT_end 600001/1/199330/5/1993 700001/6/199330/9/1993 700001/10/199331/1/1994 700001/2/199431/12/1994 Desired result: SalaryVT_startVT_end 600001/1/199330/5/1993 700001/6/199331/12/1994

4 Ad-hoc approaches are complex and are not likely to work How to get the desired result using SQL92: CREATE TABLE Temp(Salary, VT_start,VT_end) AS SELECT Salary, VT_start, VT_end FROM Employee WHERE Name = “Andrea”; Repeat UPDATE Temp T1 SET (T1.VT_end)=SELECT MAX(T2.VT_end) WHERE T1.Salary=T2.Salary AND T1.VT_start < T2.VT_Start AND T1.VT_end >= T2.VT_start AND T1.VT_end < T2.VT_end WHERE EXISTS (SELECT * FROM Temp AS T2 WHERE T1.Salary=T2.Salary AND T1.VT_start = T2.VT_start AND T1.VT_end < T2.VT_end) Until no tuples updated

5 Ad-hoc approaches are complex and are not likely to work How to get the desired result using SQL92 (continues!): DELETE FROM Temp T1 WHERE EXISTS(SELECT * FROM Temp AS T2 WHERE T1.Salary = T2.Salary AND ((T1.VT_start > T2.VT_Start) AND (T1.VT_end = T2.VT_Start) AND (T1.VT_end < T2.VT_end))

6 Ad-hoc approaches are complex and are not likely to work Underlying semantic phenomenon: Projection on temporal relations involves temporal coalescing about value equivalent tuples When it occurs (SQL): Whenever a proper subset of the attributes of the relations is chosen in the SELECT part of the query

7 Ad-hoc approaches are complex and are not likely to work How to get the desired result using a Temporal DB (ex. TSQL2) SELECT Salary FROM Employee WHERE Name = “Andrea”

8 Ad-hoc approaches are complex and are not likely to work Example 2. Join (and temporal intersection) NameSalaryVT_startVT_end Andrea600001/1/199330/5/1993 Andrea700001/6/199331/12/1994 Employee1 NameTitleVT_startVT_end AndreaAss. Provost1/1/199330/9/1993 AndreaProvost1/10/199331/1/1994 AndreaProfessor1/2/199431/12/1994 Employee2 Query: “combined” history of both Andrea’s salary and title

9 Ad-hoc approaches are complex and are not likely to work “Intuitive” SQL query: SELECT Salary, Title, Emp1.VT_start, Emp1.VT_end Emp2.VT_start, Emp2.VT_end FROM Employee1, Employee2 WHERE Employee1.Name=“Andrea” AND Employee1.Name=“Andrea”

10 Ad-hoc approaches are complex and are not likely to work Result obtained: SalaryEmp1. VT_start Emp1. VT_end TitleEmp2. VT_start Emp2. VT_end 600001/1/199330/5/1993Ass. Provost1/1/199330/9/1993 600001/1/199330/5/1993Provost1/10/199331/1/1994 600001/1/199330/5/1993Professor1/2/199431/12/1994 700001/6/199331/12/1994Ass. Provost1/1/199330/9/1993 700001/6/199331/12/1994Provost1/10/199331/1/1994 700001/6/199331/12/1994Professor1/2/199431/12/1994

11 Ad-hoc approaches are complex and are not likely to work Result desired: SalaryTitleVT_startVT_end 60000Ass. Provost1/1/199330/5/1993 70000Ass. Provost1/6/199330/9/1993 70000Provost1/10/199331/1/1994 70000Professor1/2/199431/12/1994

12 Ad-hoc approaches are complex and are not likely to work How to get the desired result using SQL92: SELECT Employee1.Name,Salary,Dept,Employee1.VT_start,Employee1.VT_end FROM Employee1, Employee2 WHERE Employee1.Name=Employee2.Name AND Employee2.VT_start <= Employee1.VT_start AND Employee1.VT_end < Employee2.VT_end UNION SELECT Employee1.Name,Salary,Dept,Employee1.VT_start,Employee2.VT_end FROM Employee1, Employee2 WHERE Employee1.Name=Employee2.Name AND Employee1.VT_start >= Employee2.VT_start AND Employee2.VT_end < Employee1.VT_end AND Employye1.VT_start < Employee2.VT_end UNION SELECT Employee1.Name,Salary,Dept,Employee2.VT_start,Employee1.VT_end FROM Employee1, Employee2 WHERE Employee1.Name=Employee2.Name AND Employee2.VT_start > Employee2.VT_start AND Employee1.VT_end < Employee2.VT_end AND Employye2.VT_start < Employee1.VT_end UNION SELECT Employee1.Name,Salary,Dept,Employee2.VT_start,Employee2.VT_end FROM Employee1, Employee2 WHERE Employee1.Name=Employee2.Name AND Employee2.VT_start > Employee1.VT_start AND Employee2.VT_end < Employee1.VT_end

13 Ad-hoc approaches are complex and are not likely to work Underlying semantic phenomenon: Join (Cartesian product) on temporal relations involves temporal intersection When it occurs (SQL): Whenever more than one relation is used in the FROM part of the query Note: the number of terms in the SQL union is 2 n, where n is the number of relations in the FROM part

14 Ad-hoc approaches are complex and are not likely to work How to get the desired result using a Temporal DB (ex. TSQL2) SELECT Salary, Title FROM Employee1, Employee2 WHERE Employee1.Name=“Andrea” AND Employee1.Name=“Andrea”

15 Ad-hoc approaches are complex and are not likely to work And what about: - Union, difference, …, nested queries - Temporal predicates - Primary\secondary keys - Aggregate functions - Integrity constraints - Multiple (user-defined!) granularities - …… - arbitrary combinations of all the above issues Until now, just two simple examples concerning: - SELECT a subset of attributes (  loop to do colaescing) - FROM with >1 relations (exponential union to do intersection) ?

16 Ad-hoc approaches are complex and are not likely to work Key message: - Dealing with temporal data is a general problem in DB’s - Difficult problems (often “hidden” ones) have to be faced WHY? (informally) (1)Relational model assumes independence of attribute values Time attributes predicates about when the values of the other attributes hold in the modeled reality (VT) or are current in the DB (TT)

17 Ad-hoc approaches are complex and are not likely to work WHY? (informally) (2)Relational model assumes all data\knowledge is explicit The association of time to tuples involves “semantic assumptions” Such assumptions are part of our “commonsense” way of looking at time. However, they are NOT supported by the relational model (as long as they are left implicit) Making the semantic of time explicit is a complex task (everywhere, not only in DBs)

18 Ad-hoc approaches are complex and are not likely to work From a Software Engeneering point of view: Letting applications solve the problem in an ad-hoc way is: - Both cost and time expensive - Likely to lead to errors in the applications - Likely to make integration (shared data) between applications impossible

19 Ad-hoc approaches are complex and are not likely to work Temporal DB: an area of research aiming at providing once-and-forall principled and integrated solution to the problem


Download ppt "The need for Temporal Databases (1)Need for coping with temporal data (both VT and TT) (2)Just adding 1 (or 2, or 4) temporal attributes (and maybe some."

Similar presentations


Ads by Google