Temporal Databases Am I a good guy or a bad guy?.

Slides:



Advertisements
Similar presentations
Author: Graeme C. Simsion and Graham C. Witt Chapter 11 Logical Database Design.
Advertisements

Relational Database and Data Modeling
10 Copyright © 2005, Oracle. All rights reserved. Dimensions.
Introduction to Relational Database Systems 1 Lecture 4.
Relational data integrity
1 Term 2, 2004, Lecture 6, Views and SecurityMarian Ursu, Department of Computing, Goldsmiths College Views and Security 3.
Data Definition and Integrity Constraints
TSQL 2 : QUERY LANGUAGE FOR TEMPORAL DATA CS 224 : Advanced Topics in Data Management.
Dimensional Modeling.
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Tips and Tricks for Dimensional Modeling
CHAPTER OBJECTIVE: NORMALIZATION THE SNOWFLAKE SCHEMA.
Chapter 10: Designing Databases
From Handbook of Temporal Reasoning in Artificial Intelligence By Jan Chomicki & David Toman Temporal Databases Presented by Leila Jalali CS224 presentation.
Data Warehouse Overview (Financial Analysis) May 02, 2002.
MSc IT UFCE8K-15-M Data Management Prakash Chatterjee Room 2Q18
Copyright © C. J. Date 2005page 1 AGENDA : 1. A few preliminaries 2. Laying the foundations 3.Building on the foundations.
Compiler Construction
Manipulating Data Schedule: Timing Topic 60 minutes Lecture
Navigator Management Partners LLC Business Analysis Professional Development Day – Sep 2014 How to understand and deliver requirements to your Business.
Advanced Databases Temporal Databases Dr Theodoros Manavis
Time in Databases CSCI 6442 With thanks to Richard Snodgrass, 1985 ACM /85/005/0236.
Accounting System Design
A Practical Introduction to Transactional Database Modeling and Design Mike Burr.
Data Warehouse IMS5024 – presented by Eder Tsang.
Temporal Databases. Outline Spatial Databases Indexing, Query processing Temporal Databases Spatio-temporal ….
Chapter 3 An Introduction to Relational Databases.
10/3/2000SIMS 257: Database Management -- Ray Larson Relational Algebra and Calculus University of California, Berkeley School of Information Management.
RIZWAN REHMAN, CCS, DU. Advantages of ORDBMSs  The main advantages of extending the relational data model come from reuse and sharing.  Reuse comes.
Sayed Ahmed Logical Design of a Data Warehouse.  Free Training and Educational Services  Training and Education in Bangla: Training and Education in.
Best Practices for Data Warehousing. 2 Agenda – Best Practices for DW-BI Best Practices in Data Modeling Best Practices in ETL Best Practices in Reporting.
Chapter 3 An Introduction to Relational Databases.
Data Warehousing Seminar Chapter 5. Data Warehouse Design Methodology Data Warehousing Lab. HyeYoung Cho.
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.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
SQL Structured Query Language Programming Course.
An Investigation of Oracle and SQL Server with respect to Integrity, and SQL Language standards Presented by: Paul Tarwireyi Supervisor: John Ebden.
RDBMSSection Relational DBMS DATABASE DEVELOPMENT And Franchise Colleges By MANSHA NAWAZ.
Organizing Data Revision: pages 8-10, 31 Chapter 3.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Triggers. Why Triggers ? Suppose a warehouse wishes to maintain a minimum inventory of each item. Number of items kept in items table Items(name, number,...)
6.1 © 2010 by Prentice Hall 6 Chapter Foundations of Business Intelligence: Databases and Information Management.
More Dimensional Modeling. Facts Types of Fact Design Transactional Periodic Snapshot –Predictable time period –Ex. Monthly, yearly, etc. Accumulating.
INTRODUCTION lecture1 1. Data base concept Data is a meaningless static value. What does 3421 means? Information is the data you process in a manner that.
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Normalisation RELATIONAL DATABASES.  Last week we looked at elements of designing a database and the generation of an ERD  As part of the design and.
June 08, 2011 How to design a DATA WAREHOUSE Linh Nguyen (Elly)
Temporal Data Modeling
44271: Database Design & Implementation Physical Data Modelling Ian Perry Room: C49 Tel Ext.: 7287
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
Databases Flat Files & Relational Databases. Learning Objectives Describe flat files and databases. Explain the advantages that using a relational database.
CPT-S Advanced Databases 11 Yinghui Wu EME 49.
The Need for Data Analysis 2 Managers track daily transactions to evaluate how the business is performing Strategies should be developed to meet organizational.
Data Resource Management Application Layer TPS A RCHITECTURE Data Layer Sales/MarketingHR Finance/Accounting Operations Spreadsheet Data MS Access Accounts.
 CONACT UC:  Magnific training   
