SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
An Overview of Temporal Features in SQL:2011

     Craig Baumunk, January 4, 2012




                                               1
Agenda
•   SQL Standards Process Overview

•   Temporal features in standard SQL history

•   Temporal data overview

•   Things to know about temporal features in SQL:2011

•   Application time period tables

•   System versioned tables

•   Application time period tables with system versioning (bitemporal tables)

•   Next Steps

                                                                                2
SQL Standards Process Overview

   •   INCITS DM32.2 (formerly X3H2) is responsible for SQL standard in US
         – International Committee for Information Technology Standards) is an ANSI (American
            National Standards Institute) accredited standards producing organization
   •   ISO/IEC JTC 1/SC 32 Data Management and Interchange/WG 3 committee is responsible for
       SQL Standard Internationally
   •   Much of the new capabilities in the SQL standard have originated in the US
         – Approval by DM32.2 before submission to WG3
         – Published by ISO then adopted as US standards by INCITS
   •   Typically 3 to 5 year cycle
   •   SQL is a multi-part standard which currently has 9 parts
         – The highest part number is currently 14 (parts 5, 6, 7, 8 &12) were terminated
         – Part 2: SQL/Foundation is the SQL language specification (biggest/most important part)
   •   Documentation of DM32.2 works in progress are not publicly available
   •   Anyone can join DM32 as an observer for $1,200 and get documentation of works in progress and
       what is approved but not yet published etc
   •   7 Versions of Standard SQL
         – 86 (SQL-87), 89, 92(SQL2), SQL:1999 (SQL3), SQL:2003, SQL:2008, SQL:2011


* Disclaimer: I am not and never been a member of X3H2 or INCITS DM32.2 personally
                                                                                                       3
Temporal Features First Attempt 1995 - 2001


•   X3H2 (now DM32.2) and WG 3 both approved work on a new part of SQL standard called
    SQL/Temporal in 1995
•   US made the first proposal on adding the new SQL extensions, largely based on the pioneering
    work of Prof. Rick Snodgrass of Univ. of Arizona
•   The US proposal was based on TSQL2, an extension of SQL-92, put together by a team headed
    by Prof. Snodgrass
•   The US proposal proved to be controversial at ISO. Some of the ISO members felt there were
    some serious problems with the US proposal
•   The UK brought in a competing proposal based on the work of Prof. Nikos Lorentzos of Univ.
    Athens, Greece
•   The US disagreed with the ISO comments on the US proposal. And the US also did not see the
    need for the UK proposal
•   Because of the controversy, both ANSI and ISO decided to defer further work on SQL/Temporal
    until SQL:99 was published
•   After the publication of SQL:99, neither US nor UK brought in any new proposals to resolve the
    differences
•   Because of inactivity, both ANSI and ISO decided to cancel SQL/Temporal part in 2001



                                                                                                     4
Temporal Features Second Attempt 2008 - 2011


•   A second attempt at adding temporal features to the SQL standard was made in
    2008. It started with the acceptance of a proposal on "system-versioned tables"
    by both INCITS DM32.2 and ISO/IEC JTC1 SC32 WG3. Rather than
    resurrecting SQL/Temporal, this proposal added the temporal extensions to
    SQL/Foundation.

•   Another temporal feature was added in 2010 in the form of "application-time
    period tables”.

•   Both system-versioned tables and application-time period tables are now part of
    the new version of the SQL standard (SQL:2011) which was approved and
    published in 2011.

•   The temporal features in SQL:2011 are largely inspired by the earlier proposals
    considered during the first attempt but with a substantially different syntax.



                                                                                      5
