A time travel with temporal tables

Slides:



Advertisements
Similar presentations
Building Enterprise Applications Using Visual Studio ®.NET Enterprise Architect.
Advertisements

Implementing Business Analytics with MDX Chris Webb London September 29th.
Dual Partitioning for improved performance in VLDBs Ashwin Rao Karavadi, Rakesh Parida Microsoft IT.
Understanding SQL Server 2008 Change Data Capture Bret Stateham Training Manager Vortex Learning Solutions blogs.netconnex.com.
SQL Triggers, Functions & Stored Procedures Programming Operations.
SQL 2016 – WHAT’S NEW? David Cobb Daveslog.com.
1 Agenda TMA02 M876 Block 4. 2 Model of database development data requirements conceptual data model logical schema schema and database establishing requirements.
Extending and Creating Dynamics AX OLAP Cubes
Microsoft /6/ :06 AM BRK3152 Achieve developer productivity with SQL Server 2016 and Azure SQL Database Borko Novakovic, Senior Program Manager.
State of Azure SQL Database
Building Enterprise Applications Using Visual Studio®
With Temporal Tables and More
Developing modern applications with Temporal Tables and JSON
Temporal Tables Sam Nasr, MCSA, MVP NIS Technologies July 22, 2017
SQL Server 2016 How can Hoster Partners make money with SQL 2016?
Data Platform and Analytics Foundational Training
Katowice,
Temporal Databases Microsoft SQL Server 2016
Microsoft /2/2018 3:42 PM BRK3129 Query Big Data using the Expanded T-SQL footprint with PolyBase in SQL Server 2016 Casey Karst Program Manager.
Temporal Databases Microsoft SQL Server 2016
Introduction to SQL 2016 Temporal Tables
Antonio Abalos Castillo
SQL 2016 new Hosting Offers Secure Database Hybrid HyperScale
6/12/2018 2:19 PM BRK3245 DirectQuery in Analysis Services: best practices, performance, and use cases Marco Russo SQLBI © Microsoft Corporation. All rights.
6/16/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
What’s New in SQL Server 2016 Master Data Services
A time travel With temporal tables Leonel Abreu
Example of a page header
Design Seamless Upgrades to SQL Server 2016 with Query Store
Azure API Management Jothi Prakash A
Mission-critical performance with Microsoft SQL Server 2016
Add intelligence to Dynamics AX with Cortana Intelligence suite
Upgrading to SQL Server 2016
Entity Based Staging SQL Server 2012 Tyler Graham
Analytics for Apps: Landing and Loading Data into SQL Data Warehouse
Security enhancements in SQL Server 2016
Power Apps & Flow for Microsoft Dynamics SL
It’s About Time : Temporal Table Support in SQL Server 2016/2017
ISC440: Web Programming 2 Server-side Scripting PHP 3
Traveling in time with SQL Server 2017
It’s About Time : Temporal Table Support in SQL Server 2016/2017
Armando Lacerda
<Enter course name here>
BRK2279 Real-World Data Movement and Orchestration Patterns using Azure Data Factory Jason Horner, Attunix Cathrine Wilhelmsen, Inmeta -
SQL Server 2016 Query Data Store
SQL Server on Linux: High Availability And Disaster Recovery
Learn. Imagine. Build. .NET Conf
Armando Lacerda
Adding history to crud (Really) DINO ESPOSITO
TechEd /15/2019 8:08 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Sunil Agarwal | Principal Program Manager
Please support our sponsors
Stretch Database - Historical data storage in SQL Server 2016
What query folding means to self-service BI projects
Welcome to Azure Notebooks
Unleashing Stretched Databases
Zero to Tabular Patrick LeBlanc Data Platform Solution Architect
4/20/ :00 PM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
Armando Lacerda
Armando Lacerda
Data Time Travel with Temporal Tables
Playing with (M)agic: Introduction to Writing M Code in Power BI
System Center Operations Manager Assessment Results
Reinhard Flügel Possiblities and Limitations of System-Versioned Temporal Tables beyond the Basics.
SQL-Server System-Versioned Temporal Tables -Foundation
Reinhard Flügel Possiblities and Limitations of System-Versioned Temporal Tables beyond the Basics.
Data Time Travel with Temporal Tables
Reinhard Flügel Possiblities and Limitations of System-Versioned Temporal Tables beyond the Basics.
Microsoft Ignite NZ October 2016 SKYCITY, Auckland.
Data Time Travel with Temporal Tables
Presentation transcript:

