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

Slides:



Advertisements
Similar presentations
TSQL 2 : QUERY LANGUAGE FOR TEMPORAL DATA CS 224 : Advanced Topics in Data Management.
Advertisements

From Handbook of Temporal Reasoning in Artificial Intelligence By Jan Chomicki & David Toman Temporal Databases Presented by Leila Jalali CS224 presentation.
CS240A: Databases and Knowledge Bases Temporal Applications and SQL:1999 Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
BCDM Temporal Domains - Time is linear and totally ordered - Chronons are the basic time unit - Time domains are isomorphic to subsets of the domain of.
Advanced Databases Temporal Databases Dr Theodoros Manavis
Temporal and Real-Time Databases: A Survey by Gultekin Ozsoyoglu and Richard T. Snodgrass Presentation by Didi Yao.
Elementary Data Types Prof. Alamdeep Singh. Scalar Data Types Scalar data types represent a single object, i.e. only one value can be derived. In general,
King Fahd University of Petroleum and Minerals
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 ….
CS 240A: Databases and Knowledge Bases Analysis of Active Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Spatiotemporal GIS: Incorporating Time Group 7 Nathan Hunstad, Kyle Martin Csci 5980.
CS240A: Databases and Knowledge Bases A Taxonomy of Temporal DBs Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Temporal Databases. Outline Spatial Databases Indexing, Query processing Temporal Databases Spatio-temporal ….
Time Chapter 10 © Worboys and Duckham (2004)
CS240A: Databases and Knowledge Bases Applications of Active Database Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
MM3FC Mathematical Modeling 3 LECTURE 2 Times Weeks 7,8 & 9. Lectures : Mon,Tues,Wed 10-11am, Rm.1439 Tutorials : Thurs, 10am, Rm. ULT. Clinics : Fri,
CS240A: Databases and Knowledge Bases Time Ontology and Representations Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
College Algebra Fifth Edition
Real Numbers and the Decimal Number System
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
Navigation and Ancillary Information Facility NIF Leapseconds and Spacecraft Clock Kernels LSK and SCLK November 2014.
Basis Data Terapan Yoannita. SQL Server Data Types Character strings: Data typeDescriptionStorage char(n)Fixed-length character string. Maximum 8,000.
Numeral Systems Subjects: Numeral System Positional systems Decimal
Said Salomon Unitrin Direct Insurance T-SQL Date and Time Functions Said Salomon.
Foundations of Computer Science Computing …it is all about Data Representation, Storage, Processing, and Communication of Data 10/4/20151CS 112 – Foundations.
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
Extending the Definition of Exponents © Math As A Second Language All Rights Reserved next #10 Taking the Fear out of Math 2 -8.
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.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 5 Arrays.
USE OF TEMPORAL CONCEPTS IN TRANSACTIONAL DATABASES.
SCUHolliday - coen 1788–1 Schedule Today u Modifications, Schemas, Views. u Read Sections (except and 6.6.6) Next u Constraints. u Read.
CS240A: Databases and Knowledge Bases Recursive Queries in SQL 1999 Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Chapter 5 Parameter estimation. What is sample inference? Distinguish between managerial & financial accounting. Understand how managers can use accounting.
College Algebra Sixth Edition James Stewart Lothar Redlin Saleem Watson.
CS 338The Relational Model2-1 The Relational Model Lecture Topics Overview of SQL Underlying relational model Relational database structure SQL DDL and.
資工所 在職碩一 P 莊浚銘 Temporal Database Paper Reading Report.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
SPATIO-TEMPORAL DATABASES Temporal Databases. Temporal Data. Modeling Temporal Data Temporal Semantics Temporal density: the time is seen as being: 
CS240A: Databases and Knowledge Bases Temporal Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
CS 240A: Databases and Knowledge Bases Analysis of Active Databases 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.
Spatiotemporal GIS Standard GIS: Spatial Characteristics only Implicit time is usually “now” Spatiotemporal GIS: Adds concept of time What happened when.
CS240A: Databases and Knowledge Bases Recursive Queries in SQL 2003 Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
CS240A: Databases and Knowledge Bases TSQL2 Carlo Zaniolo Department of Computer Science University of California, Los Angeles Notes From Chapter 6 of.
1 The T4SQL Temporal Query Language Presented by 黃泰豐 2007/12/26.
Working with Date and Time ISYS 475. How PHP processes date and time? Traditional way: – Timestamp Newer and object oriented way: – DateTime class.
IBM Research: Software Technology © 2005 IBM Corporation Programming Technologies 1 Temporal Rules Vijay Saraswat IBM TJ Watson July 27, 2012.
CPT-S Advanced Databases 11 Yinghui Wu EME 49.
IMS 3253: Dates and Times 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Date and Time Data Turning Strings into.
Data Types COMP3211 Advanced Databases Dr Nicholas Gibbins
CONFIDENTIAL1 Good Afternoon! Today we will be learning about Calendar and Years Let’s warm up : Complete the conversion tables: Hours478 Minutes 1) Calculate.
Next Contents Back. Next Contents Back The Integers are natural numbers including 0 (0, 1, 2, 3,...) and their negatives (0, −1, −2, −3,...). They are.
SPECIAL PURPOSE DATABASES 13/09/ Temporal Database Concepts  Time is considered ordered sequence of points in some granularity Use the term choronon.
Data Types COMP3017 Advanced Databases Dr Nicholas Gibbins
COMP3211 Advanced Databases
Spatio-Temporal Databases
Modeling Arithmetic, Computation, and Languages
Spatio-Temporal Databases
Temporal Databases.
What Time Is It? Martin Phillips Ladybridge Systems.
Temporal Databases.
CS240A: Databases and Knowledge Bases TSQL2
CS240A: Databases and Knowledge Bases A Taxonomy of Temporal DBs
WP3 Workshop 16/01/2002 Timestamps.
Presentation transcript:

