CS240A: Databases and Knowledge Bases Temporal Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles.

Slides:



Advertisements
Similar presentations
Temporal Databases S. Srinivasa Rao April 12, 2007
Advertisements

1 Efficient Temporal Coalescing Query Support in Relational Database Systems Xin Zhou 1, Carlo Zaniolo 1, Fusheng Wang 2 1 UCLA, 2 Simens Corporate Research.
CS240A: Databases and Knowledge Bases Temporal Applications and SQL:1999 Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
CS 540 Database Management Systems
Advanced Databases Temporal Databases Dr Theodoros Manavis
Threats to privacy in the forensic analysis of database systems Patrick Stahlberg, Gerome Miklau, and Brian Neil Levine Department of Computer Science.
CIT 613: Relational Database Development using SQL Introduction to SQL.
Manish Bhide, Manoj K Agarwal IBM India Research Lab India {abmanish, Amir Bar-Or, Sriram Padmanabhan IBM Software Group, USA
M.S. Access Module CAS 133 Russ Erdman. M.S. Access Module Assignment Overview Two options for the unit: All students complete Units A, B and C In class.
CS240A: Databases and Knowledge Bases Time Ontology and Representations Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Spatio-Temporal Databases
Temporal Databases. Outline Spatial Databases Indexing, Query processing Temporal Databases Spatio-temporal ….
1 SYS366 Week 1 - Lecture 2 How Businesses Work. 2 Today How Businesses Work What is a System Types of Systems The Role of the Systems Analyst The Programmer/Analyst.
CS240A: Databases and Knowledge Bases A Taxonomy of Temporal DBs Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Recap of Feb 27: Disk-Block Access and Buffer Management Major concepts in Disk-Block Access covered: –Disk-arm Scheduling –Non-volatile write buffers.
Ch1: File Systems and Databases Hachim Haddouti
CS240A: Databases and Knowledge Bases Time Ontology and Representations Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
The need for Temporal Databases (1)Need for coping with temporal data (both VT and TT) (2)Just adding 1 (or 2, or 4) temporal attributes (and maybe some.
Overview of Transaction Processing and Enterprise Resource Planning Systems Chapter 2.
Chapter 11 Management Decision Making
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos OO and OR DBMSs.
© 2009 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Career Education Computers in the Medical Office Chapter 3: Introduction to.
CS462: Introduction to Database Systems. ©Silberschatz, Korth and Sudarshan1.2Database System Concepts Course Information Instructor  Kyoung-Don (KD)
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 1: Introduction.
Module Title? DBMS Introduction to Database Management System.
Data Warehousing Seminar Chapter 5. Data Warehouse Design Methodology Data Warehousing Lab. HyeYoung Cho.
Introduction to Database Systems Motivation Irvanizam Zamanhuri, M.Sc Computer Science Study Program Syiah Kuala University Website:
ITOM 2308 Introduction to Databases Review Access Database Corporate Case Study ITOM 2308 Class 81.
Database Management 9. course. Execution of queries.
© 2007 by Prentice Hall 1 Introduction to databases.
©Silberschatz, Korth and Sudarshan13.1Database System Concepts Chapter 13: Query Processing Overview Measures of Query Cost Selection Operation Sorting.
1-1 System Development Process System development process – a set of activities, methods, best practices, deliverables, and automated tools that stakeholders.
Daniel J. Abadi · Adam Marcus · Samuel R. Madden ·Kate Hollenbach Presenter: Vishnu Prathish Date: Oct 1 st 2013 CS 848 – Information Integration on the.
File Systems and Databases Lecture 1. Files and Databases File: A collection of records or documents dealing with one organization, person, area or subject.
Chapter No 4 Query optimization and Data Integrity & Security.
Fushen Wang, XinZhou, Carlo Zaniolo Using XML to Build Efficient Transaction- Time Temporal Database Systems on Relational Databases In Time Center, 2005.
Advanced SQL: Triggers & Assertions
資工所 在職碩一 P 莊浚銘 Temporal Database Paper Reading Report.
“Request For System Change” Sushil Bhatnagar MBA(IT) 4 th Semester Sikkim Manipal University (SMU DE) Roll No. : LC Code. : IICE College (02086)
Database Systems Lecture 1. In this Lecture Course Information Databases and Database Systems Some History The Relational Model.
Mr.Prasad Sawant, MIT Pune India Introduction to DBMS.
CSC 370 – Database Systems Introduction Instructor: Alex Thomo.
CIT 613: Relational Database Development using SQL Introduction to SQL DeSiaMorePowered by DeSiaMore 1.
Database Management Systems
CS240A: Databases and Knowledge Bases Temporal Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
CS240A: Databases and Knowledge Bases Temporal Applications and SQL Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Temporal Data Modeling
Where does time go ?. Applications abound Temporal database systems provide built-in support for recording and querying time-varying information Application.
CS240A: Databases and Knowledge Bases TSQL2 Carlo Zaniolo Department of Computer Science University of California, Los Angeles Notes From Chapter 6 of.
ASET 1 Amity School of Engineering & Technology B. Tech. (CSE/IT), III Semester Database Management Systems Jitendra Rajpurohit.
CPT-S Advanced Databases 11 Yinghui Wu EME 49.
1. Advanced SQL Functions Procedural Constructs Triggers.
Data Mining and Data Warehousing: Concepts and Techniques What is a Data Warehouse? Data Warehouse vs. other systems, OLTP vs. OLAP Conceptual Modeling.
Module 11: File Structure
Chapter 1: Introduction
Chapter 1: Introduction
Physical Changes That Don’t Change the Logical Design
Global E-Business: How Businesses Use Information Systems
Chapter 9 Database Systems
Views, Stored Procedures, Functions, and Triggers
Technology for School Leadership
The Killing Cursors Cyndi Johnson
Temporal Databases.
Lecture 1 File Systems and Databases.
Implementation of Relational Operations
Information Management
Evaluation of Relational Operations: Other Techniques
Terms: Data: Database: Database Management System: INTRODUCTION
CS240A: Databases and Knowledge Bases TSQL2
CS240A: Databases and Knowledge Bases A Taxonomy of Temporal DBs
Presentation transcript:

CS240A: Databases and Knowledge Bases Temporal Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles

Temporal Databases: Overview  Many applications  The problem is harder than what you think  Support for time in SQL: the good and the bad  A time ontology  Many approaches proposed  TSQL2  The physical level: efficient storage and indexing techniques.

An Introduction to Temporal Databases  Applications abound  Queries on time­varying data are hard to express in SQL--A case study.  Solution: Temporal Database Systems  A Temporal Database System is one that provides built­in support for storing and querying time- varying information.

Applications Abound: Examples  Academic: Transcripts record courses taken in previous and the current semester or term and grades for previous courses  Accounting: What bills were sent out and when, what payments were received and when?  Delinquent accounts, cash flow over time  Money­management software such as Quickencan show e.g., account balance over time.  Budgets: Previous and projected budgets, multi­ quarter or multi­year budgets

Temporal DB Applications (cont.)  Data Warehousing: Historical trend analysis for decision support  Financial: Stock market data  Audit: why were financial decisions made, and with what information available?  GIS: Geographic Information Systems ()  Land use over time: boundary of parcels changeover time, as parcels get partitioned and merged.  Title searches  Insurance: Which policy was in effect at each point in time, and what time periods did that policy cover?

Temporal DB Applications (cont.)  Medical records: Patient records, drug regimes, lab tests.Tracking course of disease  Payroll: Past employees, employee salary history, salaries for future months, records of withholding requested by employees  Capacity planning for roads and utilities. Configuring new routes, ensuring high utilization  Project scheduling: Milestones, task assignments  Reservation systems: airlines, hotels, trains.  Scientific: Timestamping satellite images. Dating archeological finds

Temporal DBs Applications: Conclusion  It is difficult to identify applications that do not involve the management of temporal data.  These applications would benefit from built­in temporal support in the DBMS. Main benefits:  More efficient application development  Potential increase in performance

Reviewing the Situation  The importance of temporal applications has motivated much research work on temporal DBs, no completely satisfactory solution has been found yet:  SQL:1999 does not support temporal queries  Temporal DBs remain an open research problem.  The problem is much more difficult than it appears at first: we have become so familiar with the time domain that we tend to overlook its intrinsic complexity.  Some of the solutions proposed by researchers were too ambitious.

Case Study  University of Arizona's Office of Appointed Personnel has some information in a database. Employee(Name, Salary, Title)  Finding an employee's salary is easy.  The OAP wishes to add the date of birth Employee(Name, Salary, Title, DateofBirth DATE) SELECT Salary, DateofBirth FROM Employee WHERE Name = 'Bob‘ SQL:1999 will do fine here, since support for the DATE type is all is needed

Case Study (cont.)  Now the OAP wishes to computerize the employment history. Employee (Name, Salary, Title, DateofBirth,Start DATE, Stop DATE) Converting to a Temporal Database

Converting to a Temporal Database Example  Now the OAP wishes to computerize the employment history. Employee (Name, Salary, Title, DateofBirth,Start DATE, Stop DATE) NameSalaryTitleDateofBirthStartStop Bob AssistantProvost 1945­04­ ­01­ ­06­01 Bob AssistantProvost 1945­04­ ­06­ ­10­01 Bob Provost 1945­04­ ­10­ ­02­01 Bob Professor 1945­04­ ­02­ ­01­01

Extracting the Salary  To find the employee's current salary, things are a bit more difficult. SELECT Salary FROM Employee WHERE Name = 'Bob‘ AND Start <= CURRENT_TIMESTAMP AND CURRENT_TIMESTAMP < Stop

Distributing the Salary History  OAP wants to distribute to all employees their salary history  Output: For each person, maximal intervals at each salary  Employee could have arbitrarily many title changes between salary changes Name Salary Start Stop Bob ­01­ ­06­01 Bob ­06­ ­01­01

Extracting the Salary History (cont.) Alternative 1: Give the user a printout of Salary and Title information, and have user determine when his/her salary changed. Alternative 2: Use SQL as much as possible. Find those intervals that overlap or are adjacent and thus should be merged.

Bob’s Salary History in SQL CREATE TABLE Temp(Salary, Start, Stop) AS SELECT Salary, Start, Stop FROM Employee WHERE Name = 'Bob'; repeat UPDATE Temp AS T1 SET (T1.Stop)=(SELECT MAX(T2.Stop) FROM Temp AS T2 WHERE T1.Salary = T2.Salary AND T1.Start = T2.Start AND T1.Stop = T2.Start AND T1.Stop < T2.Stop) until no tuples updated;

Example  Initial table  After one pass  After two passes

Salary History (cont.)  Intervals that are not maximal must be deleted DELETE FROM Temp T1 WHERE EXISTS (SELECT * FROM Temp AS T2 WHERE T1.Salary = T2.Salary AND ((T1.Start > T2.Start AND T1.Stop = T2.Start AND T1.Stop < T2.Stop) ) The loop is executed lg N times in the worst case, where N is the number of tuples in a chain of overlapping or adjacent, value­equivalent tuples. Then delete extraneous, non­maximal intervals.

Alternative 3 : Entirely in SQL CREATE TABLE Temp(Salary, Start, Stop) AS SELECT Salary, Start, Stop FROM Employee WHERE Name = 'Bob'; SELECT DISTINCT F.Salary, F.Start, L.Stop FROM Temp AS F, Temp AS L WHERE F.Start < L.Stop AND F.Salary = L.Salary AND NOT EXISTS (SELECT * FROM Temp AS M WHERE M.Salary = F.Salary AND F.Start < M.Start AND M.Start < L.Stop AND NOT EXISTS (SELECT * FROM Temp AS T1 WHERE T1.Salary = F.Salary AND T1.Start < M.Start AND M.Start <= T1.Stop)) AND NOT EXISTS (SELECT * FROM Temp AS T2 WHERE T2.Salary = F.Salary AND ( (T2.Start < F.Start AND F.Start <= T2.Stop) OR (T2.Start < L.Stop AND L.Stop < T2.Stop)))

Alternative 4: Using More Procedural Code  Use SQL only to open a cursor on the table  Maintain a linked list of intervals, each with a salary; Initialize this linked list to empty; DECLARE emp_cursor CURSOR FOR SELECT Salary, Start, Stop FROM Employee; OPEN emp_cursor; loop: FETCH emp_cursor INTO :salary,:start,:stop; if no data returned then go to finished; find position in linked list to insert this information; go to loop; finished: CLOSE emp_cursor; iterate through linked list, printing out dates and salaries

Extracting the Salary IN TSQL2 SELECT Salary FROM Employee WHERE Name = 'Bob'

A More Drastic Alternatives Reorganize the schema  Separate Salary, Title, and DateofBirth information: Employee1 (Name, Salary, Start DATE, Stop DATE) Employee2 (Name, Title, Start DATE, S top DATE)  Getting the salary information is now easy: SELECT Salary, Start, Stop FROM Employee1 WHERE Name = 'Bob‘  But what if we want a table of salary, title intervals?

Temporal Projection and Temporal Joins NameSalaryStartStop Bob ­01­011993­06­01 Bob ­06­011995­01­01 NameTitleStartStop BobAssistantProvost1993­01­011993­10­01 BobProvost1993­10­011994­02­01 BobFullProfessor1994­02­011995­01­01 NameSalaryTitleStartStop Bob60000AssistantProvost1993­01­011993­06­01 Bob70000AssistantProvost1993­06­011993­10­01 Bob70000Provost1993­10­011994­02­01 Bob70000FullProfessor1994­02­011995­01­01 Their Temporal Join: Employee 1 : Employee 2 :

Temporal Join in SQL SELECT Employee1.Name, Salary, Title, Employee1.Start, Employee1.Stop FROM Employee1, Employee2 WHERE Employee1.Name=Employee2.Name AND Employee2.Start <Employee1.Start AND Employee1.Stop <Employee2.Stop UNION ALL SELECT Employee1.Name, Salary, Title, Employee1.Start, Employee2.Stop FROM Employee1, Employee2 WHERE Employee1.Name =Employee2.Name AND Employee1.Start >Employee2.Start AND Employee2.Stop < Employee1.Stop AND Employee1.Start < Employee2.Stop UNION ALL SELECT Employee1.Name, Salary, Title Employee2.Start, Employee1.St FROM Employee1, Employee2 WHERE Employee1.Name = Employee2.Name AND Employee2.Start > Employee1.Start AND Employee1.Stop <= Employee2.Stop AND Employee2.Start < Employee1.Stop UNION ALL SELECT Employee1.Name, Salary, Title Employee2.Start, Employee2.Stop FROM Employee1, Employee2 WHERE Employee1.Name = Employee2 Name AND Employee2.Start => Employee1.Start AND Employee2.Stop <= Employee1.Stop AND NOT (Employee1.Start = Employee2.Start AND Employee1.Stop = Employee2.Stop)

TSQL2 Temporal Projection: SELECT Salary FROM Employee WHERE Name = ‘Bob’ Temporal Joins: SELECT Employee1.Name, Salary, Title FROM Employee1, Employee2 WHERE Employee1.Name = Employee2.Name