A time travel with temporal tables Leonel Abreu – labreu@seidor.es http://www.geekswithblogs.net/leabreu #516 | Bucharest 2016

Agenda What’s a Temporal Table? It’s useful for A Short “How to” Advantages and how to use it It’s useful for Auditing efects Disaster Recovery Trending Analytics A Short “How to” Scenario and demo

What is a temporal table? Also known as System Versioned Because keep changes Just two extra columns To define periods Finally a second table Which contains the history A system-versioned temporal table is a new type of user table in SQL Server 2016, designed to keep a full history of data changes and allow easy point in time analysis. This type of temporal table is referred to as a system-versioned temporal table because the period of validity for each row is managed by the system (i.e. database engine). Every temporal table has two explicitly defined columns, each with a datetime2 data type. These columns are referred to as period columns. These period columns are used exclusively by the system to record period of validity for each row whenever a row is modified. In addition to these period columns, a temporal table also contains a reference to another table with a mirrored schema. The system uses this table to automatically store the previous version of the row each time a row in the temporal table gets updated or deleted. This additional table is referred to as the history table, while the main table that stores current (actual) row versions is referred to as the current table or simply as the temporal table. During temporal table creation users can specify existing history table (must be schema compliant) or let system create default history table. Source: https://msdn.microsoft.com/en-us/library/dn935015.aspx

How does it work? Source: https://msdn.microsoft.com/en-us/library/dn935015.aspx

How does it work? Source: https://msdn.microsoft.com/en-us/library/dn935015.aspx

Advantages Security Easy to maintain Can be used Is not possible to modify the historical data Easy to maintain Additional coding to insert/update/delete data is not required Can be used For new tables For existing tables

Why temporal tables? Auditing Time Travel Recovering All data changes and forensics if necessary Time Travel State of data as of any time in the past Recovering From accidental data changes, as undesired DELETE operations

Why temporal tables? Calculate Also BI Schema included Trends over time Also BI Can be used to do SCD Schema included If the table structure is changed, it is also recorded

Why temporal tables? Real data sources are dynamic 6/26/2018 3:05 PM Why temporal tables? Real data sources are dynamic Historical data may be critical to business success Traditional databases fail to provide required insights Workarounds are… Complex, expensive, limited, inflexible, inefficient SQL Server 2016 makes life easy No change in programming model New Insights © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Why temporal tables? Azure SQL Database Facts: Solution: Microsoft Ignite 2015 6/26/2018 3:05 PM Why temporal tables? Facts: History is much bigger than actual data Retained between 3 and 10 years “Warm”: up to a few weeks/months “Cold”: rarely queried SELECT * FROM Department FOR SYSTEM_TIME AS OF '2010.01.01' Azure SQL Database Solution: history as a stretch table: PeriodEnd < “Now - 6 months” © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

How to implement it? Source: https://msdn.microsoft.com/en-us/library/dn935015.aspx

How to implement it?

Query Clauses AS OF FROM TO SysStartTime SysStartTime <= date_time SysEndTime > date_time FROM TO SysStartTime < end_date_time SysEndTime > start_date_time

Query Clauses BETWEEN AND CONTAINED IN ALL SysStartTime <= end_date_time SysEndTime > start_date_time CONTAINED IN SysStartTime >= end_date_time SysEndTime <= start_date_time ALL Returns the union between the current and history table

Demo

Q & A

La revedere

Interesting resources Getting Started with System-Versioned Tables https://msdn.microsoft.com/en-us/library/mt604462.aspx Temporal Tables https://msdn.microsoft.com/en-us/library/dn935015.aspx Changing the Schema of a System-Versioned Temporal Table https://msdn.microsoft.com/en-us/library/mt591016.aspx Querying Data in a System-Versioned Temporal Table https://msdn.microsoft.com/en-us/library/mt591018.aspx