SlideShare a Scribd company logo
TRACKING YOUR DATA
ACROSS THE FOURTH
DIMENSION
Jeremy Cook
CodeDaze 2016
““A temporal database is a database
with built-in support for handling
data involving time…
–Wikipedia
DON’T DATABASES
ALREADY HANDLE TIME
BASED DATA?
DATABASES ARE GOOD AT ‘NOW’
➤ Create
➤ Read
➤ Update
➤ Delete
➤ At any point we only see the current state of the data
SOME TEMPORAL
DATABASE THEORY
““Tonight @JCook21 explained
temporal databases and I’m sure my
brain is now leaking out of my nose…
– Jeff Carouth, https://twitter.com/
jcarouth/status/496842218674470912
TEMPORAL ASPECTS
➤ Term to describe different types of ‘temporality’
➤ Current theory defines three aspects
➤ We use temporal aspects all the time, representing them in a
DB is hard…
DECISION TIME
DECISION TIME
➤ Records the time at which a decision was made
➤ Modelled as a single value
➤ Allows for granularity through the data type used
DECISION TIME
EmpId Name Hire Date Decision to Hire
1 Jeremy 2014-03-03 2014-01-20
2 PJ 2015-01-02 2013-12-15
3 Johnny 2013-08-20 2013-08-20
VALID TIME
““In temporal databases, valid time
(VT) is the time period during which
a database fact is valid in the
modelled reality.
-Wikipedia
VALID TIME
➤ Modelled as a range between two points in time
➤ Lower bound is always closed but upper bound can be open
➤ Also known as Application Time
VALID TIME
EmpId Name Position StartVT EndVT
1 Jeremy Dev 2014-03-03 2015-01-19
1 Jeremy Senior Dev 2015-01-20 ∞
2 PJ Dev 2015-01-02 2016-01-30
2 PJ Manager 2016-01-31 ∞
3 Johnny Director 2013-08-20 2016-09-30
3 Johnny Vice President 2016-10-01 ∞
JOB DONE?
VALID-TIME ON ITS OWN MAY NOT BE ENOUGH…
Name Type StartVT EndVT
Saturn Planet
Billions of years
ago
∞
Pluto Planet
Billions of years
ago
∞
VALID-TIME ON ITS OWN MAY NOT BE ENOUGH…
Name Type StartVT EndVT
Saturn Planet
Billions of years
ago
∞
Pluto Dwarf planet
Billions of years
ago
∞
VALID-TIME ON ITS OWN MAY NOT BE ENOUGH…
Name Type StartVT EndVT
Saturn Planet
Billions of years
ago
∞
Pluto Plutoid
Billions of years
ago
∞
VALID-TIME ON ITS OWN MAY NOT BE ENOUGH…
Name Type StartVT EndVT
Saturn Planet
Billions of years
ago
∞
Pluto Planet
Billions of years
ago
2006
Pluto Dwarf planet 2006 2008
Pluto Plutoid 2008 ∞
TRANSACTION TIME
““In temporal databases, transaction
time (TT) is the time period during
which a fact stored in the database is
considered to be true.”
- Wikipedia
TRANSACTION TIME
➤ Modelled as a range between two points in time
➤ Lower bound is always closed but upper bound can be open
➤ Also known as System Time
TRANSACTION TIME
Name Type StartVT EndVT StartTT EndTT
Pluto Planet
Billions of
years ago
∞ 1930 2006
Pluto
Dwarf
planet
Billions of
years ago
∞ 2006 2008
Pluto Plutoid
Billions of
years ago
∞ 2008 ∞
HOW MANY TEMPORAL ASPECTS SHOULD YOU USE?
➤ As many or few as your application needs!
➤ Tables that implement two aspects are bi-temporal
➤ You can implement more aspects, in which case you have
multi temporal tables
IS YOUR HEAD SPINNING?
➤ Decision time records when a decision was taken
➤ Valid Time records the period of time for which the fact is
valid in the modelled reality
➤ Transaction Time records the period of time for which the fact
is considered to be true in the modelled reality
SQL:2011 TEMPORAL
PERIOD DATA TYPE
➤ Table component, capturing a pair of columns defining a start
and end date
➤ Not a new data type, but metadata about columns in the table
➤ Closed-open constraint
➤ Enforces that end time > start time
VALID TIME
➤ Also called application time in SQL:2011
➤ Modelled as a pair of date or timestamp columns with a
period
➤ Name of the columns and period is up to you
TEMPORAL PRIMARY KEYS
➤ SQL:2011 allows a valid time period to be named as part of a
primary key
➤ Without this how can you trace the evolution of data?
➤ Can also enforce that the valid time periods do not overlap
TEMPORAL FOREIGN KEYS
➤ What happens if a parent and child table both define valid
time periods?
➤ It doesn’t make sense to allow a row in a child table to
reference a row in a parent table where the valid time does
not overlap
➤ SQL:2011 allows valid time periods to be part of foreign key
constraints
➤ For the constraint to be considered satisfied the valid time
period in the child table must be contained within the valid
time period of one or more contiguous rows in the parent
table
QUERYING VALID TIME TABLES
➤ Can query against valid time columns as normal - they’re just
normal table columns
➤ When querying the database you need to specify what valid
time period you’re interested in
➤ Updates and deletes can be performed for a period of a valid
time time period
➤ Can create periods in queries and use new predicates to query
for valid time
TRANSACTION TIME
➤ Also known as system time in SQL:2011
➤ Modelled as two DATE or TIMESTAMP columns
➤ New predicates to query across transaction time periods.
➤ Management of the columns for the period is handled by the
database for you
TRANSACTION TIME
➤ Because the system manages transaction time:
➤ Not possible to alter transaction time values in the past
➤ Not possible to add future dated transaction time values
WHICH VENDORS
SUPPORT SQL:2011?
CURRENT SUPPORT
➤ IBM DB2
➤ Very good support
➤ Oracle 12c
➤ Valid time and transaction time support
➤ SQL Server 2016
➤ Only supports system/transaction time
➤ PostgreSQL
➤ 9.1 and earlier: temporal contributed package
➤ 9.2 native ranged data types
➤ Handful of others implemented as extensions
HOW DO I ADD THIS
STUFF TO MY CURRENT
SCHEMA?
SOME BIG PROBLEMS
➤ Temporal primary keys
➤ Temporal foreign keys
➤ Where are the boundaries of your temporal model?
➤ Making changes in a timeline is hard…
➤ Coaching users about the kind of changes they're making
➤ Querying for the data is harder
IMPLEMENTING VALID TIME - ONE TABLE
➤ Add a pair of date time columns to your table for the valid
time period.
➤ Can make these part of your primary key
➤ Good:
➤ Simpler model
➤ Ugly:
➤ Foreign keys become hard
IMPLEMENTING VALID TIME - TWO TABLES
➤ ‘Main’ table contains data that is valid now
➤ Second table contains data for other valid time periods
➤ Process to ‘promote’ data as it becomes valid
➤ Good:
➤ Easy to retrofit to an existing schema
➤ Ugly:
➤ More processing/logic
➤ What level of granularity can you achieve and accept with
promoting data?
IMPLEMENTING TRANSACTION TIME
➤ Add a column recording transaction time start to your table
➤ For each table create a backup table mirroring the columns in
the main table, adding a transaction time end column too
➤ Create a trigger that fires on each update or delete to copy old
values from the main table to the backup table
➤ Should add transaction time end to the backup table
➤ Should also update the transaction time start to now in the
main table if the operation is an update
IMPLEMENTING TRANSACTION TIME
➤ Things to consider:
➤ Extra complexity
➤ How long should backup data be kept for?
➤ Do you optimize for fast reads or writes?
MORE INFORMATION
➤ Wikipedia article on Temporal Databases
➤ Temporal features in SQL:2011 (PDF)
THANKS FOR LISTENING!
➤ Any questions?
➤ Contact me:
➤ @JCook21
➤ jeremycook0@icloud.com