Temporal Data



   Temporal data is data which changes over time
     •  A company’s credit rating changes over time
          •    Referred to as valid time dimension, real world perspective or business perspective
          •    SQL:2011 calls this application time
     •  The value we have in a database for a company’s credit rating changes over time
          •    This may be different than application time due to timing differences
          •    This may have nothing to do with the application time perspective (for example corrections)
          •    Referred to as transaction time dimension or database perspective
          •    SQL:2011 calls this system time (or system versioning)

   Most data is temporal
     •   Most common dimensions are application time and system time (focus of temporal features of SQL:2011)

   It is helpful to think of non-temporal data as a trivial case of temporal data
      •    Non-temporal data would be data which does not change (in real life, in a system, or we do not store a
           history of changes in a database)

   Bitemporal data is data which changes over 2 dimensions of time independently
     •   SQL:2011 calls this application time with system versioning



                                                                                                                    6
4 Types of tables


                                     No Application Time History     Application Time History
     No System Time History          Non-temporal                    Application time period table
     System Time History             System versioned table          System versioned application
                                                                     time period table


   Non-temporal tables
     • Conventional tables (without date/timestamp in PK)
     • Latest information, without any history

   Application time period tables
     • History of how data changed from an application time perspective as we know it now

   System versioned tables
     • History of how current data from a application time perspective changed in the system
       (database)

   System versioned application time period tables
     • History, of how history from an application time perspective, changed in the system (database)

                                                                                                        7
Things to know about temporal features in
                               SQL:2011
   Row based versioning
     • In contrast to column based versioning
     • But can be use to implement column based versioning

   State based storage
     • 2 timestamps for application time periods
     • 2 timestamps for system time periods
     • 4 timestamps for system versioned application time period tables

   State based inputs
     • User provides application period start AND application period end
     • Users do NOT provide system period start or end
           • Insert, update, and delete events are converted to states (till high datetime)

   Time periods use the Closed – Open convention
     • AKA inclusive – exclusive
     • Supports unambiguous comparisons with different precisions

   The strengths of the temporal features in SQL:2011 are:
     • Ease of migration (not dependent on period data type)
     • Fits well with SQL semantics (no statement modifiers)
     • Lots of user control (can update application start/end directly)
     • Compatibility (existing queries work against system versioned tables)
                                                                                              8
Primary Keys for 4 Types of Tables



   Non-temporal storage
     • No date/timestamp in PK

   Application time period table
     • 2 timestamps (Application Period Start & Application Period End) is not enough
     • Application time periods can not overlap for the same object

   System versioned table
     • System time periods should not overlap for the same object (but this is not part of the PK)
     • 2 rows for the same object can not have the same system start (constraint)
          • Transaction time is defined by implementation (high level of precision)
          • Transaction times should be sequential

   System versioned application time period table
     • Application time periods can overlap for the same object
     • System time periods can overlap for the same object
     • BOTH application time period AND system time period should NOT overlap for the same
       object

                                                                                                     9
Application time period tables

•   Table definition
      – Define columns for application period start and end (need to be a date/timestamp data types and not null)
      – New PERIOD clause specifies what columns implement an application time period and creates an implicit
           constraint that application time period start < application time period end (pick your period name)
      – New WITHOUT OVERLAPS keywords in PRIMARY KEY clause ensures that application time periods do
           not overlap
      – FOREIGN KEY clause extended to include referencing of period in parent table
•   Inserting
      – Normal syntax
              • Comply with constraints ( start and end not null, start < end, no overlaps)
•   Deletes
      – Delete rows with normal syntax
              • Constrain on application time period start and end as desired or not !
      – Delete using FOR PORTION OF application time period FROM DATE XXXX/XX/XX TO DATE XXXX/XX/XX
           clause results in automatic “row splitting”
•   Updates
      – Update rows with normal syntax (including application time period start and end columns)
              • Comply with constraints (start and end not null, start < end, no overlaps)
              • Constrain on application time period start and end as desired or not !
      – Update using FOR PORTION OF application time period FROM DATE XXXX/XX/XX TO DATE
           XXXX/XX/XX clause results in automatic “row splitting”
              • Can’t update application period start or end using this option
•   Select
      – Normal Syntax (application time period start and end can be used since they are explicit columns)
                                                                                                                    10
Application time period tables – Delete row splitting
             - 4 types of existing time slices -




