SlideShare une entreprise Scribd logo
1  sur  146
Télécharger pour lire hors ligne
Temporal Databases: Queries
Kristian Torp
Department of Computer Science
Aalborg University
people.cs.aau.dk/˜torp
torp@cs.aau.dk
November 2, 2015
daisy.aau.dk
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 1 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 2 / 122
Learning Goals
Learning Goals
Understand the differences between valid time and transaction time
Understand bitemporal support
Temporal queries: aggregation, join, and timeslicing
Temporal interval and overlap
Note
The four-timestamp data model used is widely supported
n person will make at least n + 1 temporal data models
Words period and interval are central
And switched English versus SQL
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 3 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 4 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 5 / 122
Bitemporal Graphs: Explicit Valid Time
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac
Bill, Prozac
Bill, Prozac
Bill, Morphine
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 6 / 122
Temporal Data: Tabular Overview
pname medicine
Bill Prozac
Bill Morphine
pname medicine vts vte tts tte
Bill Prozac 1 6 1 5
Bill Prozac 1 13 5 8
Bill Prozac 1 9 8 UC
Bill Morphine 10 15 2 UC
Current Bitemporal
pname medicine vts vte
Bill Prozac 1 9
Bill Morphine 10 15
pname medicine tts tte
Bill Prozac 1 5
Bill Prozac 5 8
Bill Prozac 8 UC
Bill Morphine 2 UC
Valid Time Transaction Time
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 7 / 122
Bitemporal Graphs: Implicit Valid Time
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, Shoe Joe, Shoe
Joe, Toy Joe, Toy
Joe, Shoe
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 8 / 122
Overview: Tabular Form
ename dept
Joe Shoe
ename dept vts vte tts tte
Joe Shoe 1 now 1 5
Joe Shoe 1 5 5 UC
Joe Toy 5 now 5 10
Joe Toy 5 10 10 UC
Joe Shoe 10 now 10 UC
Current Bitemporal
ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 10
Joe Shoe 10 now
ename dept tts tte
Joe Shoe 1 5
Joe Toy 5 10
Joe Shoe 10 UC
Valid Time Transaction Time
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 9 / 122
now in Real Life
Examples of now in data
Marriage certificate
Hiring period
Permanent salary benefits
How long you have owned your car/house/dog
Office room allocation
Sickness period
Note
When end-date is uncertain/unknown/unspecified use now
Interpretation of now different valid time and transaction time
Also called until changed (UC) for transaction time
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 10 / 122
Valid Time or Transaction Time?
What do you think?
Reservation time this room this seminar?
The appointments in your calendar?
The timestamps in a GPS log from a vehicle?
The positions that you have held listed on your CV?
File modification timestamp?
TV commercial: “Offer only valid next week!”
Web log?
Mortgage loan period?
Diary?
Bank day/date (tricky)?
Birthday (tricky)?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 11 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 12 / 122
Allen’s Operators
0 1 2 3 4 5 6 7 8 9 10 11 12
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
X
Note
13 cases are complete
How intervals can overlap
The symmetries
Half-open/closed intervals
Does not matter!
All cases have names
Some of them are weird
J.F.Allen CACM 26(11), Nov.
1983
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 13 / 122
Simplified Overlap Operators
Example (Allen)
0 1 2 3 4 5 6 7 8 9 10 11 12
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
X
Example (Simplified)
0 1 2 3 4 5 6 7 8 9 10 11 12
Y Y
Y
Y
Y
Y
X
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 14 / 122
Names Simplified Overlap Operators
Example (Naming)
0 1 2 3 4 5 6 7 8 9 10 11 12
Before After
Left Overlaps
During
Right Overlaps
Total Overlaps
X
Note
These names are not official just used for reference in this
presentation.
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 15 / 122
Five Cases Simplified Overlap Operators
Example (The Cases)
0 1 2 3 4 5 6 7 8 9 10 11 12
Y Y
Y
Y
Y
Y
X
The Boolean Expressions
Case Expression
No Y.vte ≤ X.vts or X.vte ≤ Y.vts
Right X.vts < Y.vts and Y.vts < X.vte
Left X.vts < Y.vte and Y.vte < X.vte
Full Y.vts ≤ X.vts and X.vte ≤ X.vte
Do intervals overlap?
X.vts < Y.vte AND Y.vts < X.vte
Get Overlap
[greatest(X.vte, Y.vte), least(X.vts, Y.vts))
provided that the intervals X and Y overlap
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 16 / 122
Query Types: Current, Sequence, and Non-Sequenced
Note
Current state for backwards compatibility
Sequenced for built-in temporal semantic/support
Non-sequenced for accessing timestamps columns directly
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 17 / 122
Valid Time versus Transaction Time
Exercise
In groups, use 3 minutes to compare valid time and transaction time.
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 18 / 122
Valid Time versus Transaction Time
Exercise
In groups, use 3 minutes to compare valid time and transaction time.
Valid Time
Past, present, and future
User supplied
Supports now
Physical delete
“History correction”
Transaction Time
Past and present
System supplied
Supports now
Logical delete
History preserving (log)
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 18 / 122
Valid Time versus Transaction Time
Exercise
In groups, use 3 minutes to compare valid time and transaction time.
Valid Time
Past, present, and future
User supplied
Supports now
Physical delete
“History correction”
Transaction Time
Past and present
System supplied
Supports now
Logical delete
History preserving (log)
Valid Time for sure if:
Time is into the future
Time can be supplied by the user
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 18 / 122
Summary: Motivation I
Valid, Transaction, and User-Defined Time
Valid time and transaction time are orthogonal
Valid time: Past, present, and future
Can be user-defined (default similar to transaction time)
Transaction time: Past and present
Always system defined
User-defined time (if not valid time or transaction time)
e.g., birthday
Query Types
Current
Sequenced
Non-sequenced
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 19 / 122
Summary: Motivation II
Database Variables
Special variable now
Different semantics valid time and transaction time
Databases do not support variables
now = 9999-12-31 (maximum value of date domain)
Intervals
Timestamps are half-open intervals
Closed intervals +/- 1 therefore more complicated
Overlap between intervals is essential to understand
Not difficult
5 cases to consider
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 20 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 21 / 122
The Idea: One
Example (Emp)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Joe, HR
Kim, HR
Example (Dept)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
HR, 10
Example (Emp Temporal Natural Join Dept)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Joe, HR, 10
Kim, HR, 10
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 22 / 122
The Idea: Two
Example (Emp)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Joe, HR
Kim, HR
Example (Dept)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
HR, 10
HR, 20
Example (Emp Temporal Natural Join Dept)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Joe, HR, 10
Kim, HR, 10
Kim, HR, 20
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 23 / 122
The Idea: Three
Example (Emp)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Joe, HR
Kim, HR
Example (Dept)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
HR, 5
Example (Emp Temporal Natural Join Dept)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 24 / 122
The Idea: Four
Example (Emp)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Joe, HR
Kim, RD
Example (Dept)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
HR, 10
RD, 20
Example (Emp Temporal Natural Join Dept)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Joe, HR, 10
Kim, RD, 10
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 25 / 122
Natural Join Informal Definition
Idea Temporal Natural Join
The explicit attribute must be equal
The intersection of the timestamp intervals must be non-empty
The Overlap Cases to Consider
0 1 2 3 4 5 6 7 8 9 10 11 12
Before After
Left Overlaps
During
Right Overlaps
Total Overlaps
X
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 26 / 122
Temporal Natural-Join Example
select cname , adr , ptype , p . vts , p . vte −− t o t a l overlap
from c u s t v t as c , property vt as p
where c . cid = p . cid
and c . vts <= p . vts and p . vte <= c . vte union
select cname , adr , ptype , c . vts , p . vte −− r i g h t overlap
from c u s t v t as c , property vt as p
where c . cid = p . cid
and c . vts between p . vts and p . vte
and c . vte > p . vte union
select cname , adr , ptype , p . vts , c . vte −− l e f t overlap
from c u s t v t as c , property vt as p
where c . cid = p . cid
and c . vte between p . vts and p . vte
and c . vts < p . vts union −− during
select cname , adr , ptype , c . vts , c . vte
from c u s t v t as c , property vt as p
where c . cid = p . cid
and c . vts between p . vts and p . vte
and c . vte between p . vts and p . vte
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 27 / 122
Quiz: What is the Natural-Join Result
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Bill, support
Pam, sale Pam, RD Pam, RD
Sam, RD
Jim, RD Jim, sale Jim, RD
Tim, web Tim, sale
Tom, sale Tom, test
Joe, RD Joe, sale Joe, RD
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
RD, 50 RD, 60 RD, 80
sale, 10 sale, 20 sale, 25
web, 5
test, 20 test, 15
support, 30
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 28 / 122
Summary: Temporal Join
Main Points
Temporal natural join most widely used
Like in non-temporal databases
Valid-time natural-join complicated because multiple overlap
scenarios to consider
It is possible to join a valid-time table with a non-temporal table
On all rows in the non-temporal table the valid-time is [-forever, forever)
Note
Efficiency may be a problem
Can you see why?
Temporal versions of Cartesian product, outer joins, and equi join are
well-defined
See www.cs.arizona.edu/projects/stagg/papers/TR-71.pdf
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 29 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 30 / 122
The Data Foundation
Query in English
Find the number of persons employed over time and in which intervals.
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Joe, 10 Joe, 12 Joe, 13
Jim, 12 Jim, 14
Jill, 10 Jill, 15
Pat, 9 Pat, 9 Pat, 10
Bill, 9
Boris, 9
Pam, 11
Kurt, 11
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 31 / 122
Constant Regions
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Joe, 10 Joe, 12 Joe, 13
Jim, 12 Jim, 14
Jill, 10 Jill, 15
Pat, 9 Pat, 9 Pat, 10
Bill, 9
Boris, 9
Pam, 11
Kurt, 11
Note
Vertical lines at all vts and vte values
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 32 / 122
The Result
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Joe, 10 Joe, 12 Joe, 13
Jim, 12 Jim, 14
Jill, 10 Jill, 15
Pat, 9 Pat, 9 Pat, 10
Bill, 9
Boris, 9
Pam, 11
Kurt, 11 cnt vts vte
3 1 3
5 3 5
5 5 6
6 6 7
5 7 11
4 11 13
5 13 14
5 14 16
6 16 17
5 17 18
6 18 19
5 19 21
5 21 23
4 23 24
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 33 / 122
Main Idea in Finding Constant Regions
Five cases to consider
No other interval overlaps me
Another interval has vts between my vts and vte
Another interval has vte between my vts and vte
Another interval totally overlaps me
Another interval is after me
Note
For each case there can be no vts or vte between returned result
A single interval can qualify for more than one of the cases above
SQL is declarative therefore ”after” could be ”before”
But just one of the cases can be considered
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 34 / 122
Main Query
Example (The Main Query)
select count (ename) as cnt ,
const regions . vts as vts ,
const regions . vte as vte
from emp vt , const regions
where emp vt . vts < const regions . vte
and const regions . vts < emp vt . vte
group by const regions . vts , const regions . vte
order by vts , vte
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 35 / 122
Constant Regions Part 1: No Overlap
with const regions as (
−− get t1 . vts and t1 . vte
select t1 . vts as vts , t1 . vte as vte
from emp vt t1
where not exists (
select ∗
from emp vt t3
where ( t1 . vts < t3 . vts and t3 . vts < t1 . vte ) or
( t1 . vts < t3 . vte and t3 . vte < t1 . vte ) )
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
result = t1
not exists t3
not exists t3
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 36 / 122
Constant Regions Part 2:
union
−− t1 . vts and t2 . vts
select t1 . vts as vts , t2 . vts as vte
from emp vt t1 , emp vt t2
where t1 . vts < t2 . vts and t2 . vts < t1 . vte
and not exists (
select ∗
from emp vt t3
where ( t1 . vts < t3 . vts and t3 . vts < t2 . vts ) or
( t1 . vts < t3 . vte and t3 . vte < t2 . vts ) )
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
t1
t2
result
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 37 / 122
Constant Regions Part 3:
union
−− t1 . vts and t2 . vte
select t1 . vts as vts , t2 . vte as vte
from emp vt t1 , emp vt t2
where t1 . vts < t2 . vte and t2 . vte < t1 . vte
and not exists (
select ∗
from emp vt t3
where ( t1 . vts < t3 . vts and t3 . vts < t2 . vte ) or
( t1 . vts < t3 . vte and t3 . vte < t2 . vte ) )
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
t1
t2
result
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 38 / 122
Constant Regions Part 4: Before
union
−− t1 . vte and t2 . vts
select t1 . vte as vts , t2 . vts as vte
from emp vt t1 , emp vt t2
where t1 . vte < t2 . vts
and not exists (
select ∗
from emp vt t3
where ( t1 . vte < t3 . vts and t3 . vts < t2 . vts ) or
( t1 . vte < t3 . vte and t3 . vte < t2 . vts ) )
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
t1
t2
result
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 39 / 122
Constant Regions Part 5:
union
−− t1 . vte and t2 . vte
select t1 . vte as vts , t2 . vte as vte
from emp vt t1 , emp vt t2
where t2 . vts < t1 . vte and t1 . vte < t2 . vte
and not exists (
select ∗
from emp vt t3
where ( t1 . vte < t3 . vts and t3 . vts < t2 . vte ) or
( t1 . vte < t3 . vte and t3 . vte < t2 . vte ) ) )
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
t1
t2
result
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 40 / 122
Correctness of Constant Regions
Five = Original row + Four Combinations
[t1.vts, t1.vte)
[t1.vts, t2.vts)
[t1.vts, t2.vte)
[t2.vte, t2.vts)
[t2.vte, t2.vte)
Note
All cases are covered
Informal argument
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 41 / 122
Quiz
Query in English
Find the constant regions and average budget for all departments over
time.
Example (Data Foundation)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
RD, 50 RD, 60 RD, 80
sale, 10 sale, 20 sale, 25
web, 5
test, 20 test, 15
support, 30
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 42 / 122
Quiz: Solution, One
Example (Data Foundation with Dividers)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
RD, 50 RD, 60 RD, 80
sale, 10 sale, 20 sale, 25
web, 5
test, 20 test, 15
support, 30
Rest of Solution
Now we have the constant regions
Next step is to do the aggregation within each region
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 43 / 122
Quiz: Solution, Two
cnt vts vte
50.00 1 4
30.00 4 6
21.67 6 8
21.25 8 10
26.67 10 11
33.33 11 15
33.75 15 16
32.50 16 17
37.50 17 22
45.00 22 24
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
50.00
30.00
21.67
21.25
26.67
33.33
33.75
32.50
37.50
45.00
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 44 / 122
Summary: Aggregation
Main Points
Constant regions must be identified
Can be done in multiple ways
Approach used is consider efficient (allowed to prove me wrong :-))
Due to various ways intervals may overlap the queries are long
Same approach to average, count, minimum, and so on
Note
The approach also works if grouping on non-temporal column
It is an exercise to figure-out how!
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 45 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 46 / 122
Coalescing in Figures
Example (How long have Lars and Peter been with us?)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Lars, web Lars, web
Lars, web
Lars, test Lars, test
Peter, web Peter, test Peter, test
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 47 / 122
Coalescing in Figures
Example (How long have Lars and Peter been with us?)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Lars, web Lars, web
Lars, web
Lars, test Lars, test
Peter, web Peter, test Peter, test
Example (Result)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Lars
Peter
Note
Select just the employee name
Coalescing resulted in fewer rows
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 47 / 122
Coalescing in Figures, cont
Example (How long have the ’web’ and ’test’ projects been active?)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Lars, web Lars, web
Lars, web
Lars, test Lars, test
Peter, web Peter, test Peter, test
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 48 / 122
Coalescing in Figures, cont
Example (How long have the ’web’ and ’test’ projects been active?)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Lars, web Lars, web
Lars, web
Lars, test Lars, test
Peter, web Peter, test Peter, test
Example (Result)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
test
web web
Note
Coalescing gives better overview
Coalescing gives new insight
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 48 / 122
Example: Valid-Time State Data Model
Example (State and Event)
pname vts vte
Bush 1989 1993
Clinton 1993 1997
Clinton 1997 2001
Bush jr. 2001 2005
Bush jr. 2005 2009
Obama 2009 2013
Obama 2013 2017
pname vts vte
Bush 1989 1993
Clinton 1993 2001
Bush jr. 2001 2009
Obama 2009 2017
Questions
Do the tables have the same content?
Does it have anything to do with duplicate elimination?
What can you say about primary keys (tricky)?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 49 / 122
Example: Event Data Model
Example (Similar Content)
pname vts vte
Bush 1989 1993
Clinton 1993 1997
Clinton 1997 2001
Bush jr. 2001 2005
Bush jr. 2005 2009
Obama 2009 2013
Obama 2013 2017
pname vts
Bush 1989
Clinton 1993
Clinton 1997
Bush jr. 2001
Bush jr. 2005
Obama 2009
Obama 2013
pname vts
Bush 1989
Clinton 1993
Bush jr. 2001
Obama 2009
Questions
Any implicit assumptions for state or event table?
Future data any differences?
What are the pros/cons state versus event table?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 50 / 122
Quiz: Coalescing
Questions
How much space can be saved coalescing temporal data?
Informal argument using examples!
Can data in valid-time event tables be un-coalesced?
Informal argument using examples!
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 51 / 122
Quiz: Coalescing
Questions
How much space can be saved coalescing temporal data?
Informal argument using examples!
Can data in valid-time event tables be un-coalesced?
Informal argument using examples!
Answers
The saving coalescing the data stored can be significant. Consider
many overlaps of value equivalent rows.
Event-tables can also be un-coalesced.
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 51 / 122
Advantages and Disadvantages
Coalesced
Minimal space
Row delete info. lost
Queries faster
Less data
Modifications slower
Many checks
Un-coalesced
Additional space
Possibly much larger
Queries slower
More data
Modifications faster
Less checking
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 52 / 122
Coalescing in SQL (Proposed by Celko/Bohlen)
select d i s t i n c t f i . ename, f i . vts , la . vte
from projemp vt f i , projemp vt la
where f i . vts < la . vte
and f i . ename = la . ename
and not exists ( −− ensure no holes and extend towards f i . vts
select ∗
from projemp vt mi
where mi . ename = f i . ename
and f i . vts < mi . vts and mi . vts < la . vte
and not exists (
select ∗
from projemp vt a1
where a1 . ename = f i . ename
and a1 . vts < mi . vts and mi . vts <= a1 . vte ) )
and not exists ( −− ensure only maximal periods
select ∗
from projemp vt a2
where a2 . ename = f i . ename
and ( a2 . vts < f i . vts and f i . vts <= a2 . vte
or a2 . vts <= la . vte and la . vte < a2 . vte ) )
order by f i . ename, f i . vts
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 53 / 122
Quiz: Coalesced?
Example (Is the data coalesced?)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Shoe Joe, Toy
Tom, Shoe Tom, Shoe Tom, Toy
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 54 / 122
Quiz: Coalesced?
Example (Is the data coalesced?)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Shoe Joe, Toy
Tom, Shoe Tom, Shoe Tom, Toy
Example (Is the data coalesced?)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Shoe Joe, Toy
Tom, Shoe
Tom, Toy
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 54 / 122
Questions Related to Coalesced
Questions
Can coalescing increase the number of rows in table?
What happens if you coalesce a table/query twice?
If you make a projection on a coalesce table is the result coalesced?
If you make a selection on a coalesce table is the result coalesced?
Are ename and vts a primary key of a coalesced table?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 55 / 122
Summary: Coalescing
Main Points
Similar to duplicate elimination
also called fold/unfold
Coalesced = uncoalesed is domain specific
Follow the data
Can data be coalesced without information loss?
Note
Avoid making coalescing into “politics” or “religion”
Some persons have strong feelings for/against coalescing
Coalescing is an expensive operation to perform
It is related to duplicate elimination
Nothing to do with the coalesce function
Do you know what this function does?
Additional information on coalescing
timecenter.cs.aau.dk/TimeCenterPublications/TR-9.pdf
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 56 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 57 / 122
Overview
Example (One)
VT
0 1 2 3 4 5 6 7 8 9 10
R
S
R ∪ S
R ∩ S
VT
0 1 2 3 4 5 6 7 8 9 10
R
S
R − S
S − R
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 58 / 122
Overview
Example (One)
VT
0 1 2 3 4 5 6 7 8 9 10
R
S
R ∪ S
R ∩ S
VT
0 1 2 3 4 5 6 7 8 9 10
R
S
R − S
S − R
Example (Two)
VT
0 1 2 3 4 5 6 7 8 9 10
R
S
R ∪ S
R ∩ S
VT
0 1 2 3 4 5 6 7 8 9 10
S
R − S
S − R
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 58 / 122
Overview
Example (One)
VT
0 1 2 3 4 5 6 7 8 9 10
R
S
R ∪ S
R ∩ S
VT
0 1 2 3 4 5 6 7 8 9 10
R
S
R − S
S − R
Example (Two)
VT
0 1 2 3 4 5 6 7 8 9 10
R
S
R ∪ S
R ∩ S
VT
0 1 2 3 4 5 6 7 8 9 10
S
R − S
S − R
Note
Think Venn diagrams
No big surprises!
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 58 / 122
Set Intersection: As Figure
Example (Emp1)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens Jens
Lene Lene
Example (Emp2)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens
Lene Lene
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 59 / 122
Set Intersection: As Figure
Example (Emp1)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens Jens
Lene Lene
Example (Emp2)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens
Lene Lene
Example (Emp1 ∩ Emp2)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens
Lene Lene
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 59 / 122
Set Intersection: As Table
Example (Emp)
ename dept vts vte
Jens RD 0 5
Lene Cust 2 10
Jens Sup 6 15
Jens Cust 16 20
Example (Boss)
ename dept vts vte
Lene Cust 5 9
Jens Cust 17 20
Example (Emp ∩ Boss)
ename dept vts vte
Lene Cust 5 9
Jens Cust 17 20
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 60 / 122
Set Intersection: The Cases
Example (Before)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
empty
Example (After)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
empty
Example (Right Overlap)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (Left Overlap)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (Included)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (Totally Overlaps)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 61 / 122
Set Intersection: Informally
Definition
Explicit columns must be equal
If overlap between the intervals then take the
The largest of the vts values
The smallest of the vte values
Otherwise skip the row
Note
Recall that vts ≤ vte for interval to be valid
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 62 / 122
Set Intersection in SQL
select emp. ename, emp. dept , −− overlap emp and boss
greatest (emp. vts , boss . vts ) as vts ,
least (emp. vte , boss . vte ) as vte
from emp dept vt as emp, bossemp dept vt as boss
where emp. ename = boss . ename and emp. dept = boss . dept
and emp. vts < boss . vte and boss . vts < emp. vte
and greatest (emp. vts , boss . vts ) <= least (emp. vte , boss . vte )
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 63 / 122
Set Union: As Figure
Example (Emp1)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens Jens
Lene Lene
Example (Emp2)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens
Lene Lene
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 64 / 122
Set Union: As Figure
Example (Emp1)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens Jens
Lene Lene
Example (Emp2)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens
Lene Lene
Example (Emp1 ∪ Emp2)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Jens Jens
Lene Lene
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 64 / 122
Set Union: As Table
Example (Emp)
ename dept vts vte
Jens RD 0 5
Lene Cust 2 10
Jens Sup 6 15
Jens Cust 16 20
Example (Boss)
ename dept vts vte
Lene Cust 5 9
Jens Cust 17 20
Example (Emp ∪ Boss)
ename dept vts vte
Jens RD 0 5
Lene Cust 2 10
Jens Sup 6 15
Jens Cust 16 20
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 65 / 122
Set Union: The Cases
Example (Before)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result result
Example (After)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result result
Example (Right Overlap)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (Left Overlap)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (Included)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (Totally Overlaps)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 66 / 122
Set Union: Informally
Definition
Explicit columns must be equal
If overlap between the intervals then take the
The smallest of the vts values
The largest of the vte values
Else take the intervals in the first table,
and take the intervals in the second table
Note
Three cases to consider
Mutual exclusive cases therefore union all between cases
The rows must be snapshot equal, i.e., have the same explicit
columns
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 67 / 122
Set Union in SQL
select emp. ename, emp. dept , −− overlap emp and boss
least (emp. vts , boss . vts ) as vts ,
greatest (emp. vte , boss . vte ) as vte
from emp dept vt as emp, bossemp dept vt as boss
where emp. ename = boss . ename and emp. dept = boss . dept
and emp. vts < boss . vte and boss . vts < emp. vte union a l l
select emp. ename, emp. dept , emp. vts , emp. vte −− emp no overlap
from emp dept vt as emp
where not exists (
select ∗
from bossemp dept vt as b
where emp. ename = b . ename and emp. dept = b . dept
and emp. vts < b . vte and b . vts < emp. vte ) union a l l
select boss . ename, boss . dept , boss . vts , boss . vte −− boss no overlap
from bossemp dept vt as boss
where not exists (
select ∗
from emp dept vt as b
where boss . ename = b . ename and boss . dept = b . dept
and boss . vts < b . vte and b . vts < boss . vte )
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 68 / 122
Set Difference: As Figure
Example (Emp)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Jens, RD Jens, Sup Jens, Cust
Lene, Cust
Example (Boss)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Jens, Cust
Lene, Cust
Example (Emp - Boss)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Jens, RD Jens, Sup Jens, Cust
Lene, Cust Lene, Cust
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 69 / 122
Set Difference: As Table
Example (Emp)
ename dept vts vte
Jens RD 0 5
Lene Cust 2 10
Jens Sup 6 15
Jens Cust 16 20
Example (Boss)
ename dept vts vte
Lene Cust 5 9
Jens Cust 17 20
Example (Emp - Boss)
ename dept vts vte
Jens RD 0 5
Lene Cust 2 5
Lene Cust 9 10
Jens Sup 6 15
Jens Cust 16 17
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 70 / 122
Set Difference: The Cases
Example (Before)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (After)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (Right Overlap)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (Left Overlap)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result
Example (Included)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
result result
Example (Totally Overlaps)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
emp
boss
empty
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 71 / 122
Set Difference: Informally
Definition
Explicit columns must be equal
If overlap between the intervals then
Row with interval [emp.vts, boss.vts) if emp.vts< boss.vts
Row with interval [boss.vte, emp.vte) if boss.vte< emp.vte
Otherwise skip the row
Note
Before or after does not matter
Total overlap does not add rows to the result
During is handled like a combination of left and right overlap
One interval may be split into one or two intervals
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 72 / 122
Set Difference in SQL, Part 1
select emp. ename, emp. dept , emp. vts , emp. vte −− no overlap
from emp dept vt as emp
where not exists (
select ∗
from bossemp dept vt as b
where emp. ename = b . ename and emp. dept = b . dept
and emp. vts < b . vte and b . vts < emp. vte )
union
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 73 / 122
Set Difference in SQL, Part 2
select emp. ename, emp. dept , emp. vts , boss . vts −− r i g h t overlap
from emp dept vt as emp, bossemp dept vt as boss
where emp. ename = boss . ename and emp. dept = boss . dept
and emp. vts < boss . vts and boss . vts < emp. vte and
not exists (
select ∗
from bossemp dept vt as b
where emp. ename = b . ename and emp. dept = b . dept
and emp. vts < b . vte and b . vts < boss . vts )
union
select emp. ename, emp. dept , boss . vte , emp. vte −− l e f t overlap
from emp dept vt as emp, bossemp dept vt as boss
where emp. ename = boss . ename and emp. dept = boss . dept
and boss . vte < emp. vte and emp. vts < boss . vte and
not exists (
select ∗
from bossemp dept vt as b
where emp. ename = b . ename and emp. dept = b . dept
and boss . vte < b . vte and b . vts < emp. vte )
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 74 / 122
Quiz: Set Operations
Questions
R ∪ S = S ∪ R ?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
Quiz: Set Operations
Questions
R ∪ S = S ∪ R ? Yes!
R ∩ S = S ∩ R ?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
Quiz: Set Operations
Questions
R ∪ S = S ∪ R ? Yes!
R ∩ S = S ∩ R ? Yes!
R − S = S − R ?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
Quiz: Set Operations
Questions
R ∪ S = S ∪ R ? Yes!
R ∩ S = S ∩ R ? Yes!
R − S = S − R ? No!
Can R ∪ S return fewer rows than there are in R?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
Quiz: Set Operations
Questions
R ∪ S = S ∪ R ? Yes!
R ∩ S = S ∩ R ? Yes!
R − S = S − R ? No!
Can R ∪ S return fewer rows than there are in R? Yes!
In contrast to the non-temporal version
Can R − S return more rows than there are in R?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
Quiz: Set Operations
Questions
R ∪ S = S ∪ R ? Yes!
R ∩ S = S ∩ R ? Yes!
R − S = S − R ? No!
Can R ∪ S return fewer rows than there are in R? Yes!
In contrast to the non-temporal version
Can R − S return more rows than there are in R? Yes!
In contrast with non-temporal version
Can R ∩ S return more rows than there are in R?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
Quiz: Set Operations
Questions
R ∪ S = S ∪ R ? Yes!
R ∩ S = S ∩ R ? Yes!
R − S = S − R ? No!
Can R ∪ S return fewer rows than there are in R? Yes!
In contrast to the non-temporal version
Can R − S return more rows than there are in R? Yes!
In contrast with non-temporal version
Can R ∩ S return more rows than there are in R? Yes!
In contrast with non-temporal version
Can R − S return an empty result?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
Quiz: Set Operations
Questions
R ∪ S = S ∪ R ? Yes!
R ∩ S = S ∩ R ? Yes!
R − S = S − R ? No!
Can R ∪ S return fewer rows than there are in R? Yes!
In contrast to the non-temporal version
Can R − S return more rows than there are in R? Yes!
In contrast with non-temporal version
Can R ∩ S return more rows than there are in R? Yes!
In contrast with non-temporal version
Can R − S return an empty result? Yes!
Like the non-temporal version!
Can R ∩ S return an empty result?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
Quiz: Set Operations
Questions
R ∪ S = S ∪ R ? Yes!
R ∩ S = S ∩ R ? Yes!
R − S = S − R ? No!
Can R ∪ S return fewer rows than there are in R? Yes!
In contrast to the non-temporal version
Can R − S return more rows than there are in R? Yes!
In contrast with non-temporal version
Can R ∩ S return more rows than there are in R? Yes!
In contrast with non-temporal version
Can R − S return an empty result? Yes!
Like the non-temporal version!
Can R ∩ S return an empty result? Yes!
Like the non-temporal version!
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
Summary: Set Operators
Main Points
No big surprises in how union, intersection, and difference are defined
The size of the result sets may be a surprise!
Set difference is surprisingly difficult
Challenge that single row can be split into two rows
Note
Notation of union compatibility still applies!
Alternative interpretations of the set operators exists
However not in widespread usage
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 76 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 77 / 122
Timeslicing: As a Figure
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Toy
Jim, Toy
Jill, Shoe
Example (In Table Format)
ename dept vts vte
Joe Shoe 2 8
Joe Toy 10 now
Jim Toy 4 14
Jill Shoe 12 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
Timeslicing: As a Figure
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Toy
Jim, Toy
Jill, Shoe
Example (Timeslice at time 1)
ename dept
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
Timeslicing: As a Figure
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Toy
Jim, Toy
Jill, Shoe
Example (Timeslice at time 3)
ename dept
Joe Shoe
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
Timeslicing: As a Figure
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Toy
Jim, Toy
Jill, Shoe
Example (Timeslice at time 9)
ename dept
Jim Toy
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
Timeslicing: As a Figure
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Toy
Jim, Toy
Jill, Shoe
Example (Timeslice at time 13)
ename dept
Joe Toy
Jim Toy
Jill Shoe
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
Timeslicing: As a Figure
Example
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Toy
Jim, Toy
Jill, Shoe
Example (Timeslice at time 20)
ename dept
Joe Toy
Jill Shoe
Note
Timeslicing can be both in valid time and transaction time
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 79 / 122
Current TimeSlice (now = 20)
Example (Content)
ename dept vts vte
Joe Shoe 2 8
Joe Toy 10 now
Jim Toy 4 14
Jill Shoe 12 now
Example (Timeslice)
ename dept
Joe Toy
Jill Shoe
Example (SQL Statement)
select ename, dept
from emp
where vte = 99 −− 99 i s the value used f o r now
Note
Only explicit attributes
SQL statement is simple
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 80 / 122
Timeslice Back in Time 13 (now = 20)
Example (Content)
ename dept vts vte
Joe Shoe 2 8
Joe Toy 10 now
Jim Toy 4 14
Jill Shoe 12 now
Example (Timeslice)
ename dept
Joe Toy
Jim Toy
Jill Shoe
Example (SQL Statement)
select ename, dept
from emp
where vts < 13 and vte >= 13
Note
between cannot be used due to half-open intervals
Query different from current timeslice
SQL statement again simple
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 81 / 122
Summmary: Valid-Time Timeslice
Main Points
Current state most often used
Timeslice back and forward in time same query
SQL statements are simple
Must pick a value for now
Typically 9999-12-30 or 9999-12-31
Transaction-time slicing basically the same as for valid-time
Note
Often current state separated from other data
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 82 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 83 / 122
First Example of Transaction-Time Timeslice
Example (Bitemporal Graph)
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, Shoe Joe, Shoe
Joe, Toy Joe, Toy
Joe, Shoe
Table Content
Content as of time 15
Only one employee, to make graph readable
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 84 / 122
Timeslice at 1
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, Shoe
ename dept vts vte
Joe Shoe 1 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 85 / 122
Timeslice at 2
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, Shoe
ename dept vts vte
Joe Shoe 1 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 86 / 122
Timeslice at 3
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, Shoe
ename dept vts vte
Joe Shoe 1 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 87 / 122
Timeslice at 4
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, Shoe
ename dept vts vte
Joe Shoe 1 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 88 / 122
Timeslice at 5
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, ShoeJoe, Shoe
Joe, Toy
ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 89 / 122
Timeslice at 6
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, ShoeJoe, Shoe
Joe, Toy
ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 90 / 122
Timeslice at 7
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, ShoeJoe, Shoe
Joe, Toy
ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 91 / 122
Timeslice at 8
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, ShoeJoe, Shoe
Joe, Toy
ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 92 / 122
Timeslice at 9
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, ShoeJoe, Shoe
Joe, Toy
ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 93 / 122
Timeslice at 10
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, ShoeJoe, Shoe
Joe, ToyJoe, Toy
Joe, Shoe ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 10
Joe Shoe 10 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 94 / 122
Timeslice at 11
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, ShoeJoe, Shoe
Joe, ToyJoe, Toy
Joe, Shoe ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 10
Joe Shoe 10 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 95 / 122
Timeslice at 12
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, ShoeJoe, Shoe
Joe, ToyJoe, Toy
Joe, Shoe ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 10
Joe Shoe 10 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 96 / 122
Timeslice at 13
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, Shoe Joe, Shoe
Joe, ToyJoe, Toy
Joe, Shoe
ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 10
Joe Shoe 10 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 97 / 122
Timeslice at 14
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, Shoe Joe, Shoe
Joe, ToyJoe, Toy
Joe, Shoe
ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 10
Joe Shoe 10 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 98 / 122
Timeslice at 15
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Joe, Shoe Joe, Shoe
Joe, Toy Joe, Toy
Joe, Shoe
ename dept vts vte
Joe Shoe 1 5
Joe Toy 5 10
Joe Shoe 10 now
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 99 / 122
Summary: First Example
Note that
All previous states retained
Backward compatible (with “plain” SQL)
End-used has supplied no valid-time values
Transaction-time slice contains valid-time columns
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 100 / 122
Second Example of Transaction-Time Timeslice
Example (Bitemporal Graph)
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
Table Content
Content as of time 15
Only one patient
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 101 / 122
Timeslice at 1
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
pname medicin vts vte
Bill Prozac 1 6
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 102 / 122
Timeslice at 2
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 6
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 103 / 122
Timeslice at 3
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 6
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 104 / 122
Timeslice at 4
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 6
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 105 / 122
Timeslice at 5
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 13
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 106 / 122
Timeslice at 6
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 13
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 107 / 122
Timeslice at 7
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 13
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 108 / 122
Timeslice at 8
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 9
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 109 / 122
Timeslice at 9
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 9
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 110 / 122
Timeslice at 10
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 9
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 111 / 122
Timeslice at 11
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 9
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 112 / 122
Timeslice at 12
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 9
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 113 / 122
Timeslice at 13
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 9
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 114 / 122
Timeslice at 14
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 9
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 115 / 122
Timeslice at 15
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
pname medicin vts vte
Bill Prozac 1 9
Bill Morphine 10 15
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 116 / 122
Summary: Second Example
Note that
All previous states retained
Valid-time does not retain your errors!
However, bitemporal does!
Not-backwards compatible (with “plain” SQL)
End-used has supplied all valid-time values
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 117 / 122
Quiz: Does Bill Die?
Example (Medication for Bill)
TT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
VT
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Prozac, Pepper
Bill, Morphine, Jones
Alive or Dead?
If prozac and morphine is a leathal combination does Bill die?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 118 / 122
Summary: Timeslicing
Main Points
Timeslicing see the table as of a point in time
Timeslicing can be both in valid-time and transaction-time
For transaction-time timeslicing only into the past
For valid-time timeslicing both into the past and the future
Timeslicing is a fairly simple SQL select statement
Note
Current timeslice = the database state stored by non-temporal
databases
Physical database design: current timeslice stored separately from
other data
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 119 / 122
Outline
1 Overview and Foundation
Current, Valid Time, Transaction Time, and Bitemporal
Overlap Between Intervals
2 Temporal Join
3 Aggregation
4 Coalescing
5 Set Operators
6 Timeslice
Valid Time
Bitemporal
7 Summary
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 120 / 122
Quiz
Example (Emp Table One)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Toy Joe, Shoe
Tom, Shoe
Tom, Toy
Questions
Were Joe and Tom employed during the same period?
Did Joe and Tom work in the same department at the same time?
Is the data coalesced?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 121 / 122
Quiz
Example (Emp Table Two)
VT
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Joe, Shoe Joe, Toy Joe, Food
Tom, Food
Tom, Shoe
Tom, Toy
Tom, Toy
Questions
Were Joe and Tom employed during the same period?
Did Joe and Tom work in the same department at the same time?
Is the data coalesced?
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 121 / 122
Summary: Main Ideas
Query Types
Time dimensions: valid time, transaction time, and user-defined time
Bitemporal = valid time + transaction time
Query types: current, sequenced, non-sequenced
Extensions of plain SQL: Join, aggregation, set operations
Also projection and selection
New possibilities: Timeslicing
New problems: Coalescing
Intervals overlap, central to understand how works
Not difficult, just many cases
Note
A temporal data model implemented using plain SQL
IBM DB2 10, SQL Server 2015, and TeraData 13.10 have built-in
bitemporal support
Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 122 / 122