More Related Content

Similar to Tracking your data across the fourth dimension (20)

Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried FärberTrivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis
 
Data Warehousing concepts for Data Engineering
Data Warehousing concepts for Data EngineeringData Warehousing concepts for Data Engineering
Data Warehousing concepts for Data Engineering
GouthumM
 
Time Travelling With DB2 10 For zOS
Time Travelling With DB2 10 For zOSTime Travelling With DB2 10 For zOS
Time Travelling With DB2 10 For zOS
Laura Hood
 
Apache Flink's Table & SQL API - unified APIs for batch and stream processing
Apache Flink's Table & SQL API - unified APIs for batch and stream processingApache Flink's Table & SQL API - unified APIs for batch and stream processing
Apache Flink's Table & SQL API - unified APIs for batch and stream processing
Timo Walther
 
Timo Walther - Table & SQL API - unified APIs for batch and stream processing
Timo Walther - Table & SQL API - unified APIs for batch and stream processingTimo Walther - Table & SQL API - unified APIs for batch and stream processing
Timo Walther - Table & SQL API - unified APIs for batch and stream processing
Ververica
 
Temporal Tables, Transparent Archiving in DB2 for z/OS and IDAA
Temporal Tables, Transparent Archiving in DB2 for z/OS and IDAATemporal Tables, Transparent Archiving in DB2 for z/OS and IDAA
Temporal Tables, Transparent Archiving in DB2 for z/OS and IDAA
Cuneyt Goksu
 