• There can be multiple types of existing time slices for a delete range
• No error if delete over a range where no values


                                                                           11
Application time period tables – Update row splitting
                - 4 types of existing time slices -




• There can be multiple types of existing time slices for a update range
• No error if update over a range where no values
• An update can cause multiple contiguous time slices to have the same non PK data
values (unpacked)
                                                                                     12
System versioned tables

•   Table definition
      – Define columns for system time period start and end (need to be date/timestamp data type and not null) with new
           GENERATE ALWAYS AS ROW BEGIN/END clause
      – New PERIOD clause with SYSTEM_TIME period name specifies what columns are in the system time period
           (system time period start < system time period end does not need to be enforced)
      – New WITH SYSTEM VERSIONING clause implicitly adds system time period start to primary key
      – Constraints only apply to rows which are not logically deleted
      – Referential Integrity is not impacted
•   Inserting
      – Normal syntax but never specify system time period start or end columns as they are generated
      – New time slices of data have system time period start = insert transaction time and system period end = high
           date/time
•   Deletes
      – Normal syntax but a history of what data was deleted and when it was deleted is maintained automatically
      – Deleted time slices of data have system period end = delete transaction time (logically deleted)
      – Only rows which are not logically deleted can be deleted
•   Updates
      – Normal syntax but a history of what data was updated and when it was updated is maintained automatically
      – Updated time slices of data have system period end = update transaction time (logically deleted)
      – Only rows which are not logically deleted can be updated
•   Select
      – Normal syntax works as if non-temporal table (do not query logically deleted rows)
      – New as-of, between, and from clauses are available to query all rows in the table
              • Including logically deleted rows
                                                                                                                   13
System versioned tables – Delete history
                               - 1 type of existing time slice -




                                                                                                Not logically
                                                                                                  deleted


 Delete range begin =
Delete transaction time                                                                         Delete range end =
                                                                                                High date/timestamp



     Logically deleted




   • There is only 1 type of existing time slice for a delete range
   • There can only be 1 time slice of interest for an object (that is not logically deleted)




                                                                                                                      14
System versioned tables – Update History
                               - 1 type of existing time slices -




                                                                                              Not logically
                                                                                                deleted


 Delete range begin =
Delete transaction time                                                                       Delete range end =
                                                                                              High date/timestamp


                                                                                              Not logically
     Logically deleted
                                                                                                deleted




 • There can only be 1 type of existing time slice for an update range
 • There can only be 1 time slice of interest for an object (that is not logically deleted)




                                                                                                                    15
System versioned application time period tables


•   Table definition
     –   Define columns for application time period start and end (need to be date/timestamp data types and not null)
     –   Define columns for system time period start and end (need to be date/timestamp data types and not null)
         with new GENERATE ALWAYS AS ROW BEGIN/END clause
     –   New PERIOD clause to specifies what columns are in the application time period
     –   New PERIOD clause with SYSTEM_TIME keyword specifies what columns are in system time period
     –   New WITHOUT OVERLAPS keyword in PRIMARY KEY clause ensures that application time periods do not
         overlap
     –   New WITH SYSTEM VERSIONING clause implicitly adds system time period start to primary key
     –   Constraints only apply to rows which are not logically deleted
     –   FOREIGN KEY clause extended to include referencing of period in parent table
•   Inserting
     –   Same as application time period tables but never specify system time period start or end columns as they
         are generated
•   Deletes
     –   Same as application time period tables but a history of what was deleted and when it was deleted is
         maintained automatically (rows)
     –   Only rows which are not logically deleted can be deleted
•   Updates
     –   Same as application time period tables but a history of what was updated and when it was updated is
         maintained automatically (rows)
     –   Only rows which are not logically deleted can be updated
•   Select
     –   Same as application period tables
     –   New as-of, between, and from clauses are available to query all rows in the table
           • Including logically deleted rows

                                                                                                                        16
Bitemporal tables – Delete splitting & history
              - 4 types of existing application time slices -