Contenu connexe

Tendances

Data Discovery at Databricks with Amundsen
Data Discovery at Databricks with AmundsenData Discovery at Databricks with Amundsen
Data Discovery at Databricks with AmundsenDatabricks
 
Near Real-Time Data Warehousing with Apache Spark and Delta Lake
Near Real-Time Data Warehousing with Apache Spark and Delta LakeNear Real-Time Data Warehousing with Apache Spark and Delta Lake
Near Real-Time Data Warehousing with Apache Spark and Delta LakeDatabricks
 
Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT326) - AWS re:Inv...
Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT326) - AWS re:Inv...Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT326) - AWS re:Inv...
Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT326) - AWS re:Inv...Amazon Web Services
 
Diving into Delta Lake: Unpacking the Transaction Log
Diving into Delta Lake: Unpacking the Transaction LogDiving into Delta Lake: Unpacking the Transaction Log
Diving into Delta Lake: Unpacking the Transaction LogDatabricks
 
Best Practices for Enabling Speculative Execution on Large Scale Platforms
Best Practices for Enabling Speculative Execution on Large Scale PlatformsBest Practices for Enabling Speculative Execution on Large Scale Platforms
Best Practices for Enabling Speculative Execution on Large Scale PlatformsDatabricks
 
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce FundamentalsIntroduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce FundamentalsSkillspeed
 