Temporal Case Management 1998
Temporal Case Management  1998Temporal Case Management  1998
Temporal Case Management 1998
David Tryon
 
SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022
SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022
SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022
HostedbyConfluent
 
Databases
DatabasesDatabases
Databases
Sajitha Pathirana
 
Dataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra SolutionsDataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra Solutions
Quontra Solutions
 
ACS DataMart_ppt
ACS DataMart_pptACS DataMart_ppt
ACS DataMart_ppt
Jeremy Searls
 
ACS DataMart_ppt
ACS DataMart_pptACS DataMart_ppt
ACS DataMart_ppt
Jeremy Searls
 
tempDB.ppt
tempDB.ppttempDB.ppt
tempDB.ppt
GopiBala5
 
SQL Server Temporal Tables
SQL Server Temporal TablesSQL Server Temporal Tables
SQL Server Temporal Tables
Greg McMurray
 
How to Design a Modern Data Warehouse in BigQuery
How to Design a Modern Data Warehouse in BigQueryHow to Design a Modern Data Warehouse in BigQuery
How to Design a Modern Data Warehouse in BigQuery
Dan Sullivan, Ph.D.
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's New
dpcobb
 
Temporal_Data_Warehouse.pptx
Temporal_Data_Warehouse.pptxTemporal_Data_Warehouse.pptx
Temporal_Data_Warehouse.pptx
Kulwinder Padda
 
Checking and verifying temporal data
Checking and verifying temporal dataChecking and verifying temporal data
Checking and verifying temporal data
IJDMS
 
Data Warehouse - What you know about etl process is wrong
Data Warehouse - What you know about etl process is wrongData Warehouse - What you know about etl process is wrong
Data Warehouse - What you know about etl process is wrong
Massimo Cenci
 
Real time database
Real time databaseReal time database
Real time database
arvinthsaran
 
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried FärberTrivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis
 
Data Warehousing concepts for Data Engineering
Data Warehousing concepts for Data EngineeringData Warehousing concepts for Data Engineering
Data Warehousing concepts for Data Engineering
GouthumM
 
Time Travelling With DB2 10 For zOS
Time Travelling With DB2 10 For zOSTime Travelling With DB2 10 For zOS
Time Travelling With DB2 10 For zOS
Laura Hood
 
Apache Flink's Table & SQL API - unified APIs for batch and stream processing
Apache Flink's Table & SQL API - unified APIs for batch and stream processingApache Flink's Table & SQL API - unified APIs for batch and stream processing
Apache Flink's Table & SQL API - unified APIs for batch and stream processing
Timo Walther
 
