Traveling in time with SQL Server 2017

Slides:



Advertisements
Similar presentations
By: Jose Chinchilla July 31, Jose Chinchilla MCITP: SQL Server 2008, Database Administrator MCTS: SQL Server 2005/2008, Business Intelligence DBA.
Advertisements

Virtual training week 4 structured query language (SQL)
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 8 Application Data Auditing.
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 8 Application Data Auditing.
A comparison of MySQL And Oracle Jeremy Haubrich.
Virtual techdays INDIA │ 9-11 February 2011 virtual techdays Auditing Made Easy: Change Tracking and Change Data Capture Pinal Dave │ Technology Evangelist,
Auditing Database DDL Changes with SQLVer. About PASS The PASS community encompasses everyone who uses the Microsoft SQL Server or Business Intelligence.
January 15, Tips for using SQL Server Change Data Capture (Introduction) The Baker’s Dozen Business Intelligence Webcast Radio 13 SQL Server -Business.
DB Audit Expert v1.1 for Oracle Copyright © SoftTree Technologies, Inc. This presentation is for DB Audit Expert for Oracle version 1.1 which.
Adapted from Afyouni, Database Security and Auditing DB Auditing Examples (Ch. 9) Dr. Mario Guimaraes.
Adapted from Afyouni, Database Security and Auditing Database Application Auditing – Ch. 8.
RDB/1 An introduction to RDBMS Objectives –To learn about the history and future direction of the SQL standard –To get an overall appreciation of a modern.
Database Technical Session By: Prof. Adarsh Patel.
1 Oracle Database 11g – Flashback Data Archive. 2 Data History and Retention Data retention and change control requirements are growing Regulatory oversight.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Triggers A Quick Reference and Summary BIT 275. Triggers SQL code permits you to access only one table for an INSERT, UPDATE, or DELETE statement. The.
Understanding SQL Server 2008 Change Data Capture Bret Stateham Training Manager Vortex Learning Solutions blogs.netconnex.com.
USE OF TEMPORAL CONCEPTS IN TRANSACTIONAL DATABASES.
Application Data and Database Activities Auditing Dr. Gabriel.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Master Data Management & Microsoft Master Data Services Presented By: Jeff Prom Data Architect MCTS - Business Intelligence (2008), Admin (2008), Developer.
02 | Data Flow – Extract Data Richard Currey | Senior Technical Trainer–New Horizons United George Squillace | Senior Technical Trainer–New Horizons Great.
SQL Triggers, Functions & Stored Procedures Programming Operations.
Fundamental of Database Systems
Aga Private computer Institute Prepared by: Srwa Mohammad
With Temporal Tables and More
SQL Server Statistics and its relationship with Query Optimizer
Standard/Express edition
Developing modern applications with Temporal Tables and JSON
Temporal Tables Sam Nasr, MCSA, MVP NIS Technologies July 22, 2017
Katowice,
Temporal Databases Microsoft SQL Server 2016
Temporal Databases Microsoft SQL Server 2016
Introduction to SQL 2016 Temporal Tables
Antonio Abalos Castillo
A time travel with temporal tables
Introduction To Database Systems
A time travel With temporal tables Leonel Abreu
Example of a page header
Where I am at: Swagatika Sarangi MDM Lead PASS Summit SQL Saturdays
It’s About Time : Temporal Table Support in SQL Server 2016/2017
Instant Add Columns in MySQL
It’s About Time : Temporal Table Support in SQL Server 2016/2017
<Enter course name here>
Workbench Data Definition Language (DDL)
SQL Azure Database – No CDC, No Problem!
The Basics of Data Manipulation
Please thank our sponsors!
مقدمة في قواعد البيانات
Cloud Data Replication with SQL Data Sync
Data Model.
Adding history to crud (Really) DINO ESPOSITO
SQL .. An overview lecture3.
Please support our sponsors
Data Management Innovations 2017 High level overview of DB
Clustered Columnstore Indexes (SQL Server 2014)
Prof. Arfaoui. COM390 Chapter 9
Change Tracking Live Data Warehouse
Data Time Travel with Temporal Tables
DATABASE Purpose of database
Understanding Core Database Concepts
Reinhard Flügel Possiblities and Limitations of System-Versioned Temporal Tables beyond the Basics.
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.
Dmytro Polishchuk BI Developer DB Best Technologies
Data Time Travel with Temporal Tables
Implementing ETL solution for Incremental Data Load in Microsoft SQL Server Ganesh Lohani SR. Data Analyst Lockheed Martin
Presentation transcript:

Traveling in time with SQL Server 2017 Damian Widera Dominika Widera Traveling in time with SQL Server 2017

Thanks to our sponsors!

Damian Widera 15+ years of experience with SQL Server Data Platform MVP & MCT Microsoft Certified Solutions Expert Data Management and Analytics Business Intelligence http://sqlplayer.net/ Dominika Widera YouTube: dvkx (easy programing for kids!)

Traveling in time

Traveling in time with SQL Server 2017 Time travelling – how to make it possible with SQL Server 2016 At least in terms of data not actual time journey

A little bit of the history How do you monitor data changes now? Triggers Stored procedures Change Data Capture (CDC) Change Tracking (CT) How to do it with Temporal Tables Scenarios How it works? Developers …. Performance ….

Triggers All SQL Server versions & editions Easy to implement - INSERT, UPDATE, DELETE But – changing the source table definition almost always require to change the code of the trigger Interact with other triggers – @@IDENTITY Transactional

Stored procedures All SQL Server versions & editions Could be easy to implement Changing the source table structure possibly require the change in the procedure Called from the applications

Change tracking Tracks changes on DML operations like INSERT, UPDATE and DELETE Only last version of data No historical changes How many times a record has changed? A table can have only one CT related table

Change Data Capture Tracks changes on DML operations like INSERT, UPDATE and DELETE All changes are stored Full changes history A table can have up to two CDC related tables

Why temporal Data changes over time Temporal in DB Tracking and analyzing changes is often important Temporal in DB Automatically tracks history of data changes Enables easy querying of historical data states Advantages over workarounds Simplifies app development and maintenance Efficiently handles complex logic in DB engine Time travel Data audit Slowly changing dimensions Repair record-level corruptions

How to start - remarks Primary key must be present on the base table Turn on the SYSTEM_VERSIONING option on a table to make it temporal Add two non-nullable columns of type DATETIME2() that represents the start and the end od period when the row is valid A column that represents the start of the period must be marked as GENERATED ALWAYS AS ROW START A column that represents the end of the period must be marked as GENERATED ALWAYS AS ROW END

How to start – remarks - cont. Add a statement at the table level for setting up the per: PERIOD FOR SYSTEM_TIME (<startcol>, <endcol>) The historical table can be created: By the SQL Server By the user In both cases the historical table will be PAGE compressed

How to start – remarks - cont. The DML operations cannot affect the columns that store the period information True if the SYSTEM_VERSIONING is turned on TRUNCATE TABLE will not work with the SYSTEM_VERSIONING option turned on The DML cannot be done on the historical table DBCC CHECKCONSTRAINTS works little bit different https://msdn.microsoft.com/en-us/library/ms189496.aspx

No change in programming model How to start with temporal ANSI 2011 compliant No change in programming model New Insights FOR SYSTEM_TIME AS OF FROM..TO BETWEEN..AND CONTAINED IN Temporal Querying CREATE temporal TABLE PERIOD FOR SYSTEM_TIME… ALTER regular_table TABLE ADD PERIOD… DDL INSERT / BULK INSERT UPDATE DELETE MERGE DML SELECT * FROM temporal Querying Performance

“Get actual row versions” How the AS OF works – historical data Department (actual data) DepNum DepName MngrID From To A001 Marketing 6 2008 ∞ A002 Sales 5 2007 “Get actual row versions” AS OF BETWEEN..AND CONTAINED IN Department (actual and historical data) DepNum DepName MngrID A001 Marketing 5 6 A002 Sales 2 A003 Consulting 10 Department (historical data) A001 ∞ DepNum DepName MngrID From To A001 Marketing 5 2005 2008 A002 Sales 2 2007 A003 Consulting 6 2006 10 2009 2012 A001 A002 ∞ A002 A003 A003 2005 2015 SELECT * FROM Department FOR SYSTEM_TIME AS OF '2006.01.01' SELECT * FROM Department FOR SYSTEM_TIME CONTAINED IN ('2007.01.01', '2009.01.01') SELECT * FROM Department FOR SYSTEM_TIME BETWEEN '2006.01.01' AND '2007.01.01' Valid data „Now” SELECT * FROM Department

How does system-time work? Temporal table (actual data) History table * Old versions Update */ Delete * Insert / Bulk Insert

* Include historical version How does system-time work? Temporal table (actual data) History table * Include historical version Regular queries (current data) Temporal queries * (Time travel, etc.)

Temporal data continuum SQL Database Temporal queries

Thanks to our sponsors!