Advanced Streaming Analytics with Apache Flink and Apache Kafka, Stephan Ewen
Advanced Streaming Analytics with Apache Flink and Apache Kafka, Stephan EwenAdvanced Streaming Analytics with Apache Flink and Apache Kafka, Stephan Ewen
Advanced Streaming Analytics with Apache Flink and Apache Kafka, Stephan Ewenconfluent
 
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudAmazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudNoritaka Sekiyama
 
Making Data Timelier and More Reliable with Lakehouse Technology
Making Data Timelier and More Reliable with Lakehouse TechnologyMaking Data Timelier and More Reliable with Lakehouse Technology
Making Data Timelier and More Reliable with Lakehouse TechnologyMatei Zaharia
 
Flexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache FlinkFlexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache FlinkDataWorks Summit
 
Processing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeekProcessing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeekVenkata Naga Ravi
 
Radical Speed for SQL Queries on Databricks: Photon Under the Hood
Radical Speed for SQL Queries on Databricks: Photon Under the HoodRadical Speed for SQL Queries on Databricks: Photon Under the Hood
Radical Speed for SQL Queries on Databricks: Photon Under the HoodDatabricks
 
Large Scale Lakehouse Implementation Using Structured Streaming
Large Scale Lakehouse Implementation Using Structured StreamingLarge Scale Lakehouse Implementation Using Structured Streaming
Large Scale Lakehouse Implementation Using Structured StreamingDatabricks
 