Timo Walther - Table & SQL API - unified APIs for batch and stream processing
Timo Walther - Table & SQL API - unified APIs for batch and stream processingTimo Walther - Table & SQL API - unified APIs for batch and stream processing
Timo Walther - Table & SQL API - unified APIs for batch and stream processing
Ververica
 
Temporal Tables, Transparent Archiving in DB2 for z/OS and IDAA
Temporal Tables, Transparent Archiving in DB2 for z/OS and IDAATemporal Tables, Transparent Archiving in DB2 for z/OS and IDAA
Temporal Tables, Transparent Archiving in DB2 for z/OS and IDAA
Cuneyt Goksu
 
Temporal Case Management 1998
Temporal Case Management  1998Temporal Case Management  1998
Temporal Case Management 1998
David Tryon
 
SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022
SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022
SQL Extensions to Support Streaming Data With Fabian Hueske | Current 2022
HostedbyConfluent
 
Dataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra SolutionsDataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra Solutions
Quontra Solutions
 
SQL Server Temporal Tables
SQL Server Temporal TablesSQL Server Temporal Tables
SQL Server Temporal Tables
Greg McMurray
 
How to Design a Modern Data Warehouse in BigQuery
How to Design a Modern Data Warehouse in BigQueryHow to Design a Modern Data Warehouse in BigQuery
How to Design a Modern Data Warehouse in BigQuery
Dan Sullivan, Ph.D.
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's New
dpcobb
 
Temporal_Data_Warehouse.pptx
Temporal_Data_Warehouse.pptxTemporal_Data_Warehouse.pptx
Temporal_Data_Warehouse.pptx
Kulwinder Padda
 
Checking and verifying temporal data
Checking and verifying temporal dataChecking and verifying temporal data
Checking and verifying temporal data
IJDMS
 
Data Warehouse - What you know about etl process is wrong
Data Warehouse - What you know about etl process is wrongData Warehouse - What you know about etl process is wrong
Data Warehouse - What you know about etl process is wrong
Massimo Cenci
 
Real time database
Real time databaseReal time database
Real time database
arvinthsaran
 

More from Jeremy Cook (7)

Unit test your java architecture with ArchUnit
Unit test your java architecture with ArchUnitUnit test your java architecture with ArchUnit
Unit test your java architecture with ArchUnit
Jeremy Cook
 
Beyond MVC: from Model to Domain
Beyond MVC: from Model to DomainBeyond MVC: from Model to Domain
Beyond MVC: from Model to Domain
Jeremy Cook
 
Beyond MVC: from Model to Domain
Beyond MVC: from Model to DomainBeyond MVC: from Model to Domain
Beyond MVC: from Model to Domain
Jeremy Cook
 
Accelerate your web app with a layer of Varnish
Accelerate your web app with a layer of VarnishAccelerate your web app with a layer of Varnish
Accelerate your web app with a layer of Varnish
Jeremy Cook
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
Jeremy Cook
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
Jeremy Cook
 
PHPUnit: from zero to hero
PHPUnit: from zero to heroPHPUnit: from zero to hero
PHPUnit: from zero to hero
Jeremy Cook
 
Unit test your java architecture with ArchUnit
Unit test your java architecture with ArchUnitUnit test your java architecture with ArchUnit
Unit test your java architecture with ArchUnit
Jeremy Cook
 
Beyond MVC: from Model to Domain
Beyond MVC: from Model to DomainBeyond MVC: from Model to Domain
Beyond MVC: from Model to Domain
Jeremy Cook
 
Beyond MVC: from Model to Domain
Beyond MVC: from Model to DomainBeyond MVC: from Model to Domain
Beyond MVC: from Model to Domain
Jeremy Cook
 
Accelerate your web app with a layer of Varnish
Accelerate your web app with a layer of VarnishAccelerate your web app with a layer of Varnish
Accelerate your web app with a layer of Varnish
Jeremy Cook
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
Jeremy Cook
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
Jeremy Cook
 
PHPUnit: from zero to hero
PHPUnit: from zero to heroPHPUnit: from zero to hero
PHPUnit: from zero to hero
Jeremy Cook
 