CS240A: Databases and Knowledge Bases Time Ontology and Representations Carlo Zaniolo Department of Computer Science University of California, Los Angeles Notes From Chapter 5 of Advanced Database Systems by Zaniolo, Ceri, Faloutsos, Snodgrass, Subrahmanian and Zicari. Morgan Kaufmann, 1997

Time Properties  Structure  Boundedness  Density  Time Data Types  Time and Facts

Time Structure  Linear Time  Branching Time  Directed Acyclic Graph  Periodic/Cyclic Time—e.g. the week.  Boundedness of Time  Boundedness  Unbounded  Time origin exists (bounded from the left): from now on  Bounded time (bounds on both ends)—the end of time.

Time Density  Discrete:  Time line is isomorphic to the integers  Timeline composed of a sequence of non­decomposable time periods of some fixed, minimal duration, termed chronons.  Between each pair of chronons is a finite number of other chronons.  Dense: (difficult to implement)  Time line is isomorphic to the rational numbers.  Between any two chronons is an infinite number of other instants.  Continuous: (very difficult to implement)  Time line is isomorphic to the real numbers.  Between each pair of instants is a infinite number of other instants.  A bounded discrete representation of time is the simplest option used in SQL-2 and most temporal DBs.

Internal Representation of Time  UNIX time is specified as the number of seconds since January 1, (Unix Epoch)  Windows NT time is specified as the number of 100 nanosecond intervals since January 1,  There are 134,774 days (or 11,644,473,600 seconds) between these dates.  Nt2unix Divide by 10,000,000 and subtract 11,644,473,600.  unix2nt:Add 11,644,473,600 and multiply by 10,000,000.  SQL standards are independent from OS and based on:  Date  Time  Timestamp: Date || Time  Support for leap seconds, Julian calendar (almost)

Date and Time Data Types in SQL-2  Date : four digits for the year and two for month and day. Multiple formats allowed:  E.g., or 12/08/2001 or  ISO, USA, EUR, JIS representations supported---DBA selects which one is used in specific system.  Time : 2 digits for hour, 2 for minutes, and 2 for seconds, plus optional fractional digits (system dependent). E.g., 13:50:00, 13:50, 1:50 PM denote the same time.  These are external representations: internal representation is unique, independent of external ones.

Internal Representation (DB2)  A date is (year, month, day). The range of the year part is 0001 to The range of the month part is 1 to 12. The range of the day depends on the month.  The internal representation of a date is a string of 4 bytes. Each byte consists of 2 packed decimal digits. The first 2 bytes represent the year, the third byte the month, and the last byte the day.  A time is (hour, minute, second) designating a time of day under a 24-hour clock. The range of the hour part is 0 to 24; while the range of the other parts is 0 to 59 (?) If the hour is 24, the minute and second specifications will be zero.  The internal representation of a time is a string of 3 bytes. Each byte is 2 packed decimal digits. The first byte represents the hour, the second byte the minute, and the last byte the second.

