tsql 2 : query language for temporal data
DESCRIPTION
TSQL 2 : Query Language for Temporal DatA. CS 224 : Advanced Topics in Data Management. tem·po·ral : . of or pertaining to time. Introduction. Element of TIME in DB Queries like… What happened at that time? (Simple) e.g What was Mark’s salary when he joined? - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/1.jpg)
TSQL 2 : QUERY LANGUAGE FOR TEMPORAL DATA
CS 224 : Advanced Topics in Data Management
![Page 2: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/2.jpg)
of or pertaining to time
tem·po·ral :
![Page 3: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/3.jpg)
Introduction
Element of TIME in DB Queries like… What happened at that time? (Simple)
e.g What was Mark’s salary when he joined?
What has happened from then till now? (Complex) e.g Which employees got a raise in past year?
![Page 4: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/4.jpg)
Terminology
VALID TIME of a fact; is the time in the real world when the fact is valid
TRANSACTION TIME of a fact: when it was recorded in the database
![Page 5: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/5.jpg)
Types of Relation
SNAPSHOT relation Standard database
VALID-TIME (historical) relation - When did it rain? When did the soccer world cup happen?
TRANSACTION-TIME(rollback) relation – What was Tom’s salary on October 1?
BI – TEMPORAL relation Supports both valid time and transaction time
![Page 6: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/6.jpg)
is a database (DBMS) that supports valid time and/or transaction time
Temporal database (DBMS)
![Page 7: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/7.jpg)
Time Dimension: Temporal Relations
Snapshot relation
Valid-time relation
Transaction-time relation
Bitemporal relation
![Page 8: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/8.jpg)
Bi-Temporal Data
Jake hiring – reflects single hiring but changes in the modeled reality and the transaction time
![Page 9: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/9.jpg)
QUICK TOUR
TSQL2 (Valid-Time Relation)
![Page 10: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/10.jpg)
Valid-Time Relation
VALIDTIME : At each point in time…. POINT: DATE in above example…
![Page 11: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/11.jpg)
Valid-Time Relation
LIST ALL EMPLOYES WHO WERE NOT MANAGERS
VALIDTIME : At each point in time…. POINT: DATE in above example…
![Page 12: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/12.jpg)
Valid-Time Relation
EXTRACT THE SIZE HISTORY OF THE DEPARTMENT
VALIDTIME : At each point in time…. POINT: DATE in above example…
![Page 13: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/13.jpg)
Valid-Time Relation
CHANGE THE MANAGER OF TOOLS DEPT FOR 1994 to BOB
VALIDTIME : At each point in time…. POINT: DATE in above example…
![Page 14: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/14.jpg)
How to think about it?
TSQL2 (Validtime Relation)
![Page 15: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/15.jpg)
SNAPSHOT RELATION
q: STANDARD SQL QUERY
![Page 16: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/16.jpg)
SNAPSHOT RELATION
![Page 17: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/17.jpg)
TEMPORAL (Valid-Time) RELATION
q: STANDARD SQL QUERY
![Page 18: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/18.jpg)
TEMPORAL (Valid-Time) RELATION
![Page 19: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/19.jpg)
TEMPORAL (Valid-Time) RELATION
q: HISTORICAL TSQL QUERY : Give history of monthly salaries paid to employees (Sequence Query)
![Page 20: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/20.jpg)
TEMPORAL (Valid-Time) RELATION
![Page 21: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/21.jpg)
TEMPORAL (Valid-Time) RELATION
u: TSQL UPDATE QUERY : Change the town named ‘ TUSCON ‘ to ‘ TUCSON’ (Sequence Query)
![Page 22: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/22.jpg)
TEMPORAL (Valid-Time) RELATION
![Page 23: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/23.jpg)
TEMPORAL (Valid-Time) RELATION
q: Who was given SALARY raises ? (Non Sequence Query)
![Page 24: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/24.jpg)
TEMPORAL (Valid-Time) RELATION
![Page 25: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/25.jpg)
TEMPORAL (Valid-Time) RELATION
U: Give employees 5% raise if they never had a raise before? (Non Sequence Query)
![Page 26: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/26.jpg)
TEMPORAL (Valid-Time) RELATION
![Page 27: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/27.jpg)
TEMPORAL (Valid-Time) RELATION
![Page 28: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/28.jpg)
Problem Definition
TSQL2(Transaction Time)
![Page 29: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/29.jpg)
Transaction Time
What is the need? Applications need to keep track of the past
states of the database, often for auditing requirements
Changes are not allowed on the past states; that would prevent secure auditing. Instead, compensating transactions are used to correct errors.
![Page 30: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/30.jpg)
Transaction Time
What is the need? We find out that the telephone bill for a
department is unusually high, so we ask “How many employees have been in each department" to get a start.
![Page 31: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/31.jpg)
Transaction Time
What is the need? It turns out that one of the departments shows
an unreasonable number of current employees (more than 25).
When was the error introduced? How long has the database been incorrect? The
query “When did we think that departments are overly large?“ provides an initial answer, but is also very difficult to express in SQL.
![Page 32: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/32.jpg)
Quick Tour
TSQL2 (Transaction Time Relations)
![Page 33: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/33.jpg)
TEMPORAL RELATION(Transaction Time)
![Page 34: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/34.jpg)
TEMPORAL RELATION(Transaction Time)
Jake hiring – reflects single hiring but changes in the modeled reality and the transaction time
![Page 35: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/35.jpg)
TEMPORAL RELATION(Transaction Time)
![Page 36: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/36.jpg)
TEMPORAL RELATION(Transaction Time)
![Page 37: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/37.jpg)
TEMPORAL RELATION(Transaction Time)
When was the street corrected, and what were the old and new values? (Nonsequence tx time & sequenced vt time)
![Page 38: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/38.jpg)
TEMPORAL RELATION(Transaction Time)
When did we think that someone lived somewhere for more than six months?
![Page 39: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/39.jpg)
TEMPORAL RELATION(Transaction Time)
Assume it is now October 1, 1995. Lilian moved last June 1.(PostActive update)
![Page 40: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/40.jpg)
TEMPORAL RELATION(Transaction Time)
“When was an employee's address for 1995 corrected?"(run on Nov 1 95)
![Page 41: TSQL 2 : Query Language for Temporal DatA](https://reader036.vdocument.in/reader036/viewer/2022062301/56816149550346895dd0c5a4/html5/thumbnails/41.jpg)
QUESTIONS ?Prepared by Puneet Mehta