• Same as application time period table deletes except update existing time slices instead of
delete because:
      • Only 1 type of existing row from system versioning perspective
      • Application time period table delete splitting results in inserts and deletes
      • System versioning does not do any splitting for inserts
      • System versioning changes deletes into updates
                                                                                                17
Bitemporal tables – Update splitting & history
              - 4 types of existing application time slices -




• Same as application time period table updates except additional insert of existing time slice
because:
     • Only 1 type of existing row from system versioning perspective
     • Application time period table update row splitting results in inserts and updates
     • System versioning does not do any splitting for inserts
     • System versioning changes updates into an update AND an insert
                                                                                                  18
Summary & Conclusions



• Significant new temporal features have been included in SQL:2011
• Temporal features represent a significant extension to the SQL
  language that will take time for people to utilize
• Vendors are beginning to adopt these features
• Methodology for how to utilize new temporal features of SQL will
  probably be a factor in utilization
• Time will tell how much the SQL:2011 temporal extensions are
  utilized
• Implications of temporal extensions on replication, partitioning,
  archiving etc are still being sorted




                                                                      19
Next Steps



•   Actual syntax

•   Examples, Examples and more examples

•   Advanced topics
     –   Temporal predicates
     –   Joining different types of temporal tables
     –   Referential integrity implications
     –   Schema migration implications

•   Where are vendors with compliance/adoption

•   How vendors CAN comply but also differentiate

•   How vendors ARE differentiating


                                                      20
Resources




 Search YouTube.com for “Case for Bitemporal Data”
    http://www.youtube.com/playlist?list=PL4CB3C8161D2804E6

 TemporalData.com

 “Temporal Data” LinkedIn group
    http://www.linkedin.com/groups?gid=3885228

 http://stacresearch.com/btd
    Functional and performance benchmarks


                                                               21
THANK YOU!


USA                            UK

BitemporalData.com LLC         BitemporalData Ltd
1330 Route 206                 Suite 13493, 2nd floor
Suite 318                      145-157 St John Street
Skillman, NJ 08558             London EC1V 4PY


Tel: +1.201.332.5000           Tel: +44.20.3318.5919




                                                        22

Más contenido relacionado

La actualidad más candente

Displaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSLDisplaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSL
Bình Trọng Án
 

La actualidad más candente (20)

Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
RDF and OWL
RDF and OWLRDF and OWL
RDF and OWL
 
Apache Nifi Crash Course
Apache Nifi Crash CourseApache Nifi Crash Course
Apache Nifi Crash Course
 
Deep dive into LangChain integration with Neo4j.pptx
Deep dive into LangChain integration with Neo4j.pptxDeep dive into LangChain integration with Neo4j.pptx
Deep dive into LangChain integration with Neo4j.pptx
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4j
 
Css position
Css positionCss position
Css position
 
Debunking some “RDF vs. Property Graph” Alternative Facts
Debunking some “RDF vs. Property Graph” Alternative FactsDebunking some “RDF vs. Property Graph” Alternative Facts
Debunking some “RDF vs. Property Graph” Alternative Facts
 
Displaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSLDisplaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSL
 
Dhtml ppt (2)
Dhtml ppt (2)Dhtml ppt (2)
Dhtml ppt (2)
 
Considerations for Data Access in the Lakehouse
Considerations for Data Access in the LakehouseConsiderations for Data Access in the Lakehouse
Considerations for Data Access in the Lakehouse
 
Impala presentation
Impala presentationImpala presentation
Impala presentation
 
Difference between molap, rolap and holap in ssas
Difference between molap, rolap and holap  in ssasDifference between molap, rolap and holap  in ssas
Difference between molap, rolap and holap in ssas
 
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
 
Big Data
Big DataBig Data
Big Data
 
Apache Druid 101
Apache Druid 101Apache Druid 101
Apache Druid 101
 
Introduction to Stream Processing
Introduction to Stream ProcessingIntroduction to Stream Processing
Introduction to Stream Processing
 