Recently uploaded (20)

Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 

Tracking your data across the fourth dimension

  • 1. TRACKING YOUR DATA ACROSS THE FOURTH DIMENSION Jeremy Cook CodeDaze 2016
  • 2. ““A temporal database is a database with built-in support for handling data involving time… –Wikipedia
  • 4. DATABASES ARE GOOD AT ‘NOW’ ➤ Create ➤ Read ➤ Update ➤ Delete ➤ At any point we only see the current state of the data
  • 6. ““Tonight @JCook21 explained temporal databases and I’m sure my brain is now leaking out of my nose… – Jeff Carouth, https://twitter.com/ jcarouth/status/496842218674470912
  • 7. TEMPORAL ASPECTS ➤ Term to describe different types of ‘temporality’ ➤ Current theory defines three aspects ➤ We use temporal aspects all the time, representing them in a DB is hard…
  • 9. DECISION TIME ➤ Records the time at which a decision was made ➤ Modelled as a single value ➤ Allows for granularity through the data type used
  • 10. DECISION TIME EmpId Name Hire Date Decision to Hire 1 Jeremy 2014-03-03 2014-01-20 2 PJ 2015-01-02 2013-12-15 3 Johnny 2013-08-20 2013-08-20
  • 12. ““In temporal databases, valid time (VT) is the time period during which a database fact is valid in the modelled reality. -Wikipedia
  • 13. VALID TIME ➤ Modelled as a range between two points in time ➤ Lower bound is always closed but upper bound can be open ➤ Also known as Application Time
  • 14. VALID TIME EmpId Name Position StartVT EndVT 1 Jeremy Dev 2014-03-03 2015-01-19 1 Jeremy Senior Dev 2015-01-20 ∞ 2 PJ Dev 2015-01-02 2016-01-30 2 PJ Manager 2016-01-31 ∞ 3 Johnny Director 2013-08-20 2016-09-30 3 Johnny Vice President 2016-10-01 ∞
  • 16. VALID-TIME ON ITS OWN MAY NOT BE ENOUGH… Name Type StartVT EndVT Saturn Planet Billions of years ago ∞ Pluto Planet Billions of years ago ∞
  • 17. VALID-TIME ON ITS OWN MAY NOT BE ENOUGH… Name Type StartVT EndVT Saturn Planet Billions of years ago ∞ Pluto Dwarf planet Billions of years ago ∞
  • 18. VALID-TIME ON ITS OWN MAY NOT BE ENOUGH… Name Type StartVT EndVT Saturn Planet Billions of years ago ∞ Pluto Plutoid Billions of years ago ∞
  • 19. VALID-TIME ON ITS OWN MAY NOT BE ENOUGH… Name Type StartVT EndVT Saturn Planet Billions of years ago ∞ Pluto Planet Billions of years ago 2006 Pluto Dwarf planet 2006 2008 Pluto Plutoid 2008 ∞
  • 21. ““In temporal databases, transaction time (TT) is the time period during which a fact stored in the database is considered to be true.” - Wikipedia
  • 22. TRANSACTION TIME ➤ Modelled as a range between two points in time ➤ Lower bound is always closed but upper bound can be open ➤ Also known as System Time
  • 23. TRANSACTION TIME Name Type StartVT EndVT StartTT EndTT Pluto Planet Billions of years ago ∞ 1930 2006 Pluto Dwarf planet Billions of years ago ∞ 2006 2008 Pluto Plutoid Billions of years ago ∞ 2008 ∞
  • 24. HOW MANY TEMPORAL ASPECTS SHOULD YOU USE? ➤ As many or few as your application needs! ➤ Tables that implement two aspects are bi-temporal ➤ You can implement more aspects, in which case you have multi temporal tables
  • 25. IS YOUR HEAD SPINNING? ➤ Decision time records when a decision was taken ➤ Valid Time records the period of time for which the fact is valid in the modelled reality ➤ Transaction Time records the period of time for which the fact is considered to be true in the modelled reality
  • 27. PERIOD DATA TYPE ➤ Table component, capturing a pair of columns defining a start and end date ➤ Not a new data type, but metadata about columns in the table ➤ Closed-open constraint ➤ Enforces that end time > start time
  • 28. VALID TIME ➤ Also called application time in SQL:2011 ➤ Modelled as a pair of date or timestamp columns with a period ➤ Name of the columns and period is up to you
  • 29. TEMPORAL PRIMARY KEYS ➤ SQL:2011 allows a valid time period to be named as part of a primary key ➤ Without this how can you trace the evolution of data? ➤ Can also enforce that the valid time periods do not overlap
  • 30. TEMPORAL FOREIGN KEYS ➤ What happens if a parent and child table both define valid time periods? ➤ It doesn’t make sense to allow a row in a child table to reference a row in a parent table where the valid time does not overlap ➤ SQL:2011 allows valid time periods to be part of foreign key constraints ➤ For the constraint to be considered satisfied the valid time period in the child table must be contained within the valid time period of one or more contiguous rows in the parent table
  • 31. QUERYING VALID TIME TABLES ➤ Can query against valid time columns as normal - they’re just normal table columns ➤ When querying the database you need to specify what valid time period you’re interested in ➤ Updates and deletes can be performed for a period of a valid time time period ➤ Can create periods in queries and use new predicates to query for valid time
  • 32. TRANSACTION TIME ➤ Also known as system time in SQL:2011 ➤ Modelled as two DATE or TIMESTAMP columns ➤ New predicates to query across transaction time periods. ➤ Management of the columns for the period is handled by the database for you
  • 33. TRANSACTION TIME ➤ Because the system manages transaction time: ➤ Not possible to alter transaction time values in the past ➤ Not possible to add future dated transaction time values
  • 35. CURRENT SUPPORT ➤ IBM DB2 ➤ Very good support ➤ Oracle 12c ➤ Valid time and transaction time support ➤ SQL Server 2016 ➤ Only supports system/transaction time ➤ PostgreSQL ➤ 9.1 and earlier: temporal contributed package ➤ 9.2 native ranged data types ➤ Handful of others implemented as extensions
  • 36. HOW DO I ADD THIS STUFF TO MY CURRENT SCHEMA?
  • 37. SOME BIG PROBLEMS ➤ Temporal primary keys ➤ Temporal foreign keys ➤ Where are the boundaries of your temporal model? ➤ Making changes in a timeline is hard… ➤ Coaching users about the kind of changes they're making ➤ Querying for the data is harder
  • 38. IMPLEMENTING VALID TIME - ONE TABLE ➤ Add a pair of date time columns to your table for the valid time period. ➤ Can make these part of your primary key ➤ Good: ➤ Simpler model ➤ Ugly: ➤ Foreign keys become hard
  • 39. IMPLEMENTING VALID TIME - TWO TABLES ➤ ‘Main’ table contains data that is valid now ➤ Second table contains data for other valid time periods ➤ Process to ‘promote’ data as it becomes valid ➤ Good: ➤ Easy to retrofit to an existing schema ➤ Ugly: ➤ More processing/logic ➤ What level of granularity can you achieve and accept with promoting data?
  • 40. IMPLEMENTING TRANSACTION TIME ➤ Add a column recording transaction time start to your table ➤ For each table create a backup table mirroring the columns in the main table, adding a transaction time end column too ➤ Create a trigger that fires on each update or delete to copy old values from the main table to the backup table ➤ Should add transaction time end to the backup table ➤ Should also update the transaction time start to now in the main table if the operation is an update
  • 41. IMPLEMENTING TRANSACTION TIME ➤ Things to consider: ➤ Extra complexity ➤ How long should backup data be kept for? ➤ Do you optimize for fast reads or writes?
  • 42. MORE INFORMATION ➤ Wikipedia article on Temporal Databases ➤ Temporal features in SQL:2011 (PDF)
  • 43. THANKS FOR LISTENING! ➤ Any questions? ➤ Contact me: ➤ @JCook21 ➤ [email protected]