Seconds The Maximum Second [Trudy Pelzer, DBAzine, :41 PM] The largest second in a minute is given as 59, since the seconds in a minute are generally numbered from 0 to 59. Although that might seem obvious and uncontroversial, it's not 100% true:  First exception: DB2 happens to allow a time of '24:00:00' for midnight. ('24:00:01' is not legal.) This is an extension that is probably best avoided, because it's not compatible with other DBMSs, and because it's hard to distinguish ' :00:00' from ' :00:00'. Nevertheless, it might be necessary to correspond to legal documents that refer to "midnight on January 1" because in such documents midnight means the end of the day, not the beginning.  Second exception: At irregular intervals, but always as the last second at the end of a calendar quarter, the International Earth Rotation Service (IERS) declares a leap second. (June 30th and December 31st are the preferred dates; since the system was introduced in 1972, only dates in June and December have been used.) That means the day has (24 x 60 x ) 86,401 seconds instead of the usual mere 86,400 – which is why counting seconds between two wide-apart timestamps is almost certainly unreliable. The SQL Standard actually allows for two leap seconds, so the last second on June , for example, could have been ' :59:61'. But in fact, it wasn't — the IERS has never declared a double leap second. SQL Server Magazine Leap Second for 2005: The year 2005 will be one second longer than a usual non-leap year. For the first time since 1998, the IERS has announced that the earth's rotation is running slow relative to atomic time standards, and the last minute of December 31 will contain 61 seconds in order to get things back on track: ftp://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat. ftp://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat  Hmmm, interesting. But how does this impact SQL Server?  All versions of SQL Server don’t support valid DATETIME values such as ' T23:59:60.500' that occur during leap seconds. In addition, SQL Server's DATEDIFF function does not take into account leap seconds. Be prepared!

Time Datatype in SQL-2  TIMESTAMP : date+time with six fractional digits for the second field. E.g.,  TIME(STAMP) WITH ZONE: offset according to UTC (universel temps coordonné)  INTERVAL: I.e. a time span. In DB2 is called a labeled duration. E.g., 10 DAYS  Time expressions. Using the labeled duration in arithmetic : orderdate + 10 DAYS < CURRENT DATE --- this is valid, but CURRENT DATE - orderdate > 10 DAYS --- this is not valid.  CAST expressions: E.g. CAST(2 DAYS AS HOURS) returns 48 HOURS

Various Temporal Types used in temporal DBs  A time instant is a time point on the time line.  An event is an instantaneous fact, i.e, something occurring at an instant. The event occurrence time of an event is the instant at which the event occurs in the real world.  An instant set is a set of instants.  A time period is the set of time instants between two instants (start time and end time).

Periods versus Time Intervals  Periods are frequently called (time) intervals.  but this conflicts with the SQL data type INTERVAL and we will try to avoid it.  In SQL:1999, a time interval is a directed duration of time. A duration is an amount of time with a known length, but no specific starting or ending instants.Also called a span.  A positive interval denotes forward motion of time; a negative interval denotes backwards motion of time.

Valid Time and Transaction Time  Valid Time of a fact: when the fact is true in the modeled reality  Transaction Time of a fact: when it was recorded in the database.  Thus we have four different kinds of tables: 1. Snapshot 2. Valid-time 3. Transaction-time 4. Bitemporal

Example: Tom's Employment History  On January 1, 1984, Tom joined the faculty as an Instructor.  On December 1, 1984, Tom completed his doctorate, and so was promoted to Assistant Professor effective retroactively on July 1,  On March 1, 1989, Tom was promoted to Associate Professor, effective July 1, 1989 (proactive update).

Queries and Updates  A transaction time table is append only it keeps the history of the updates made on the database.  Transaction time tables supports rollback/flashback queries, such as:  On October 1, what rank was our database showing for Tom?  A valid time table can be updated: e.g., Tom’s past record is changed once his rank is changed retroactively.  Valid time tables support historical queries, such as:  What was Tom’s rank on October 1 (according to our current database)?

Bitemporal Tables  Bitemporal Tables are append­only and supports queries of both kinds (rollback& historical) such as:  On October 1, 1984, what did we think Tom's rank was at that date?  TSQL2: SELECT Rank FROM Faculty AS F WHERE Name = 'Tom‘ AND VALID(F) OVERLAPS DATE '1984­10­01‘ AND TRANSACTION(F) OVERLAPS DATE '1984­10­01'

Desiderata for a Temporal Data Model and Query Language  Capture the semantics of time­varying information  Retain simplicity of the relational model: Strict superset of the relational model  Present all the information concerning an object in a coherent fashion  Ensure ease of implementation  Ensure high performance Regrettably SQL-2 falls way short of these desiderata, and extending SQL to achieve them has also proven to be very difficult!