Google Cloud and Data Pipeline Patterns
Google Cloud and Data Pipeline PatternsGoogle Cloud and Data Pipeline Patterns
Google Cloud and Data Pipeline Patterns
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC Service
 
InfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxData
InfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxDataInfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxData
InfluxDB 101 - Concepts and Architecture | Michael DeSa | InfluxData
 
Fifth Elephant Apache Atlas Talk
Fifth Elephant Apache Atlas TalkFifth Elephant Apache Atlas Talk
Fifth Elephant Apache Atlas Talk
 

Similar a An Overview of Temporal Features in SQL:2011

T sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powersT sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powers
Shehap Elnagar
 
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaaPerfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Cuneyt Goksu
 
Database applicationtesting
Database applicationtestingDatabase applicationtesting
Database applicationtesting
Renuka Ballal
 
2 approaches to system development
2 approaches to system development2 approaches to system development
2 approaches to system development
cymark09
 
Openstack upgrade without_down_time_20141103r1
Openstack upgrade without_down_time_20141103r1Openstack upgrade without_down_time_20141103r1
Openstack upgrade without_down_time_20141103r1
Yankai Liu
 

Similar a An Overview of Temporal Features in SQL:2011 (20)

T sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powersT sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powers
 
Un it 2-se-mod-staff
Un it 2-se-mod-staffUn it 2-se-mod-staff
Un it 2-se-mod-staff
 
T sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powersT sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powers
 
T sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powersT sql performance guidelines for better db stress powers
T sql performance guidelines for better db stress powers
 
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaaPerfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
 
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
 
Database applicationtesting
Database applicationtestingDatabase applicationtesting
Database applicationtesting
 
Software Configuration Management.pptx
Software Configuration Management.pptxSoftware Configuration Management.pptx
Software Configuration Management.pptx
 
System development
System developmentSystem development
System development
 
Project scheduler doc
Project scheduler docProject scheduler doc
Project scheduler doc
 
SKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSING
SKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSINGSKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSING
SKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSING
 
SDLC
SDLC SDLC
SDLC
 
Oracle11g R2 - Edition Based Redefinition for On Line Application Upgrade
Oracle11g R2 - Edition Based Redefinition for On Line Application UpgradeOracle11g R2 - Edition Based Redefinition for On Line Application Upgrade
Oracle11g R2 - Edition Based Redefinition for On Line Application Upgrade
 
2 approaches to system development
2 approaches to system development2 approaches to system development
2 approaches to system development
 
Pawan111
Pawan111Pawan111
Pawan111
 
6. FUNDAMENTALS OF SE AND REQUIREMENT ENGINEERING.ppt
6. FUNDAMENTALS OF SE AND REQUIREMENT ENGINEERING.ppt6. FUNDAMENTALS OF SE AND REQUIREMENT ENGINEERING.ppt
6. FUNDAMENTALS OF SE AND REQUIREMENT ENGINEERING.ppt
 
Openstack upgrade without_down_time_20141103r1
Openstack upgrade without_down_time_20141103r1Openstack upgrade without_down_time_20141103r1
Openstack upgrade without_down_time_20141103r1
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
 
Types of Operating System
Types of Operating System Types of Operating System
Types of Operating System
 
Software Configuration Management
Software Configuration ManagementSoftware Configuration Management
Software Configuration Management
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