CH 10 DB Application Design n 10.1 Functions n 10.2 Case Application n 10.3 Creating, Reading, Updating, Deleting View n 10.4 Form Design n 10.5 Report.
Building the Corporate Data Warehouse Pindaro Demertzoglou Lally School of Management Data Resource Management.
Database Design Using Normalization
Introduction lecture1.
Temporal Databases.
Data Model.
Retail Sales is used to illustrate a first dimensional model
INSTRUCTOR: MRS T.G. ZHOU
Prof. Arfaoui. COM390 Chapter 9
Presentation transcript:

Temporal Databases (Managing time varying data) Rob Squire - UK Consulting

Temporal Databases Am I a good guy or a bad guy?

Temporal Databases Interval Data Type (Timestamps) 6NF (horizontal and vertical decomposition aka TNF) Pack/UnPack (Collapsed form) No ‘special’ attributes SQL with no extensions

Temporal Databases What are temporal databases? What is time varying data? Implementation Approaches Why now? Demonstration Questions and Answers

Temporal Databases What are temporal databases? What is time varying data? Implementation Approaches Why now? Demonstration Questions and Answers

What are temporal databases? Non Temporal store only a single state of the real world, usually the most recent state classified as snapshot databases application developers and database designers need to code for time varying data requirements eg history tables, forecast reports etc

What are temporal databases? stores upto two dimensions of time i.e VALID (stated) time and TRANSACTION (logged) time Classified as historical, rollback or bi-temporal No need for application developers or database designers to code for time varying data requirements i.e time is inherently supported

What are temporal databases? Valid (stated) Time The 2 dimensions of time Transaction (logged) Time

What are temporal databases? Valid (stated) Time Granularity of the time axis Chronons can be days, Seconds, milliseconds depending on the application domain Transaction (logged) Time

What are temporal databases? Valid (stated) Time The moving point ‘now’ Transaction (logged) Time

What are temporal databases? We can use these two dimensions to distinguish between different forms of temporal database A rollback database stores data with respect to transaction time e.g. Oracle 10g has flashback query A historical database stores data with respect to valid time A bi-temporal database stores data with respect to both valid time and transaction time.

Temporal Databases What are temporal databases? What is time varying data? Implementation Approaches Why now? Demonstration Questions and Answers

What is time varying data? You want a reprint of a customer's invoice of August 12, 1999. What was the stock value of the Oracle shares on June 15th, last year? What was the lowest stock quantity for every product last year? How much money will you save, if you keep the stocks at those levels? Where do you enter the new address of this customer as from the first of next month? What will your profits be next month, given the price list and cost prices by then?

What is time varying data? And combinations of the situations can be very complex  You offered these goods to the customer on January 10 this year. What were the billing prices and what was his discount level when you sent him this offer? He has not accepted yet. Is it smart to offer him an actualized discount now? Given the final settlements for all the insurance claims of the last three years, what will be the minimum insurance premium your customers have to pay next year?

What is time varying data? Examples of application domains dealing with time varying data: Financial Apps (e.g. history of stock market data) Insurance Apps (e.g. when were the policies in effect) Reservation Systems (e.g. when is which room in a hotel booked) Medical Information Management Systems (e.g. patient records) Decision Support Systems (e.g. planning future contigencies) CRM applications (eg customer history / future) HR applications (e.g Date tracked positions in hierarchies)

What is time varying data? In fact, time varying data has ALWAYS been in business requirements – but existing technology does not deal with it elegantly!