Near Real-Time Analytics with Apache Spark: Ingestion, ETL, and Interactive Q...
Near Real-Time Analytics with Apache Spark: Ingestion, ETL, and Interactive Q...Near Real-Time Analytics with Apache Spark: Ingestion, ETL, and Interactive Q...
Near Real-Time Analytics with Apache Spark: Ingestion, ETL, and Interactive Q...Databricks
 
Anatomy of a data driven architecture - Tamir Dresher
Anatomy of a data driven architecture - Tamir Dresher   Anatomy of a data driven architecture - Tamir Dresher
Anatomy of a data driven architecture - Tamir Dresher Tamir Dresher
 
Datawarehousing & DSS
Datawarehousing & DSSDatawarehousing & DSS
Datawarehousing & DSSDeepali Raut
 

Tendances (20)

Data Discovery at Databricks with Amundsen
Data Discovery at Databricks with AmundsenData Discovery at Databricks with Amundsen
Data Discovery at Databricks with Amundsen
 
Near Real-Time Data Warehousing with Apache Spark and Delta Lake
Near Real-Time Data Warehousing with Apache Spark and Delta LakeNear Real-Time Data Warehousing with Apache Spark and Delta Lake
Near Real-Time Data Warehousing with Apache Spark and Delta Lake
 
Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT326) - AWS re:Inv...
Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT326) - AWS re:Inv...Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT326) - AWS re:Inv...
Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT326) - AWS re:Inv...
 
Diving into Delta Lake: Unpacking the Transaction Log
Diving into Delta Lake: Unpacking the Transaction LogDiving into Delta Lake: Unpacking the Transaction Log
Diving into Delta Lake: Unpacking the Transaction Log
 
Best Practices for Enabling Speculative Execution on Large Scale Platforms
Best Practices for Enabling Speculative Execution on Large Scale PlatformsBest Practices for Enabling Speculative Execution on Large Scale Platforms
Best Practices for Enabling Speculative Execution on Large Scale Platforms
 
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce FundamentalsIntroduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
 
Advanced Streaming Analytics with Apache Flink and Apache Kafka, Stephan Ewen
Advanced Streaming Analytics with Apache Flink and Apache Kafka, Stephan EwenAdvanced Streaming Analytics with Apache Flink and Apache Kafka, Stephan Ewen
Advanced Streaming Analytics with Apache Flink and Apache Kafka, Stephan Ewen
 
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudAmazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
 
HDFS Analysis for Small Files
HDFS Analysis for Small FilesHDFS Analysis for Small Files
HDFS Analysis for Small Files
 
Making Data Timelier and More Reliable with Lakehouse Technology
Making Data Timelier and More Reliable with Lakehouse TechnologyMaking Data Timelier and More Reliable with Lakehouse Technology
Making Data Timelier and More Reliable with Lakehouse Technology
 
Flexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache FlinkFlexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache Flink
 
Operational Data Vault
Operational Data VaultOperational Data Vault
Operational Data Vault
 
Processing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeekProcessing Large Data with Apache Spark -- HasGeek
Processing Large Data with Apache Spark -- HasGeek
 
Radical Speed for SQL Queries on Databricks: Photon Under the Hood
Radical Speed for SQL Queries on Databricks: Photon Under the HoodRadical Speed for SQL Queries on Databricks: Photon Under the Hood
Radical Speed for SQL Queries on Databricks: Photon Under the Hood
 
Large Scale Lakehouse Implementation Using Structured Streaming
Large Scale Lakehouse Implementation Using Structured StreamingLarge Scale Lakehouse Implementation Using Structured Streaming
Large Scale Lakehouse Implementation Using Structured Streaming
 
Apache Spark Architecture
Apache Spark ArchitectureApache Spark Architecture
Apache Spark Architecture
 
Near Real-Time Analytics with Apache Spark: Ingestion, ETL, and Interactive Q...
Near Real-Time Analytics with Apache Spark: Ingestion, ETL, and Interactive Q...Near Real-Time Analytics with Apache Spark: Ingestion, ETL, and Interactive Q...
Near Real-Time Analytics with Apache Spark: Ingestion, ETL, and Interactive Q...
 
Anatomy of a data driven architecture - Tamir Dresher
Anatomy of a data driven architecture - Tamir Dresher   Anatomy of a data driven architecture - Tamir Dresher
Anatomy of a data driven architecture - Tamir Dresher
 
Datawarehousing & DSS
Datawarehousing & DSSDatawarehousing & DSS
Datawarehousing & DSS
 
Flink Streaming
Flink StreamingFlink Streaming
Flink Streaming
 

En vedette

Temporal Databases: Data Models
Temporal Databases: Data ModelsTemporal Databases: Data Models
Temporal Databases: Data Modelstorp42
 
Temporal
TemporalTemporal
Temporalsunsie
 
SQL/XML on Oracle
SQL/XML on OracleSQL/XML on Oracle
SQL/XML on Oracletorp42
 
An Overview of Temporal Features in SQL:2011
An Overview of Temporal Features in SQL:2011An Overview of Temporal Features in SQL:2011
An Overview of Temporal Features in SQL:2011Craig Baumunk
 
Tracking your data across the fourth dimension
Tracking your data across the fourth dimensionTracking your data across the fourth dimension
Tracking your data across the fourth dimensionJeremy Cook
 
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...Lucas Jellema
 
Temporal Databases: Modifications
Temporal Databases: ModificationsTemporal Databases: Modifications
Temporal Databases: Modificationstorp42
 
Moving object databases
Moving object databasesMoving object databases
Moving object databasesShivangi Gupta
 
Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011sumit_study
 
Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016Stéphane Fréchette
 
Mobile Database
Mobile DatabaseMobile Database
Mobile DatabaseThanh Le
 