An Overview of Temporal Features in SQL:2011

  • 1. An Overview of Temporal Features in SQL:2011 Craig Baumunk, January 4, 2012 1
  • 2. Agenda • SQL Standards Process Overview • Temporal features in standard SQL history • Temporal data overview • Things to know about temporal features in SQL:2011 • Application time period tables • System versioned tables • Application time period tables with system versioning (bitemporal tables) • Next Steps 2
  • 3. SQL Standards Process Overview • INCITS DM32.2 (formerly X3H2) is responsible for SQL standard in US – International Committee for Information Technology Standards) is an ANSI (American National Standards Institute) accredited standards producing organization • ISO/IEC JTC 1/SC 32 Data Management and Interchange/WG 3 committee is responsible for SQL Standard Internationally • Much of the new capabilities in the SQL standard have originated in the US – Approval by DM32.2 before submission to WG3 – Published by ISO then adopted as US standards by INCITS • Typically 3 to 5 year cycle • SQL is a multi-part standard which currently has 9 parts – The highest part number is currently 14 (parts 5, 6, 7, 8 &12) were terminated – Part 2: SQL/Foundation is the SQL language specification (biggest/most important part) • Documentation of DM32.2 works in progress are not publicly available • Anyone can join DM32 as an observer for $1,200 and get documentation of works in progress and what is approved but not yet published etc • 7 Versions of Standard SQL – 86 (SQL-87), 89, 92(SQL2), SQL:1999 (SQL3), SQL:2003, SQL:2008, SQL:2011 * Disclaimer: I am not and never been a member of X3H2 or INCITS DM32.2 personally 3
  • 4. Temporal Features First Attempt 1995 - 2001 • X3H2 (now DM32.2) and WG 3 both approved work on a new part of SQL standard called SQL/Temporal in 1995 • US made the first proposal on adding the new SQL extensions, largely based on the pioneering work of Prof. Rick Snodgrass of Univ. of Arizona • The US proposal was based on TSQL2, an extension of SQL-92, put together by a team headed by Prof. Snodgrass • The US proposal proved to be controversial at ISO. Some of the ISO members felt there were some serious problems with the US proposal • The UK brought in a competing proposal based on the work of Prof. Nikos Lorentzos of Univ. Athens, Greece • The US disagreed with the ISO comments on the US proposal. And the US also did not see the need for the UK proposal • Because of the controversy, both ANSI and ISO decided to defer further work on SQL/Temporal until SQL:99 was published • After the publication of SQL:99, neither US nor UK brought in any new proposals to resolve the differences • Because of inactivity, both ANSI and ISO decided to cancel SQL/Temporal part in 2001 4
  • 5. Temporal Features Second Attempt 2008 - 2011 • A second attempt at adding temporal features to the SQL standard was made in 2008. It started with the acceptance of a proposal on "system-versioned tables" by both INCITS DM32.2 and ISO/IEC JTC1 SC32 WG3. Rather than resurrecting SQL/Temporal, this proposal added the temporal extensions to SQL/Foundation. • Another temporal feature was added in 2010 in the form of "application-time period tables”. • Both system-versioned tables and application-time period tables are now part of the new version of the SQL standard (SQL:2011) which was approved and published in 2011. • The temporal features in SQL:2011 are largely inspired by the earlier proposals considered during the first attempt but with a substantially different syntax. 5
  • 6. Temporal Data  Temporal data is data which changes over time • A company’s credit rating changes over time • Referred to as valid time dimension, real world perspective or business perspective • SQL:2011 calls this application time • The value we have in a database for a company’s credit rating changes over time • This may be different than application time due to timing differences • This may have nothing to do with the application time perspective (for example corrections) • Referred to as transaction time dimension or database perspective • SQL:2011 calls this system time (or system versioning)  Most data is temporal • Most common dimensions are application time and system time (focus of temporal features of SQL:2011)  It is helpful to think of non-temporal data as a trivial case of temporal data • Non-temporal data would be data which does not change (in real life, in a system, or we do not store a history of changes in a database)  Bitemporal data is data which changes over 2 dimensions of time independently • SQL:2011 calls this application time with system versioning 6
  • 7. 4 Types of tables No Application Time History Application Time History No System Time History Non-temporal Application time period table System Time History System versioned table System versioned application time period table  Non-temporal tables • Conventional tables (without date/timestamp in PK) • Latest information, without any history  Application time period tables • History of how data changed from an application time perspective as we know it now  System versioned tables • History of how current data from a application time perspective changed in the system (database)  System versioned application time period tables • History, of how history from an application time perspective, changed in the system (database) 7
  • 8. Things to know about temporal features in SQL:2011  Row based versioning • In contrast to column based versioning • But can be use to implement column based versioning  State based storage • 2 timestamps for application time periods • 2 timestamps for system time periods • 4 timestamps for system versioned application time period tables  State based inputs • User provides application period start AND application period end • Users do NOT provide system period start or end • Insert, update, and delete events are converted to states (till high datetime)  Time periods use the Closed – Open convention • AKA inclusive – exclusive • Supports unambiguous comparisons with different precisions  The strengths of the temporal features in SQL:2011 are: • Ease of migration (not dependent on period data type) • Fits well with SQL semantics (no statement modifiers) • Lots of user control (can update application start/end directly) • Compatibility (existing queries work against system versioned tables) 8
  • 9. Primary Keys for 4 Types of Tables  Non-temporal storage • No date/timestamp in PK  Application time period table • 2 timestamps (Application Period Start & Application Period End) is not enough • Application time periods can not overlap for the same object  System versioned table • System time periods should not overlap for the same object (but this is not part of the PK) • 2 rows for the same object can not have the same system start (constraint) • Transaction time is defined by implementation (high level of precision) • Transaction times should be sequential  System versioned application time period table • Application time periods can overlap for the same object • System time periods can overlap for the same object • BOTH application time period AND system time period should NOT overlap for the same object 9
  • 10. Application time period tables • Table definition – Define columns for application period start and end (need to be a date/timestamp data types and not null) – New PERIOD clause specifies what columns implement an application time period and creates an implicit constraint that application time period start < application time period end (pick your period name) – New WITHOUT OVERLAPS keywords in PRIMARY KEY clause ensures that application time periods do not overlap – FOREIGN KEY clause extended to include referencing of period in parent table • Inserting – Normal syntax • Comply with constraints ( start and end not null, start < end, no overlaps) • Deletes – Delete rows with normal syntax • Constrain on application time period start and end as desired or not ! – Delete using FOR PORTION OF application time period FROM DATE XXXX/XX/XX TO DATE XXXX/XX/XX clause results in automatic “row splitting” • Updates – Update rows with normal syntax (including application time period start and end columns) • Comply with constraints (start and end not null, start < end, no overlaps) • Constrain on application time period start and end as desired or not ! – Update using FOR PORTION OF application time period FROM DATE XXXX/XX/XX TO DATE XXXX/XX/XX clause results in automatic “row splitting” • Can’t update application period start or end using this option • Select – Normal Syntax (application time period start and end can be used since they are explicit columns) 10
  • 11. Application time period tables – Delete row splitting - 4 types of existing time slices - • There can be multiple types of existing time slices for a delete range • No error if delete over a range where no values 11
  • 12. Application time period tables – Update row splitting - 4 types of existing time slices - • There can be multiple types of existing time slices for a update range • No error if update over a range where no values • An update can cause multiple contiguous time slices to have the same non PK data values (unpacked) 12
  • 13. System versioned tables • Table definition – Define columns for system time period start and end (need to be date/timestamp data type and not null) with new GENERATE ALWAYS AS ROW BEGIN/END clause – New PERIOD clause with SYSTEM_TIME period name specifies what columns are in the system time period (system time period start < system time period end does not need to be enforced) – New WITH SYSTEM VERSIONING clause implicitly adds system time period start to primary key – Constraints only apply to rows which are not logically deleted – Referential Integrity is not impacted • Inserting – Normal syntax but never specify system time period start or end columns as they are generated – New time slices of data have system time period start = insert transaction time and system period end = high date/time • Deletes – Normal syntax but a history of what data was deleted and when it was deleted is maintained automatically – Deleted time slices of data have system period end = delete transaction time (logically deleted) – Only rows which are not logically deleted can be deleted • Updates – Normal syntax but a history of what data was updated and when it was updated is maintained automatically – Updated time slices of data have system period end = update transaction time (logically deleted) – Only rows which are not logically deleted can be updated • Select – Normal syntax works as if non-temporal table (do not query logically deleted rows) – New as-of, between, and from clauses are available to query all rows in the table • Including logically deleted rows 13
  • 14. System versioned tables – Delete history - 1 type of existing time slice - Not logically deleted Delete range begin = Delete transaction time Delete range end = High date/timestamp Logically deleted • There is only 1 type of existing time slice for a delete range • There can only be 1 time slice of interest for an object (that is not logically deleted) 14
  • 15. System versioned tables – Update History - 1 type of existing time slices - Not logically deleted Delete range begin = Delete transaction time Delete range end = High date/timestamp Not logically Logically deleted deleted • There can only be 1 type of existing time slice for an update range • There can only be 1 time slice of interest for an object (that is not logically deleted) 15
  • 16. System versioned application time period tables • Table definition – Define columns for application time period start and end (need to be date/timestamp data types and not null) – Define columns for system time period start and end (need to be date/timestamp data types and not null) with new GENERATE ALWAYS AS ROW BEGIN/END clause – New PERIOD clause to specifies what columns are in the application time period – New PERIOD clause with SYSTEM_TIME keyword specifies what columns are in system time period – New WITHOUT OVERLAPS keyword in PRIMARY KEY clause ensures that application time periods do not overlap – New WITH SYSTEM VERSIONING clause implicitly adds system time period start to primary key – Constraints only apply to rows which are not logically deleted – FOREIGN KEY clause extended to include referencing of period in parent table • Inserting – Same as application time period tables but never specify system time period start or end columns as they are generated • Deletes – Same as application time period tables but a history of what was deleted and when it was deleted is maintained automatically (rows) – Only rows which are not logically deleted can be deleted • Updates – Same as application time period tables but a history of what was updated and when it was updated is maintained automatically (rows) – Only rows which are not logically deleted can be updated • Select – Same as application period tables – New as-of, between, and from clauses are available to query all rows in the table • Including logically deleted rows 16
  • 17. Bitemporal tables – Delete splitting & history - 4 types of existing application time slices - • Same as application time period table deletes except update existing time slices instead of delete because: • Only 1 type of existing row from system versioning perspective • Application time period table delete splitting results in inserts and deletes • System versioning does not do any splitting for inserts • System versioning changes deletes into updates 17
  • 18. Bitemporal tables – Update splitting & history - 4 types of existing application time slices - • Same as application time period table updates except additional insert of existing time slice because: • Only 1 type of existing row from system versioning perspective • Application time period table update row splitting results in inserts and updates • System versioning does not do any splitting for inserts • System versioning changes updates into an update AND an insert 18
  • 19. Summary & Conclusions • Significant new temporal features have been included in SQL:2011 • Temporal features represent a significant extension to the SQL language that will take time for people to utilize • Vendors are beginning to adopt these features • Methodology for how to utilize new temporal features of SQL will probably be a factor in utilization • Time will tell how much the SQL:2011 temporal extensions are utilized • Implications of temporal extensions on replication, partitioning, archiving etc are still being sorted 19
  • 20. Next Steps • Actual syntax • Examples, Examples and more examples • Advanced topics – Temporal predicates – Joining different types of temporal tables – Referential integrity implications – Schema migration implications • Where are vendors with compliance/adoption • How vendors CAN comply but also differentiate • How vendors ARE differentiating 20
  • 21. Resources  Search YouTube.com for “Case for Bitemporal Data”  http://www.youtube.com/playlist?list=PL4CB3C8161D2804E6  TemporalData.com  “Temporal Data” LinkedIn group  http://www.linkedin.com/groups?gid=3885228  http://stacresearch.com/btd  Functional and performance benchmarks 21
  • 22. THANK YOU! USA UK BitemporalData.com LLC BitemporalData Ltd 1330 Route 206 Suite 13493, 2nd floor Suite 318 145-157 St John Street Skillman, NJ 08558 London EC1V 4PY Tel: +1.201.332.5000 Tel: +44.20.3318.5919 22