What is time varying data? Ask yourself two questions Does your business need to know the situation as it was known at a particular date (e.g. the reprint of the customer's invoice)? Does your business use information that was effective in the past or will become effective in the future (e.g. the new address of the customer)?

What is time varying data? If you answer "Yes" on one or both of these questions then your data varies over time and you could consider adopting a temporal approach

Temporal Databases What are temporal databases? What is time varying data? Implementation Approaches Why now? Demonstration Questions and Answers

Implementation Approaches Several implementation strategies are available Use a date type supplied in a non-temporal DBMS and build temporal support into applications (traditional) Implement an abstract data type for time (object oriented) Provide a program layer (api) above a non-temporal data model (stratum)

Implementation Approaches Generalise a non-temporal data model into a temporal data model (Temporal Normal Form) Re-design core database kernel (Temporal Database)

Implementation Approaches Q: Why don’t temporal databases already exist? A: Dealing with time-varying data is complex

Implementation Approaches For example: Avoiding duplicates requires complex logic. Avoiding gaps in a time-varying data requires complex logic. A simple join when applied to time-varying data turns into many lines of code consisting of multiple FROM and WHERE clauses. A simple update translates into several modification statements requiring many lines of code.

Temporal Databases What are temporal databases? What is time varying data? Implementation Approaches Why now? Demonstration Questions and Answers

Why now? Plummeting cost of storage Widespread adoption of warehouse technology has led to an increasing interest in temporal databases The idea of maintaining and processing historical data has become not just a goal but a reality for many organisations

Why now? DW vendors are themselves faced with temporal problems (slowly changing time dimension) and have begun to feel the need for a new solution DB Vendors considering adding temporal support to existing product (Oracle flashback query) and applications (Oracle HR date tracking/payroll) SQL bodies are beginning to think about adding syntax to the standard to support temporal features (SQL3, TSQL)

Temporal Databases What are temporal databases? What is time varying data? Implementation Approaches Why now? Demonstration Questions and Answers

Demonstration Temporal Normal Form (approach 4) Generate TNF for supplier, supplier part schema Show select, insert, update and delete operations Show Referential Integrity With a Temporal Data Dictionary Using simple standard SQL with no extensions

Demonstration Now Fix Valid Time SUPPLIER

Demonstration Timestamp or Now + 2 days Fix Valid Time SUPPLIER

Demonstration Fix Transaction Time SUPPLIER Now

Demonstration Fix Transaction Time SUPPLIER Timestamp or Now - 2 days

Demonstration Fix Transaction and Valid Time SUPPLIER

Demonstration Demo 01 Generating, populating and querying TNF

Demonstration Non Temporal Schema (SP) TNF Temporal Schema (TSP) SUPPLIER SUPPLIER PART Example schema taken from Temporal Data and the Relational Model by CJ Date, H Darwin, NA Lorentzos (2003)

Demonstration Non Temporal Schema (SP) TNF Temporal Schema (TSP) SUPPLIER SUPPLIER Generate SUPPLIER PART SUPPLIER PART

Demonstration Record Timestamp 1 03-NOV-05 15.45.23.125990000

Demonstration Non Temporal Schema (SP) TNF Temporal Schema (TSP) SUPPLIER SUPPLIER Populate Insert as Select * from SUPPLIER PART SUPPLIER PART

t0(now) Transaction time = now DEMO 1

t1(now) S1 S2 S3 S4 S5 Transaction time = now DEMO 1

Demonstration Fix Valid Time timestamp1 SUPPLIER

t2(timestamp1) S1 S2 S3 S4 S5 Transaction time = now DEMO 1

Demonstration Un Fix Valid Time SUPPLIER Now

t3 (now) S1 S2 S3 S4 S5 Transaction time = now DEMO 1

Demonstration Fix Valid Time Now + 2 days SUPPLIER

t4 (now+2days) S1 S2 S3 S4 S5 Transaction time = now DEMO 1

delete S1 S2 S3 S4 S5 Transaction time = now DEMO 1

Demonstration Un Fix Valid Time SUPPLIER Now

t5 (now) S1 S2 S3 S4 S5 Transaction time = now DEMO 1

eovt S1 S2 S3 S4 S5 Transaction time = now DEMO 1

t6 (now) S1 S2 S3 S4 S5 Transaction time = now DEMO 1

Demonstration Record Timestamp 2 03-NOV-05 15.57.04.334588000

Demonstration Now + 30 seconds Fix Valid Time SUPPLIER

t7(now+30 seconds) S1 S2 S3 S4 S5 Transaction time = now DEMO 1

delete S1 S2 S3 S4 S5 Transaction time = now DEMO 1

Demonstration Un Fix Valid Time SUPPLIER Now

t8(now) S1 S2 S3 S4 S5 Transaction time = now DEMO 1

t9(now) S1 S2 S3 S4 S5 Transaction time = now DEMO 1

Demonstration Demo 02 Fixing transaction time

t10(now) 33 S1 S2 S3 S4 S5 Transaction time = now DEMO 2

t11(now) 45 S1 S2 S3 S4 S5 Transaction time = now DEMO 2

t12(now) 65 S1 S2 S3 S4 S5 Transaction time = now DEMO 2

Demonstration Fix Transaction Time SUPPLIER Timestamp 2

t13(now) 171000 S1 S2 S3 S4 S5 Transaction time < t7 DEMO 2

t14(now) 170900 S1 S2 S3 S4 S5 Transaction time < t7 DEMO 2

t15(now) 170800 S1 S2 S3 S4 S5 Transaction time < t7 DEMO 2

Lifetime >2 days S1 S2 S3 S4 S5 Transaction time < t7 DEMO 2

Demonstration UnFix Transaction Time SUPPLIER Now

t16(now) Lifetime 1 hour S1 S2 S3 S4 S5 Transaction time = now DEMO 2

Demonstration Demo 03 (part1) DML not allowed when transaction time is fixed

Demonstration Fix Transaction Time SUPPLIER Current Timestamp

t17(now) ORA-20001: S: Cannot insert while system Y time is set. Transaction time <> now DEMO 3

Demonstration UnFix Transaction Time SUPPLIER Now

Demonstration Demo 03 (part 2) Updating in TNF

Demonstration Now – 10 days Fix Valid Time SUPPLIER

t18(now-10days) London Paris Paris London Athens Transaction time = now DEMO 3

Demonstration Now – 8 days Fix Valid Time SUPPLIER

t19(now-8days) London Paris Lyons Paris Lyons London Athens Transaction time = now DEMO 3

Demonstration Now – 6 days Fix Valid Time SUPPLIER

t20(now-6days) London Paris Lyons Paris Lyons London Athens Corinth Transaction time = now DEMO 3

Demonstration Now – 4 days Fix Valid Time SUPPLIER

t21(now-4days) London Manchester Paris Lyons Paris Lyons London Manchester Athens Corinth Transaction time = now DEMO 3

Demonstration Un Fix Valid Time SUPPLIER Now

t22(now) London Manchester Paris Lyons Paris Lyons London Manchester Athens Corinth Transaction time = now DEMO 3

t18 t19 t20 t21 London Manchester Paris Lyons Paris Lyons London Manchester Athens Corinth Transaction time = now DEMO 3

Demonstration Demo 04 (part1) Maintaining Referential Integrity

Demonstration Un Fix Valid Time SUPPLIER Now

t23(now) S SP ORA-20001: :Integrity Constraint violated – parent key not found Transaction time = now DEMO 4 (showing one S relvar)

t23(now) S SP Transaction time = now DEMO 4 (showing one S relvar)

t23(now) S SP Transaction time = now DEMO 4 (showing one S relvar)

Demonstration Demo 04 (part2) Foreign Key Rules for TNF

Demonstration Now – 10 days Fix Valid Time SUPPLIER

t24(now-10days) S1 Transaction time = now DEMO 4 (showing one S relvar)

Demonstration Un Fix Valid Time SUPPLIER Now

t25(now) S1 Transaction time = now DEMO 4 (showing one S relvar)

Demonstration Now – 5 days Fix Valid Time SUPPLIER

t26(now-5days) S1 S1,P1 ORA-20001: :Integrity Constraint violated – parent key not found Transaction time = now DEMO 4 (showing one S relvar)

t26(now-5days) S1 delete restrict S1,P1 Delete rule on foreign key constraint SP_S_FK is RESTRICT Transaction time = now DEMO 4 (showing one S relvar)

t26(now-5days) S1 delete cascade S1,P1 Delete rule on foreign key constraint SP_S_FK is CASCADE Transaction time = now DEMO 4 (showing one S relvar)

Demonstration Un Fix Valid Time SUPPLIER Now

t27(now) S1 S1,P1 Transaction time = now DEMO 4 (showing one S relvar)

Demonstration Demo 05 A more complex example

Demonstration UnFix Transaction Time SUPPLIER Now

Demonstration Now – 100 days Fix Valid Time SUPPLIER

S1,P1 S1,P2 S1,P3 S2,P4 S2,P5 S2,P6 S3,P1 S3,P3 S3,P6 S1,P4 S1,P5 Transaction time = now DEMO 5 (showing all SP relvars)

S1,P1 S2 S1,P2 S3 S1,P3 S2,P4 S2,P5 S1 S1 S2,P6 S3,P1 S3,P3 QUERY A – Page 74 List of dates each supplier was able to supply at least one part S3,P6 S1,P4 S1,P5 Transaction time = now DEMO 5 (showing all SP relvars)

S1,P1 S1,P2 S1 S1 S1,P3 S1 S2,P4 S2 S2 S2,P5 S2,P6 S3 S3 S3,P1 S3,P3 QUERY B – Page 75 List of dates each supplier was unable to supply at least one part S3,P6 S1,P4 S1,P5 Transaction time = now DEMO 5 (showing all SP relvars)

Demonstration Demo 06 (part1) The classic Employee Department schema example

Demonstration Un Fix Valid Time SUPPLIER Now

Demonstration UnFix Transaction Time SUPPLIER Now

t28(now) Dept 10, Sales, New York Transaction time = now DEMO 6 (showing Dept relvar)

t29(now) Dept 10, Sales, New York Dept 20, Finance, New York Transaction time = now DEMO 6 (showing Dept relvars)

t30(now) Dept 10, Sales, New York Dept 20, Finance, New York Emp 1, John, Clerk,…,Dept 10 Transaction time = now DEMO 6 (showing Dept/Emp relvars)

Demonstration Now + 20 days Fix Valid Time SUPPLIER

t31(now+20) Dept 10, Sales, New York Dept 20, Finance, New York Emp 1, John, Clerk,…,Dept 10 Transaction time = now DEMO 6 (showing Dept/Emp relvars)

Demonstration Un Fix Valid Time SUPPLIER Now

t32(now) Dept 10, Sales, New York Dept 20, Finance, New York delete restrict Emp 1, John, Clerk,…,Dept 10 ORA-20001: :Integrity Constraint violated – parent key not found Transaction time = now DEMO 6 (showing Dept/Emp relvars)

t33(now) Dept 10, Sales, New York Dept 20, Finance, New York delete cascade Emp 1, John, Clerk,…,Dept 20 Transaction time = now DEMO 6 (showing Dept/Emp relvars)

Demonstration Demo 06 (part2) Non Transferable foreign keys

t33(now) Dept 10, Sales, New York Dept 20, Finance, New York transferable Emp 1, John, Clerk,…,Dept 20 Transaction time = now DEMO 6 (showing Dept/Emp relvars)

t34(now) Dept 10, Sales, New York Dept 20, Finance, New York Non transferable Emp 1, John, Clerk,…,Dept 20 ORA-20001: :Illegal attempt to modify non-transferable foreign key. Transaction time = now DEMO 6 (showing Dept/Emp relvars)

t34(now) Dept 10, Sales, New York Dept 20, Finance, New York Non transferable Emp 1, John, Clerk,…,Dept 20 Transaction time = now DEMO 6 (showing Dept/Emp relvars)

Demonstration You have just seen A practical implementation of TNF Using Standard SQL Where existing data modelling techniques for current view apply Providing bi temporal support Can underpin any application development platform (forms, java, html etc)

Demonstration Next Steps Gather feedback and responses on TNF from Oracle user organisations Contact Oracle Expert Services 0870 550 3060 expertservices_uk@oracle.com www.oracle.com/uk/expert_services

Q & A Q U E S T I O N S A N S W E R S Rob Squire UK Consulting rob.squire@oracle.com