R-Trees and Geospatial Data Structures
R-Trees and Geospatial Data StructuresR-Trees and Geospatial Data Structures
R-Trees and Geospatial Data StructuresAmrinder Arora
 
Mobile database security threats
Mobile database security threatsMobile database security threats
Mobile database security threatsAkhil Kumar
 
Mobile Database ,alrazgi
Mobile Database ,alrazgiMobile Database ,alrazgi
Mobile Database ,alrazgialrazgi
 
Emerging DB Technologies
Emerging DB TechnologiesEmerging DB Technologies
Emerging DB TechnologiesTalal Alsubaie
 

En vedette (20)

Temporal Databases: Data Models
Temporal Databases: Data ModelsTemporal Databases: Data Models
Temporal Databases: Data Models
 
Temporal database
Temporal databaseTemporal database
Temporal database
 
Temporal Data
Temporal DataTemporal Data
Temporal Data
 
Temporal
TemporalTemporal
Temporal
 
SQL/XML on Oracle
SQL/XML on OracleSQL/XML on Oracle
SQL/XML on Oracle
 
An Overview of Temporal Features in SQL:2011
An Overview of Temporal Features in SQL:2011An Overview of Temporal Features in SQL:2011
An Overview of Temporal Features in SQL:2011
 
Chapter24
Chapter24Chapter24
Chapter24
 
B-tree & R-tree
B-tree & R-treeB-tree & R-tree
B-tree & R-tree
 
Tracking your data across the fourth dimension
Tracking your data across the fourth dimensionTracking your data across the fourth dimension
Tracking your data across the fourth dimension
 
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
Time is of the essence - The Fourth Dimension in Oracle Database 12c (on Flas...
 
Temporal Databases: Modifications
Temporal Databases: ModificationsTemporal Databases: Modifications
Temporal Databases: Modifications
 
Moving object databases
Moving object databasesMoving object databases
Moving object databases
 
Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011
 
Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016Back to the future - Temporal Table in SQL Server 2016
Back to the future - Temporal Table in SQL Server 2016
 
Mobile Database
Mobile DatabaseMobile Database
Mobile Database
 
R-Trees and Geospatial Data Structures
R-Trees and Geospatial Data StructuresR-Trees and Geospatial Data Structures
R-Trees and Geospatial Data Structures
 
Mobile database security threats
Mobile database security threatsMobile database security threats
Mobile database security threats
 
Mobile Database ,alrazgi
Mobile Database ,alrazgiMobile Database ,alrazgi
Mobile Database ,alrazgi
 
Emerging DB Technologies
Emerging DB TechnologiesEmerging DB Technologies
Emerging DB Technologies
 
NOSQL vs SQL
NOSQL vs SQLNOSQL vs SQL
NOSQL vs SQL
 

Similaire à Temporal Databases: Queries

The Data Analysis Workflow
The Data Analysis WorkflowThe Data Analysis Workflow
The Data Analysis WorkflowJonathanEarley3
 
CSE545 sp23 (2) Streaming Algorithms 2-4.pdf
CSE545 sp23 (2) Streaming Algorithms 2-4.pdfCSE545 sp23 (2) Streaming Algorithms 2-4.pdf
CSE545 sp23 (2) Streaming Algorithms 2-4.pdfAlexanderKyalo3
 
Clogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry Beds
Clogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry BedsClogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry Beds
Clogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry BedsAvishek Choudhury
 
Best practices survey
Best practices surveyBest practices survey
Best practices surveyMrJinx
 
TIE: A Framework for Embedding-based Incremental Temporal Knowledge Graph Com...
TIE: A Framework for Embedding-based Incremental Temporal Knowledge Graph Com...TIE: A Framework for Embedding-based Incremental Temporal Knowledge Graph Com...
TIE: A Framework for Embedding-based Incremental Temporal Knowledge Graph Com...Jiapeng Wu
 
Introduction to XPath
Introduction to XPathIntroduction to XPath
Introduction to XPathtorp42
 
Sustainable development in three newspapers: How does coverage in a particula...
Sustainable development in three newspapers: How does coverage in a particula...Sustainable development in three newspapers: How does coverage in a particula...
Sustainable development in three newspapers: How does coverage in a particula...Mark Boukes (University of Amsterdam)
 
Anil timeline construction
Anil timeline constructionAnil timeline construction
Anil timeline constructionanilcs0405
 
NLP Data Cleansing Based on Linguistic Ontology Constraints
NLP Data Cleansing Based on Linguistic Ontology ConstraintsNLP Data Cleansing Based on Linguistic Ontology Constraints
NLP Data Cleansing Based on Linguistic Ontology ConstraintsDimitris Kontokostas
 

Similaire à Temporal Databases: Queries (10)

The Data Analysis Workflow
The Data Analysis WorkflowThe Data Analysis Workflow
The Data Analysis Workflow
 
CSE545 sp23 (2) Streaming Algorithms 2-4.pdf
CSE545 sp23 (2) Streaming Algorithms 2-4.pdfCSE545 sp23 (2) Streaming Algorithms 2-4.pdf
CSE545 sp23 (2) Streaming Algorithms 2-4.pdf
 
Clogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry Beds
Clogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry BedsClogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry Beds
Clogged Arteries: Discrete Event Simulation Reduces Holds for Telemetry Beds
 
Best practices survey
Best practices surveyBest practices survey
Best practices survey
 
TIE: A Framework for Embedding-based Incremental Temporal Knowledge Graph Com...
TIE: A Framework for Embedding-based Incremental Temporal Knowledge Graph Com...TIE: A Framework for Embedding-based Incremental Temporal Knowledge Graph Com...
TIE: A Framework for Embedding-based Incremental Temporal Knowledge Graph Com...
 
Introduction to XPath
Introduction to XPathIntroduction to XPath
Introduction to XPath
 
Sustainable development in three newspapers: How does coverage in a particula...
Sustainable development in three newspapers: How does coverage in a particula...Sustainable development in three newspapers: How does coverage in a particula...
Sustainable development in three newspapers: How does coverage in a particula...
 
Anil timeline construction
Anil timeline constructionAnil timeline construction
Anil timeline construction
 
Motion And Time Study
Motion And Time StudyMotion And Time Study
Motion And Time Study
 
NLP Data Cleansing Based on Linguistic Ontology Constraints
NLP Data Cleansing Based on Linguistic Ontology ConstraintsNLP Data Cleansing Based on Linguistic Ontology Constraints
NLP Data Cleansing Based on Linguistic Ontology Constraints
 

Plus de torp42

The DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQLThe DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQLtorp42
 
Spatial Indexing
Spatial IndexingSpatial Indexing
Spatial Indexingtorp42
 
XML on SQL Server
XML on SQL ServerXML on SQL Server
XML on SQL Servertorp42
 
Entity-Relationship Diagrams ERD
Entity-Relationship Diagrams ERDEntity-Relationship Diagrams ERD
Entity-Relationship Diagrams ERDtorp42
 
Introduction to DTD
Introduction to DTDIntroduction to DTD
Introduction to DTDtorp42
 
Introduction to XML and Databases
Introduction to XML and DatabasesIntroduction to XML and Databases
Introduction to XML and Databasestorp42
 

Plus de torp42 (6)

The DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQLThe DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
The DE-9IM Matrix in Details using ST_Relate: In Picture and SQL
 
Spatial Indexing
Spatial IndexingSpatial Indexing
Spatial Indexing
 
XML on SQL Server
XML on SQL ServerXML on SQL Server
XML on SQL Server
 
Entity-Relationship Diagrams ERD
Entity-Relationship Diagrams ERDEntity-Relationship Diagrams ERD
Entity-Relationship Diagrams ERD
 
Introduction to DTD
Introduction to DTDIntroduction to DTD
Introduction to DTD
 
Introduction to XML and Databases
Introduction to XML and DatabasesIntroduction to XML and Databases
Introduction to XML and Databases
 

Dernier

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Temporal Databases: Queries

  • 1. Temporal Databases: Queries Kristian Torp Department of Computer Science Aalborg University people.cs.aau.dk/˜torp torp@cs.aau.dk November 2, 2015 daisy.aau.dk Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 1 / 122
  • 2. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 2 / 122
  • 3. Learning Goals Learning Goals Understand the differences between valid time and transaction time Understand bitemporal support Temporal queries: aggregation, join, and timeslicing Temporal interval and overlap Note The four-timestamp data model used is widely supported n person will make at least n + 1 temporal data models Words period and interval are central And switched English versus SQL Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 3 / 122
  • 4. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 4 / 122
  • 5. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 5 / 122
  • 6. Bitemporal Graphs: Explicit Valid Time TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac Bill, Prozac Bill, Prozac Bill, Morphine Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 6 / 122
  • 7. Temporal Data: Tabular Overview pname medicine Bill Prozac Bill Morphine pname medicine vts vte tts tte Bill Prozac 1 6 1 5 Bill Prozac 1 13 5 8 Bill Prozac 1 9 8 UC Bill Morphine 10 15 2 UC Current Bitemporal pname medicine vts vte Bill Prozac 1 9 Bill Morphine 10 15 pname medicine tts tte Bill Prozac 1 5 Bill Prozac 5 8 Bill Prozac 8 UC Bill Morphine 2 UC Valid Time Transaction Time Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 7 / 122
  • 8. Bitemporal Graphs: Implicit Valid Time TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, Shoe Joe, Shoe Joe, Toy Joe, Toy Joe, Shoe Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 8 / 122
  • 9. Overview: Tabular Form ename dept Joe Shoe ename dept vts vte tts tte Joe Shoe 1 now 1 5 Joe Shoe 1 5 5 UC Joe Toy 5 now 5 10 Joe Toy 5 10 10 UC Joe Shoe 10 now 10 UC Current Bitemporal ename dept vts vte Joe Shoe 1 5 Joe Toy 5 10 Joe Shoe 10 now ename dept tts tte Joe Shoe 1 5 Joe Toy 5 10 Joe Shoe 10 UC Valid Time Transaction Time Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 9 / 122
  • 10. now in Real Life Examples of now in data Marriage certificate Hiring period Permanent salary benefits How long you have owned your car/house/dog Office room allocation Sickness period Note When end-date is uncertain/unknown/unspecified use now Interpretation of now different valid time and transaction time Also called until changed (UC) for transaction time Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 10 / 122
  • 11. Valid Time or Transaction Time? What do you think? Reservation time this room this seminar? The appointments in your calendar? The timestamps in a GPS log from a vehicle? The positions that you have held listed on your CV? File modification timestamp? TV commercial: “Offer only valid next week!” Web log? Mortgage loan period? Diary? Bank day/date (tricky)? Birthday (tricky)? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 11 / 122
  • 12. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 12 / 122
  • 13. Allen’s Operators 0 1 2 3 4 5 6 7 8 9 10 11 12 Y Y Y Y Y Y Y Y Y Y Y Y Y X Note 13 cases are complete How intervals can overlap The symmetries Half-open/closed intervals Does not matter! All cases have names Some of them are weird J.F.Allen CACM 26(11), Nov. 1983 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 13 / 122
  • 14. Simplified Overlap Operators Example (Allen) 0 1 2 3 4 5 6 7 8 9 10 11 12 Y Y Y Y Y Y Y Y Y Y Y Y Y X Example (Simplified) 0 1 2 3 4 5 6 7 8 9 10 11 12 Y Y Y Y Y Y X Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 14 / 122
  • 15. Names Simplified Overlap Operators Example (Naming) 0 1 2 3 4 5 6 7 8 9 10 11 12 Before After Left Overlaps During Right Overlaps Total Overlaps X Note These names are not official just used for reference in this presentation. Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 15 / 122
  • 16. Five Cases Simplified Overlap Operators Example (The Cases) 0 1 2 3 4 5 6 7 8 9 10 11 12 Y Y Y Y Y Y X The Boolean Expressions Case Expression No Y.vte ≤ X.vts or X.vte ≤ Y.vts Right X.vts < Y.vts and Y.vts < X.vte Left X.vts < Y.vte and Y.vte < X.vte Full Y.vts ≤ X.vts and X.vte ≤ X.vte Do intervals overlap? X.vts < Y.vte AND Y.vts < X.vte Get Overlap [greatest(X.vte, Y.vte), least(X.vts, Y.vts)) provided that the intervals X and Y overlap Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 16 / 122
  • 17. Query Types: Current, Sequence, and Non-Sequenced Note Current state for backwards compatibility Sequenced for built-in temporal semantic/support Non-sequenced for accessing timestamps columns directly Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 17 / 122
  • 18. Valid Time versus Transaction Time Exercise In groups, use 3 minutes to compare valid time and transaction time. Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 18 / 122
  • 19. Valid Time versus Transaction Time Exercise In groups, use 3 minutes to compare valid time and transaction time. Valid Time Past, present, and future User supplied Supports now Physical delete “History correction” Transaction Time Past and present System supplied Supports now Logical delete History preserving (log) Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 18 / 122
  • 20. Valid Time versus Transaction Time Exercise In groups, use 3 minutes to compare valid time and transaction time. Valid Time Past, present, and future User supplied Supports now Physical delete “History correction” Transaction Time Past and present System supplied Supports now Logical delete History preserving (log) Valid Time for sure if: Time is into the future Time can be supplied by the user Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 18 / 122
  • 21. Summary: Motivation I Valid, Transaction, and User-Defined Time Valid time and transaction time are orthogonal Valid time: Past, present, and future Can be user-defined (default similar to transaction time) Transaction time: Past and present Always system defined User-defined time (if not valid time or transaction time) e.g., birthday Query Types Current Sequenced Non-sequenced Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 19 / 122
  • 22. Summary: Motivation II Database Variables Special variable now Different semantics valid time and transaction time Databases do not support variables now = 9999-12-31 (maximum value of date domain) Intervals Timestamps are half-open intervals Closed intervals +/- 1 therefore more complicated Overlap between intervals is essential to understand Not difficult 5 cases to consider Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 20 / 122
  • 23. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 21 / 122
  • 24. The Idea: One Example (Emp) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Joe, HR Kim, HR Example (Dept) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HR, 10 Example (Emp Temporal Natural Join Dept) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Joe, HR, 10 Kim, HR, 10 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 22 / 122
  • 25. The Idea: Two Example (Emp) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Joe, HR Kim, HR Example (Dept) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HR, 10 HR, 20 Example (Emp Temporal Natural Join Dept) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Joe, HR, 10 Kim, HR, 10 Kim, HR, 20 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 23 / 122
  • 26. The Idea: Three Example (Emp) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Joe, HR Kim, HR Example (Dept) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HR, 5 Example (Emp Temporal Natural Join Dept) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 24 / 122
  • 27. The Idea: Four Example (Emp) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Joe, HR Kim, RD Example (Dept) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HR, 10 RD, 20 Example (Emp Temporal Natural Join Dept) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Joe, HR, 10 Kim, RD, 10 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 25 / 122
  • 28. Natural Join Informal Definition Idea Temporal Natural Join The explicit attribute must be equal The intersection of the timestamp intervals must be non-empty The Overlap Cases to Consider 0 1 2 3 4 5 6 7 8 9 10 11 12 Before After Left Overlaps During Right Overlaps Total Overlaps X Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 26 / 122
  • 29. Temporal Natural-Join Example select cname , adr , ptype , p . vts , p . vte −− t o t a l overlap from c u s t v t as c , property vt as p where c . cid = p . cid and c . vts <= p . vts and p . vte <= c . vte union select cname , adr , ptype , c . vts , p . vte −− r i g h t overlap from c u s t v t as c , property vt as p where c . cid = p . cid and c . vts between p . vts and p . vte and c . vte > p . vte union select cname , adr , ptype , p . vts , c . vte −− l e f t overlap from c u s t v t as c , property vt as p where c . cid = p . cid and c . vte between p . vts and p . vte and c . vts < p . vts union −− during select cname , adr , ptype , c . vts , c . vte from c u s t v t as c , property vt as p where c . cid = p . cid and c . vts between p . vts and p . vte and c . vte between p . vts and p . vte Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 27 / 122
  • 30. Quiz: What is the Natural-Join Result VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Bill, support Pam, sale Pam, RD Pam, RD Sam, RD Jim, RD Jim, sale Jim, RD Tim, web Tim, sale Tom, sale Tom, test Joe, RD Joe, sale Joe, RD VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 RD, 50 RD, 60 RD, 80 sale, 10 sale, 20 sale, 25 web, 5 test, 20 test, 15 support, 30 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 28 / 122
  • 31. Summary: Temporal Join Main Points Temporal natural join most widely used Like in non-temporal databases Valid-time natural-join complicated because multiple overlap scenarios to consider It is possible to join a valid-time table with a non-temporal table On all rows in the non-temporal table the valid-time is [-forever, forever) Note Efficiency may be a problem Can you see why? Temporal versions of Cartesian product, outer joins, and equi join are well-defined See www.cs.arizona.edu/projects/stagg/papers/TR-71.pdf Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 29 / 122
  • 32. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 30 / 122
  • 33. The Data Foundation Query in English Find the number of persons employed over time and in which intervals. Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Joe, 10 Joe, 12 Joe, 13 Jim, 12 Jim, 14 Jill, 10 Jill, 15 Pat, 9 Pat, 9 Pat, 10 Bill, 9 Boris, 9 Pam, 11 Kurt, 11 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 31 / 122
  • 34. Constant Regions Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Joe, 10 Joe, 12 Joe, 13 Jim, 12 Jim, 14 Jill, 10 Jill, 15 Pat, 9 Pat, 9 Pat, 10 Bill, 9 Boris, 9 Pam, 11 Kurt, 11 Note Vertical lines at all vts and vte values Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 32 / 122
  • 35. The Result VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Joe, 10 Joe, 12 Joe, 13 Jim, 12 Jim, 14 Jill, 10 Jill, 15 Pat, 9 Pat, 9 Pat, 10 Bill, 9 Boris, 9 Pam, 11 Kurt, 11 cnt vts vte 3 1 3 5 3 5 5 5 6 6 6 7 5 7 11 4 11 13 5 13 14 5 14 16 6 16 17 5 17 18 6 18 19 5 19 21 5 21 23 4 23 24 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 33 / 122
  • 36. Main Idea in Finding Constant Regions Five cases to consider No other interval overlaps me Another interval has vts between my vts and vte Another interval has vte between my vts and vte Another interval totally overlaps me Another interval is after me Note For each case there can be no vts or vte between returned result A single interval can qualify for more than one of the cases above SQL is declarative therefore ”after” could be ”before” But just one of the cases can be considered Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 34 / 122
  • 37. Main Query Example (The Main Query) select count (ename) as cnt , const regions . vts as vts , const regions . vte as vte from emp vt , const regions where emp vt . vts < const regions . vte and const regions . vts < emp vt . vte group by const regions . vts , const regions . vte order by vts , vte Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 35 / 122
  • 38. Constant Regions Part 1: No Overlap with const regions as ( −− get t1 . vts and t1 . vte select t1 . vts as vts , t1 . vte as vte from emp vt t1 where not exists ( select ∗ from emp vt t3 where ( t1 . vts < t3 . vts and t3 . vts < t1 . vte ) or ( t1 . vts < t3 . vte and t3 . vte < t1 . vte ) ) Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 result = t1 not exists t3 not exists t3 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 36 / 122
  • 39. Constant Regions Part 2: union −− t1 . vts and t2 . vts select t1 . vts as vts , t2 . vts as vte from emp vt t1 , emp vt t2 where t1 . vts < t2 . vts and t2 . vts < t1 . vte and not exists ( select ∗ from emp vt t3 where ( t1 . vts < t3 . vts and t3 . vts < t2 . vts ) or ( t1 . vts < t3 . vte and t3 . vte < t2 . vts ) ) Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 t1 t2 result Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 37 / 122
  • 40. Constant Regions Part 3: union −− t1 . vts and t2 . vte select t1 . vts as vts , t2 . vte as vte from emp vt t1 , emp vt t2 where t1 . vts < t2 . vte and t2 . vte < t1 . vte and not exists ( select ∗ from emp vt t3 where ( t1 . vts < t3 . vts and t3 . vts < t2 . vte ) or ( t1 . vts < t3 . vte and t3 . vte < t2 . vte ) ) Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 t1 t2 result Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 38 / 122
  • 41. Constant Regions Part 4: Before union −− t1 . vte and t2 . vts select t1 . vte as vts , t2 . vts as vte from emp vt t1 , emp vt t2 where t1 . vte < t2 . vts and not exists ( select ∗ from emp vt t3 where ( t1 . vte < t3 . vts and t3 . vts < t2 . vts ) or ( t1 . vte < t3 . vte and t3 . vte < t2 . vts ) ) Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 t1 t2 result Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 39 / 122
  • 42. Constant Regions Part 5: union −− t1 . vte and t2 . vte select t1 . vte as vts , t2 . vte as vte from emp vt t1 , emp vt t2 where t2 . vts < t1 . vte and t1 . vte < t2 . vte and not exists ( select ∗ from emp vt t3 where ( t1 . vte < t3 . vts and t3 . vts < t2 . vte ) or ( t1 . vte < t3 . vte and t3 . vte < t2 . vte ) ) ) Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 t1 t2 result Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 40 / 122
  • 43. Correctness of Constant Regions Five = Original row + Four Combinations [t1.vts, t1.vte) [t1.vts, t2.vts) [t1.vts, t2.vte) [t2.vte, t2.vts) [t2.vte, t2.vte) Note All cases are covered Informal argument Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 41 / 122
  • 44. Quiz Query in English Find the constant regions and average budget for all departments over time. Example (Data Foundation) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 RD, 50 RD, 60 RD, 80 sale, 10 sale, 20 sale, 25 web, 5 test, 20 test, 15 support, 30 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 42 / 122
  • 45. Quiz: Solution, One Example (Data Foundation with Dividers) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 RD, 50 RD, 60 RD, 80 sale, 10 sale, 20 sale, 25 web, 5 test, 20 test, 15 support, 30 Rest of Solution Now we have the constant regions Next step is to do the aggregation within each region Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 43 / 122
  • 46. Quiz: Solution, Two cnt vts vte 50.00 1 4 30.00 4 6 21.67 6 8 21.25 8 10 26.67 10 11 33.33 11 15 33.75 15 16 32.50 16 17 37.50 17 22 45.00 22 24 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 50.00 30.00 21.67 21.25 26.67 33.33 33.75 32.50 37.50 45.00 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 44 / 122
  • 47. Summary: Aggregation Main Points Constant regions must be identified Can be done in multiple ways Approach used is consider efficient (allowed to prove me wrong :-)) Due to various ways intervals may overlap the queries are long Same approach to average, count, minimum, and so on Note The approach also works if grouping on non-temporal column It is an exercise to figure-out how! Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 45 / 122
  • 48. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 46 / 122
  • 49. Coalescing in Figures Example (How long have Lars and Peter been with us?) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Lars, web Lars, web Lars, web Lars, test Lars, test Peter, web Peter, test Peter, test Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 47 / 122
  • 50. Coalescing in Figures Example (How long have Lars and Peter been with us?) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Lars, web Lars, web Lars, web Lars, test Lars, test Peter, web Peter, test Peter, test Example (Result) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Lars Peter Note Select just the employee name Coalescing resulted in fewer rows Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 47 / 122
  • 51. Coalescing in Figures, cont Example (How long have the ’web’ and ’test’ projects been active?) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Lars, web Lars, web Lars, web Lars, test Lars, test Peter, web Peter, test Peter, test Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 48 / 122
  • 52. Coalescing in Figures, cont Example (How long have the ’web’ and ’test’ projects been active?) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Lars, web Lars, web Lars, web Lars, test Lars, test Peter, web Peter, test Peter, test Example (Result) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 test web web Note Coalescing gives better overview Coalescing gives new insight Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 48 / 122
  • 53. Example: Valid-Time State Data Model Example (State and Event) pname vts vte Bush 1989 1993 Clinton 1993 1997 Clinton 1997 2001 Bush jr. 2001 2005 Bush jr. 2005 2009 Obama 2009 2013 Obama 2013 2017 pname vts vte Bush 1989 1993 Clinton 1993 2001 Bush jr. 2001 2009 Obama 2009 2017 Questions Do the tables have the same content? Does it have anything to do with duplicate elimination? What can you say about primary keys (tricky)? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 49 / 122
  • 54. Example: Event Data Model Example (Similar Content) pname vts vte Bush 1989 1993 Clinton 1993 1997 Clinton 1997 2001 Bush jr. 2001 2005 Bush jr. 2005 2009 Obama 2009 2013 Obama 2013 2017 pname vts Bush 1989 Clinton 1993 Clinton 1997 Bush jr. 2001 Bush jr. 2005 Obama 2009 Obama 2013 pname vts Bush 1989 Clinton 1993 Bush jr. 2001 Obama 2009 Questions Any implicit assumptions for state or event table? Future data any differences? What are the pros/cons state versus event table? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 50 / 122
  • 55. Quiz: Coalescing Questions How much space can be saved coalescing temporal data? Informal argument using examples! Can data in valid-time event tables be un-coalesced? Informal argument using examples! Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 51 / 122
  • 56. Quiz: Coalescing Questions How much space can be saved coalescing temporal data? Informal argument using examples! Can data in valid-time event tables be un-coalesced? Informal argument using examples! Answers The saving coalescing the data stored can be significant. Consider many overlaps of value equivalent rows. Event-tables can also be un-coalesced. Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 51 / 122
  • 57. Advantages and Disadvantages Coalesced Minimal space Row delete info. lost Queries faster Less data Modifications slower Many checks Un-coalesced Additional space Possibly much larger Queries slower More data Modifications faster Less checking Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 52 / 122
  • 58. Coalescing in SQL (Proposed by Celko/Bohlen) select d i s t i n c t f i . ename, f i . vts , la . vte from projemp vt f i , projemp vt la where f i . vts < la . vte and f i . ename = la . ename and not exists ( −− ensure no holes and extend towards f i . vts select ∗ from projemp vt mi where mi . ename = f i . ename and f i . vts < mi . vts and mi . vts < la . vte and not exists ( select ∗ from projemp vt a1 where a1 . ename = f i . ename and a1 . vts < mi . vts and mi . vts <= a1 . vte ) ) and not exists ( −− ensure only maximal periods select ∗ from projemp vt a2 where a2 . ename = f i . ename and ( a2 . vts < f i . vts and f i . vts <= a2 . vte or a2 . vts <= la . vte and la . vte < a2 . vte ) ) order by f i . ename, f i . vts Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 53 / 122
  • 59. Quiz: Coalesced? Example (Is the data coalesced?) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Shoe Joe, Toy Tom, Shoe Tom, Shoe Tom, Toy Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 54 / 122
  • 60. Quiz: Coalesced? Example (Is the data coalesced?) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Shoe Joe, Toy Tom, Shoe Tom, Shoe Tom, Toy Example (Is the data coalesced?) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Shoe Joe, Toy Tom, Shoe Tom, Toy Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 54 / 122
  • 61. Questions Related to Coalesced Questions Can coalescing increase the number of rows in table? What happens if you coalesce a table/query twice? If you make a projection on a coalesce table is the result coalesced? If you make a selection on a coalesce table is the result coalesced? Are ename and vts a primary key of a coalesced table? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 55 / 122
  • 62. Summary: Coalescing Main Points Similar to duplicate elimination also called fold/unfold Coalesced = uncoalesed is domain specific Follow the data Can data be coalesced without information loss? Note Avoid making coalescing into “politics” or “religion” Some persons have strong feelings for/against coalescing Coalescing is an expensive operation to perform It is related to duplicate elimination Nothing to do with the coalesce function Do you know what this function does? Additional information on coalescing timecenter.cs.aau.dk/TimeCenterPublications/TR-9.pdf Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 56 / 122
  • 63. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 57 / 122
  • 64. Overview Example (One) VT 0 1 2 3 4 5 6 7 8 9 10 R S R ∪ S R ∩ S VT 0 1 2 3 4 5 6 7 8 9 10 R S R − S S − R Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 58 / 122
  • 65. Overview Example (One) VT 0 1 2 3 4 5 6 7 8 9 10 R S R ∪ S R ∩ S VT 0 1 2 3 4 5 6 7 8 9 10 R S R − S S − R Example (Two) VT 0 1 2 3 4 5 6 7 8 9 10 R S R ∪ S R ∩ S VT 0 1 2 3 4 5 6 7 8 9 10 S R − S S − R Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 58 / 122
  • 66. Overview Example (One) VT 0 1 2 3 4 5 6 7 8 9 10 R S R ∪ S R ∩ S VT 0 1 2 3 4 5 6 7 8 9 10 R S R − S S − R Example (Two) VT 0 1 2 3 4 5 6 7 8 9 10 R S R ∪ S R ∩ S VT 0 1 2 3 4 5 6 7 8 9 10 S R − S S − R Note Think Venn diagrams No big surprises! Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 58 / 122
  • 67. Set Intersection: As Figure Example (Emp1) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Jens Lene Lene Example (Emp2) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Lene Lene Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 59 / 122
  • 68. Set Intersection: As Figure Example (Emp1) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Jens Lene Lene Example (Emp2) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Lene Lene Example (Emp1 ∩ Emp2) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Lene Lene Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 59 / 122
  • 69. Set Intersection: As Table Example (Emp) ename dept vts vte Jens RD 0 5 Lene Cust 2 10 Jens Sup 6 15 Jens Cust 16 20 Example (Boss) ename dept vts vte Lene Cust 5 9 Jens Cust 17 20 Example (Emp ∩ Boss) ename dept vts vte Lene Cust 5 9 Jens Cust 17 20 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 60 / 122
  • 70. Set Intersection: The Cases Example (Before) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss empty Example (After) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss empty Example (Right Overlap) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (Left Overlap) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (Included) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (Totally Overlaps) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 61 / 122
  • 71. Set Intersection: Informally Definition Explicit columns must be equal If overlap between the intervals then take the The largest of the vts values The smallest of the vte values Otherwise skip the row Note Recall that vts ≤ vte for interval to be valid Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 62 / 122
  • 72. Set Intersection in SQL select emp. ename, emp. dept , −− overlap emp and boss greatest (emp. vts , boss . vts ) as vts , least (emp. vte , boss . vte ) as vte from emp dept vt as emp, bossemp dept vt as boss where emp. ename = boss . ename and emp. dept = boss . dept and emp. vts < boss . vte and boss . vts < emp. vte and greatest (emp. vts , boss . vts ) <= least (emp. vte , boss . vte ) Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 63 / 122
  • 73. Set Union: As Figure Example (Emp1) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Jens Lene Lene Example (Emp2) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Lene Lene Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 64 / 122
  • 74. Set Union: As Figure Example (Emp1) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Jens Lene Lene Example (Emp2) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Lene Lene Example (Emp1 ∪ Emp2) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Jens Jens Lene Lene Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 64 / 122
  • 75. Set Union: As Table Example (Emp) ename dept vts vte Jens RD 0 5 Lene Cust 2 10 Jens Sup 6 15 Jens Cust 16 20 Example (Boss) ename dept vts vte Lene Cust 5 9 Jens Cust 17 20 Example (Emp ∪ Boss) ename dept vts vte Jens RD 0 5 Lene Cust 2 10 Jens Sup 6 15 Jens Cust 16 20 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 65 / 122
  • 76. Set Union: The Cases Example (Before) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result result Example (After) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result result Example (Right Overlap) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (Left Overlap) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (Included) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (Totally Overlaps) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 66 / 122
  • 77. Set Union: Informally Definition Explicit columns must be equal If overlap between the intervals then take the The smallest of the vts values The largest of the vte values Else take the intervals in the first table, and take the intervals in the second table Note Three cases to consider Mutual exclusive cases therefore union all between cases The rows must be snapshot equal, i.e., have the same explicit columns Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 67 / 122
  • 78. Set Union in SQL select emp. ename, emp. dept , −− overlap emp and boss least (emp. vts , boss . vts ) as vts , greatest (emp. vte , boss . vte ) as vte from emp dept vt as emp, bossemp dept vt as boss where emp. ename = boss . ename and emp. dept = boss . dept and emp. vts < boss . vte and boss . vts < emp. vte union a l l select emp. ename, emp. dept , emp. vts , emp. vte −− emp no overlap from emp dept vt as emp where not exists ( select ∗ from bossemp dept vt as b where emp. ename = b . ename and emp. dept = b . dept and emp. vts < b . vte and b . vts < emp. vte ) union a l l select boss . ename, boss . dept , boss . vts , boss . vte −− boss no overlap from bossemp dept vt as boss where not exists ( select ∗ from emp dept vt as b where boss . ename = b . ename and boss . dept = b . dept and boss . vts < b . vte and b . vts < boss . vte ) −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 68 / 122
  • 79. Set Difference: As Figure Example (Emp) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Jens, RD Jens, Sup Jens, Cust Lene, Cust Example (Boss) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Jens, Cust Lene, Cust Example (Emp - Boss) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Jens, RD Jens, Sup Jens, Cust Lene, Cust Lene, Cust Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 69 / 122
  • 80. Set Difference: As Table Example (Emp) ename dept vts vte Jens RD 0 5 Lene Cust 2 10 Jens Sup 6 15 Jens Cust 16 20 Example (Boss) ename dept vts vte Lene Cust 5 9 Jens Cust 17 20 Example (Emp - Boss) ename dept vts vte Jens RD 0 5 Lene Cust 2 5 Lene Cust 9 10 Jens Sup 6 15 Jens Cust 16 17 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 70 / 122
  • 81. Set Difference: The Cases Example (Before) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (After) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (Right Overlap) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (Left Overlap) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result Example (Included) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss result result Example (Totally Overlaps) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 emp boss empty Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 71 / 122
  • 82. Set Difference: Informally Definition Explicit columns must be equal If overlap between the intervals then Row with interval [emp.vts, boss.vts) if emp.vts< boss.vts Row with interval [boss.vte, emp.vte) if boss.vte< emp.vte Otherwise skip the row Note Before or after does not matter Total overlap does not add rows to the result During is handled like a combination of left and right overlap One interval may be split into one or two intervals Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 72 / 122
  • 83. Set Difference in SQL, Part 1 select emp. ename, emp. dept , emp. vts , emp. vte −− no overlap from emp dept vt as emp where not exists ( select ∗ from bossemp dept vt as b where emp. ename = b . ename and emp. dept = b . dept and emp. vts < b . vte and b . vts < emp. vte ) union Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 73 / 122
  • 84. Set Difference in SQL, Part 2 select emp. ename, emp. dept , emp. vts , boss . vts −− r i g h t overlap from emp dept vt as emp, bossemp dept vt as boss where emp. ename = boss . ename and emp. dept = boss . dept and emp. vts < boss . vts and boss . vts < emp. vte and not exists ( select ∗ from bossemp dept vt as b where emp. ename = b . ename and emp. dept = b . dept and emp. vts < b . vte and b . vts < boss . vts ) union select emp. ename, emp. dept , boss . vte , emp. vte −− l e f t overlap from emp dept vt as emp, bossemp dept vt as boss where emp. ename = boss . ename and emp. dept = boss . dept and boss . vte < emp. vte and emp. vts < boss . vte and not exists ( select ∗ from bossemp dept vt as b where emp. ename = b . ename and emp. dept = b . dept and boss . vte < b . vte and b . vts < emp. vte ) Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 74 / 122
  • 85. Quiz: Set Operations Questions R ∪ S = S ∪ R ? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
  • 86. Quiz: Set Operations Questions R ∪ S = S ∪ R ? Yes! R ∩ S = S ∩ R ? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
  • 87. Quiz: Set Operations Questions R ∪ S = S ∪ R ? Yes! R ∩ S = S ∩ R ? Yes! R − S = S − R ? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
  • 88. Quiz: Set Operations Questions R ∪ S = S ∪ R ? Yes! R ∩ S = S ∩ R ? Yes! R − S = S − R ? No! Can R ∪ S return fewer rows than there are in R? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
  • 89. Quiz: Set Operations Questions R ∪ S = S ∪ R ? Yes! R ∩ S = S ∩ R ? Yes! R − S = S − R ? No! Can R ∪ S return fewer rows than there are in R? Yes! In contrast to the non-temporal version Can R − S return more rows than there are in R? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
  • 90. Quiz: Set Operations Questions R ∪ S = S ∪ R ? Yes! R ∩ S = S ∩ R ? Yes! R − S = S − R ? No! Can R ∪ S return fewer rows than there are in R? Yes! In contrast to the non-temporal version Can R − S return more rows than there are in R? Yes! In contrast with non-temporal version Can R ∩ S return more rows than there are in R? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
  • 91. Quiz: Set Operations Questions R ∪ S = S ∪ R ? Yes! R ∩ S = S ∩ R ? Yes! R − S = S − R ? No! Can R ∪ S return fewer rows than there are in R? Yes! In contrast to the non-temporal version Can R − S return more rows than there are in R? Yes! In contrast with non-temporal version Can R ∩ S return more rows than there are in R? Yes! In contrast with non-temporal version Can R − S return an empty result? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
  • 92. Quiz: Set Operations Questions R ∪ S = S ∪ R ? Yes! R ∩ S = S ∩ R ? Yes! R − S = S − R ? No! Can R ∪ S return fewer rows than there are in R? Yes! In contrast to the non-temporal version Can R − S return more rows than there are in R? Yes! In contrast with non-temporal version Can R ∩ S return more rows than there are in R? Yes! In contrast with non-temporal version Can R − S return an empty result? Yes! Like the non-temporal version! Can R ∩ S return an empty result? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
  • 93. Quiz: Set Operations Questions R ∪ S = S ∪ R ? Yes! R ∩ S = S ∩ R ? Yes! R − S = S − R ? No! Can R ∪ S return fewer rows than there are in R? Yes! In contrast to the non-temporal version Can R − S return more rows than there are in R? Yes! In contrast with non-temporal version Can R ∩ S return more rows than there are in R? Yes! In contrast with non-temporal version Can R − S return an empty result? Yes! Like the non-temporal version! Can R ∩ S return an empty result? Yes! Like the non-temporal version! Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 75 / 122
  • 94. Summary: Set Operators Main Points No big surprises in how union, intersection, and difference are defined The size of the result sets may be a surprise! Set difference is surprisingly difficult Challenge that single row can be split into two rows Note Notation of union compatibility still applies! Alternative interpretations of the set operators exists However not in widespread usage Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 76 / 122
  • 95. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 77 / 122
  • 96. Timeslicing: As a Figure Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Toy Jim, Toy Jill, Shoe Example (In Table Format) ename dept vts vte Joe Shoe 2 8 Joe Toy 10 now Jim Toy 4 14 Jill Shoe 12 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
  • 97. Timeslicing: As a Figure Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Toy Jim, Toy Jill, Shoe Example (Timeslice at time 1) ename dept Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
  • 98. Timeslicing: As a Figure Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Toy Jim, Toy Jill, Shoe Example (Timeslice at time 3) ename dept Joe Shoe Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
  • 99. Timeslicing: As a Figure Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Toy Jim, Toy Jill, Shoe Example (Timeslice at time 9) ename dept Jim Toy Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
  • 100. Timeslicing: As a Figure Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Toy Jim, Toy Jill, Shoe Example (Timeslice at time 13) ename dept Joe Toy Jim Toy Jill Shoe Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
  • 101. Timeslicing: As a Figure Example VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Toy Jim, Toy Jill, Shoe Example (Timeslice at time 20) ename dept Joe Toy Jill Shoe Note Timeslicing can be both in valid time and transaction time Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 78 / 122
  • 102. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 79 / 122
  • 103. Current TimeSlice (now = 20) Example (Content) ename dept vts vte Joe Shoe 2 8 Joe Toy 10 now Jim Toy 4 14 Jill Shoe 12 now Example (Timeslice) ename dept Joe Toy Jill Shoe Example (SQL Statement) select ename, dept from emp where vte = 99 −− 99 i s the value used f o r now Note Only explicit attributes SQL statement is simple Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 80 / 122
  • 104. Timeslice Back in Time 13 (now = 20) Example (Content) ename dept vts vte Joe Shoe 2 8 Joe Toy 10 now Jim Toy 4 14 Jill Shoe 12 now Example (Timeslice) ename dept Joe Toy Jim Toy Jill Shoe Example (SQL Statement) select ename, dept from emp where vts < 13 and vte >= 13 Note between cannot be used due to half-open intervals Query different from current timeslice SQL statement again simple Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 81 / 122
  • 105. Summmary: Valid-Time Timeslice Main Points Current state most often used Timeslice back and forward in time same query SQL statements are simple Must pick a value for now Typically 9999-12-30 or 9999-12-31 Transaction-time slicing basically the same as for valid-time Note Often current state separated from other data Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 82 / 122
  • 106. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 83 / 122
  • 107. First Example of Transaction-Time Timeslice Example (Bitemporal Graph) TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, Shoe Joe, Shoe Joe, Toy Joe, Toy Joe, Shoe Table Content Content as of time 15 Only one employee, to make graph readable Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 84 / 122
  • 108. Timeslice at 1 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, Shoe ename dept vts vte Joe Shoe 1 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 85 / 122
  • 109. Timeslice at 2 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, Shoe ename dept vts vte Joe Shoe 1 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 86 / 122
  • 110. Timeslice at 3 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, Shoe ename dept vts vte Joe Shoe 1 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 87 / 122
  • 111. Timeslice at 4 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, Shoe ename dept vts vte Joe Shoe 1 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 88 / 122
  • 112. Timeslice at 5 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, ShoeJoe, Shoe Joe, Toy ename dept vts vte Joe Shoe 1 5 Joe Toy 5 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 89 / 122
  • 113. Timeslice at 6 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, ShoeJoe, Shoe Joe, Toy ename dept vts vte Joe Shoe 1 5 Joe Toy 5 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 90 / 122
  • 114. Timeslice at 7 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, ShoeJoe, Shoe Joe, Toy ename dept vts vte Joe Shoe 1 5 Joe Toy 5 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 91 / 122
  • 115. Timeslice at 8 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, ShoeJoe, Shoe Joe, Toy ename dept vts vte Joe Shoe 1 5 Joe Toy 5 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 92 / 122
  • 116. Timeslice at 9 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, ShoeJoe, Shoe Joe, Toy ename dept vts vte Joe Shoe 1 5 Joe Toy 5 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 93 / 122
  • 117. Timeslice at 10 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, ShoeJoe, Shoe Joe, ToyJoe, Toy Joe, Shoe ename dept vts vte Joe Shoe 1 5 Joe Toy 5 10 Joe Shoe 10 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 94 / 122
  • 118. Timeslice at 11 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, ShoeJoe, Shoe Joe, ToyJoe, Toy Joe, Shoe ename dept vts vte Joe Shoe 1 5 Joe Toy 5 10 Joe Shoe 10 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 95 / 122
  • 119. Timeslice at 12 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, ShoeJoe, Shoe Joe, ToyJoe, Toy Joe, Shoe ename dept vts vte Joe Shoe 1 5 Joe Toy 5 10 Joe Shoe 10 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 96 / 122
  • 120. Timeslice at 13 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, Shoe Joe, Shoe Joe, ToyJoe, Toy Joe, Shoe ename dept vts vte Joe Shoe 1 5 Joe Toy 5 10 Joe Shoe 10 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 97 / 122
  • 121. Timeslice at 14 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, Shoe Joe, Shoe Joe, ToyJoe, Toy Joe, Shoe ename dept vts vte Joe Shoe 1 5 Joe Toy 5 10 Joe Shoe 10 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 98 / 122
  • 122. Timeslice at 15 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Joe, Shoe Joe, Shoe Joe, Toy Joe, Toy Joe, Shoe ename dept vts vte Joe Shoe 1 5 Joe Toy 5 10 Joe Shoe 10 now Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 99 / 122
  • 123. Summary: First Example Note that All previous states retained Backward compatible (with “plain” SQL) End-used has supplied no valid-time values Transaction-time slice contains valid-time columns Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 100 / 122
  • 124. Second Example of Transaction-Time Timeslice Example (Bitemporal Graph) TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones Table Content Content as of time 15 Only one patient Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 101 / 122
  • 125. Timeslice at 1 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper pname medicin vts vte Bill Prozac 1 6 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 102 / 122
  • 126. Timeslice at 2 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 6 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 103 / 122
  • 127. Timeslice at 3 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 6 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 104 / 122
  • 128. Timeslice at 4 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 6 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 105 / 122
  • 129. Timeslice at 5 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 13 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 106 / 122
  • 130. Timeslice at 6 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 13 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 107 / 122
  • 131. Timeslice at 7 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 13 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 108 / 122
  • 132. Timeslice at 8 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 9 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 109 / 122
  • 133. Timeslice at 9 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 9 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 110 / 122
  • 134. Timeslice at 10 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 9 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 111 / 122
  • 135. Timeslice at 11 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 9 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 112 / 122
  • 136. Timeslice at 12 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 9 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 113 / 122
  • 137. Timeslice at 13 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 9 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 114 / 122
  • 138. Timeslice at 14 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 9 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 115 / 122
  • 139. Timeslice at 15 TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones pname medicin vts vte Bill Prozac 1 9 Bill Morphine 10 15 Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 116 / 122
  • 140. Summary: Second Example Note that All previous states retained Valid-time does not retain your errors! However, bitemporal does! Not-backwards compatible (with “plain” SQL) End-used has supplied all valid-time values Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 117 / 122
  • 141. Quiz: Does Bill Die? Example (Medication for Bill) TT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Prozac, Pepper Bill, Morphine, Jones Alive or Dead? If prozac and morphine is a leathal combination does Bill die? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 118 / 122
  • 142. Summary: Timeslicing Main Points Timeslicing see the table as of a point in time Timeslicing can be both in valid-time and transaction-time For transaction-time timeslicing only into the past For valid-time timeslicing both into the past and the future Timeslicing is a fairly simple SQL select statement Note Current timeslice = the database state stored by non-temporal databases Physical database design: current timeslice stored separately from other data Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 119 / 122
  • 143. Outline 1 Overview and Foundation Current, Valid Time, Transaction Time, and Bitemporal Overlap Between Intervals 2 Temporal Join 3 Aggregation 4 Coalescing 5 Set Operators 6 Timeslice Valid Time Bitemporal 7 Summary Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 120 / 122
  • 144. Quiz Example (Emp Table One) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Toy Joe, Shoe Tom, Shoe Tom, Toy Questions Were Joe and Tom employed during the same period? Did Joe and Tom work in the same department at the same time? Is the data coalesced? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 121 / 122
  • 145. Quiz Example (Emp Table Two) VT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Joe, Shoe Joe, Toy Joe, Food Tom, Food Tom, Shoe Tom, Toy Tom, Toy Questions Were Joe and Tom employed during the same period? Did Joe and Tom work in the same department at the same time? Is the data coalesced? Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 121 / 122
  • 146. Summary: Main Ideas Query Types Time dimensions: valid time, transaction time, and user-defined time Bitemporal = valid time + transaction time Query types: current, sequenced, non-sequenced Extensions of plain SQL: Join, aggregation, set operations Also projection and selection New possibilities: Timeslicing New problems: Coalescing Intervals overlap, central to understand how works Not difficult, just many cases Note A temporal data model implemented using plain SQL IBM DB2 10, SQL Server 2015, and TeraData 13.10 have built-in bitemporal support Kristian Torp (Aalborg University) Temporal Databases: Queries November 2, 2015 122 / 122