HOME

TheInfoList



OR:

A temporal database stores data relating to time instances. It offers temporal data types and stores information relating to past, present and future time. Temporal databases can be uni-temporal, bi-temporal or tri-temporal. More specifically the temporal aspects usually include
valid time In temporal databases, valid-time is the time period when an event happened or something was true in the real world, or more formally when a Fact (data warehouse), fact was valid in the data modeling, modeled reality. The valid-time period is an ...
, transaction time and/or
decision time In temporal databases, decision time is the time when a decision was made about a fact stored in a database. It is used to keep a history of decisions about valid times. In a database table, the start and end time of the decision time interval can ...
. * Valid time is the time period during or event time at which a fact is true in the real world. * Transaction time is the time at which a fact was recorded in the database. * Decision time is the time at which the decision was made about the fact. Used to keep a history of decisions about valid times.


Types


Uni-temporal

A uni-temporal database has one axis of time, either the validity range or the system time range.


Bi-temporal

A bi-temporal database has two axes of time: * Valid time * Transaction time or decision time


Tri-temporal

A tri-temporal database has three axes of time: * Valid time * Transaction time * Decision time This approach introduces additional complexities. Temporal databases are in contrast to current databases (not to be confused with currently available databases), which store only facts which are believed to be true at the current time.


Features

Temporal databases support managing and accessing temporal data by providing one or more of the following features: * A time period datatype, including the ability to represent time periods with no end (infinity or forever) * The ability to define valid and transaction time period attributes and bitemporal relations * System-maintained transaction time * Temporal primary keys, including non-overlapping period constraints * Temporal constraints, including non-overlapping uniqueness and
referential integrity Referential integrity is a property of data stating that all its references are valid. In the context of relational databases, it requires that if a value of one attribute (column) of a relation (table) references a value of another attribute (e ...
* Update and deletion of temporal records with automatic splitting and coalescing of time periods * Temporal queries at current time, time points in the past or future, or over durations * Predicates for querying time periods, often based on Allen's interval relations


History

With the development of
SQL Structured Query Language (SQL) (pronounced ''S-Q-L''; or alternatively as "sequel") is a domain-specific language used to manage data, especially in a relational database management system (RDBMS). It is particularly useful in handling s ...
and its attendant use in real-life applications, database users realized that when they added date columns to key fields, some issues arose. For example, if a table has a primary key and some attributes, adding a date to the primary key to track historical changes can lead to creation of more rows than intended. Deletes must also be handled differently when rows are tracked in this way. In 1992, this issue was recognized but standard database theory was not yet up to resolving this issue, and neither was the then-newly formalized SQL-92 standard. Richard Snodgrass proposed in 1992 that temporal extensions to SQL be developed by the temporal database community. In response to this proposal, a committee was formed to design extensions to the 1992 edition of the SQL standard (ANSI X3.135.-1992 and ISO/IEC 9075:1992); those extensions, known as TSQL2, were developed during 1993 by this committee.Snodgrass, 1999, p. 9 In late 1993, Snodgrass presented this work to the group responsible for the American National Standard for Database Language SQL, ANSI Technical Committee X3H2 (now known as NCITS H2). The preliminary language specification appeared in the March 1994 ACM SIGMOD Record. Based on responses to that specification, changes were made to the language, and the definitive version of the TSQL2 Language Specification was published in September, 1994 An attempt was made to incorporate parts of TSQL2 into the new SQL standard SQL:1999, called SQL3. Parts of TSQL2 were included in a new substandard of SQL3, ISO/IEC 9075-7, called SQL/Temporal. The TSQL2 approach was heavily criticized by Chris Date and
Hugh Darwen Hugh Darwen is a computer scientist who was an employee of IBM United Kingdom from 1967. to 2004, and has been involved in the development of the relational model. Work From 1978 to 1982 he was a chief architect on Business System 12, a dat ...
. The ISO project responsible for temporal support was canceled near the end of 2001. As of December 2011, ISO/IEC 9075, Database Language SQL:2011 Part 2: SQL/Foundation included clauses in table definitions to define "application-time period tables" (
valid time In temporal databases, valid-time is the time period when an event happened or something was true in the real world, or more formally when a Fact (data warehouse), fact was valid in the data modeling, modeled reality. The valid-time period is an ...
tables), "system-versioned tables" ( transaction time tables) and "system-versioned application-time period tables" ( bitemporal tables). A substantive difference between the TSQL2 proposal and what was adopted in SQL:2011 is that there are no hidden columns in the SQL:2011 treatment, nor does it have a new data type for intervals; instead two columns with datestamps (DS) or
date-timestamp A timestamp is a sequence of characters or encoded information identifying when a certain event occurred, usually giving date and time of day, sometimes accurate to a small fraction of a second. Timestamps do not have to be based on some absolu ...
s (DTS) can be bound together using a PERIOD FOR declaration. Another difference is replacement of the controversial (prefix) statement modifiers from TSQL2 with a set of temporal predicates. Other features of SQL:2011 standard related to temporal databases are automatic time period splitting, temporal primary keys, temporal referential integrity, temporal predicates with Allen's interval algebra and time-sliced and sequenced queries.


Example

For illustration, consider the following short biography of a fictional man, John Doe: :John Doe was born on 1975-04-03 in the Kids Hospital of Medicine County, as son of Jack Doe and Jane Doe who lived in Smallville. Jack Doe proudly registered the birth of his first-born on April 4, 1975 at the Smallville City Hall. John grew up as a joyful boy, turned out to be a brilliant student and graduated with honors in 1993. After graduation, he went to live on his own in Bigtown. Although he moved out on 1994-08-26, he forgot to register the change of address officially. It was only at the turn of the seasons that his mother reminded him that he had to register, which he did a few days later on 1994-12-27. Although John had a promising future, his story ends tragically. John Doe was accidentally hit by a truck on 2001-04-01. The coroner reported his date of death on the very same day.


Using a non-temporal database

To store the life of John Doe in a current (non-temporal) database we use a table . (In order to simplify, name is defined as the
primary key In the relational model of databases, a primary key is a designated attribute (column) that can reliably identify and distinguish between each individual record in a table. The database creator can choose an existing unique attribute or combinati ...
of person.) John's father officially reported his birth on 1975-04-04. On this date a Smallville official inserted the following entry in the database: Person(John Doe, Smallville). Note that the date itself is not stored in the database. After graduation, John moves out, but forgets to register his new address. John's entry in the database is not changed until 1994-12-27, when he finally reports it. A Bigtown official updates his address in the database. The person table now contains Person(John Doe, Bigtown). Note that the information of John living in Smallville has been overwritten, so it is no longer possible to retrieve that information from the database. An official accessing the database on 1994-12-28, would be told that John lives in Bigtown. More technically: if a database administrator ran the query on 1994-12-26, the result would be Smallville. Running the same query 2 days later would result in Bigtown. Until his death, the database would state that he lived in Bigtown. On 2001-04-01, the coroner deletes the John Doe entry from the database. After this, running the above query would return no result at all.


Using a single axis: valid time or transaction time

Valid time In temporal databases, valid-time is the time period when an event happened or something was true in the real world, or more formally when a Fact (data warehouse), fact was valid in the data modeling, modeled reality. The valid-time period is an ...
is the time for which a fact is true in the real world. A valid time period may be in the past, span the current time, or occur in the future. For the example above, to record valid time, the person table has two fields added, valid_from and valid_to. These specify the period when a person's address is valid in the real world. On 1975-04-04, John's father registered his son's birth. An official then inserts a new entry into the database stating that John lives in Smallville from April 3. Note that although the data was inserted on the fourth, the database states that the information is valid since the third. The official does not yet know if or when John will move to another place, so the valid_to field is set to
infinity Infinity is something which is boundless, endless, or larger than any natural number. It is denoted by \infty, called the infinity symbol. From the time of the Ancient Greek mathematics, ancient Greeks, the Infinity (philosophy), philosophic ...
(∞). The entry in the database is: On 1994-12-27, John reports his new address in Bigtown where he has been living since 1994-08-26. A new database entry is made to record this fact: The original entry Person (John Doe, Smallville, 1975-04-03, ∞) is not deleted, but has the valid_to attribute updated to reflect that it is now known that John stopped living in Smallville on 1994-08-26. The database now contains two entries for John Doe: When John dies his current entry in the database is updated stating that John does not live in Bigtown any longer. The database now looks like this:


Using two axes: valid time and transaction time

Transaction time records the time period during which a database entry is accepted as correct. This enables queries that show the state of the database at a given time. Transaction time periods can only occur in the past or up to the current time. In a transaction time table, records are never deleted. Only new records can be inserted, and existing ones updated by setting their transaction end time to show that they are no longer current. To enable transaction time in the example above, two more fields are added to the Person table: transaction_from and transaction_to. Here, transaction_from is the time a transaction was made, and transaction_to is the time that the transaction was superseded (which may be infinity if it has not yet been superseded). This makes the table into a bitemporal table. What happens if the person's address as stored in the database is incorrect? Suppose an official accidentally entered the wrong address or date? Or, suppose the person lied about their address for some reason. Upon discovery of the error, the officials update the database to correct the information recorded. For example, from 1995-06-01 to 2000-09-03, John Doe moved to Beachy. But to avoid paying Beachy's exorbitant residence tax, he never reported it to the authorities. Later during a tax investigation, it is discovered on 2-Feb-2001 that he was in fact in Beachy during those dates. To record this fact, the existing entry about John living in Bigtown must be split into two separate records, and a new record inserted recording his residence in Beachy. The database would then appear as follows: However, this leaves no record that the database ever claimed that he lived in Bigtown during 1995-06-01 to 2000-09-03.This might be important to know for auditing reasons, or to use as evidence in the official's tax investigation. Transaction time allows capturing this changing knowledge in the database, since entries are never directly modified or deleted. Instead, each entry records when it was entered and when it was superseded (or logically deleted). The database contents then look like this: The database records not only what happened in the real world, but also what was officially recorded at different times.


Using three axes: valid time, decision time, and transaction time

Decision time In temporal databases, decision time is the time when a decision was made about a fact stored in a database. It is used to keep a history of decisions about valid times. In a database table, the start and end time of the decision time interval can ...
is an alternative to the transaction time period for recording the time at which a database entry may be accepted as correct. This enables queries that show the officially recognized facts at a given time, even if there was a delay in committing those facts to the database. Support for decision time preserves the entire history and prevents the loss of information during updates. Decision time periods can only occur in the past or up to the transaction time. As in a transaction time table, records are never deleted. Only new records can be inserted, and existing ones updated by setting their decision end time to show that they are no longer current. To enable decision time, two more fields are added to a database table: decision_from and decision_to. Here, decision_from is the time a decision was made, and decision_to is the time that the decision was superseded (which may be infinity if it has not yet been superseded). When combined with transaction time, this makes the table into a tritemporal table. The following is a list of real events that occurred between the 1964 and 1976
United States presidential election The election of the president of the United States, president and Vice President of the United States, vice president of the United States is an indirect election in which citizens of the United States who are Voter registration in the United ...
s: In this example, a constant 7-day delay is assumed between the decision time and the transaction time when the data is committed to the database. Given those conditions, the database would have contained the following information after the election in 1976: Given the 7-day delayed table above, the question "who was president and vice president for the valid time of 1977-01-01" (which given the 7-day delay could provide data for 1976-12-25) would be: * Nixon/Agnew when using a decision time and transaction time of 1972-11-14 * Nixon/(Vacant) when using a decision time and transaction time of 1973-10-17 * Nixon/Ford when using a decision time and transaction time of 1974-08-08 * Ford/(Vacant) when using a decision time of 1974-08-08 and transaction time of current * Ford/Rockefeller when using a decision time and transaction time of current


Bitemporal modelling

A bitemporal model contains both valid and transaction time. This provides both ''historical'' and ''rollback'' information. Historical information (e.g.: "Where did John live in 1992?") is provided by the valid time. Rollback (e.g.: "In 1992, where did the database believe John lived?") is provided by the transaction time. The answers to these example questions may not be the same the database may have been altered since 1992, causing the queries to produce different results. The valid time and transaction time do not have to be the same for a single fact. For example, consider a temporal database storing data about the 18th century. The valid time of these facts is somewhere between 1701 and 1800. The transaction time would show when the facts were inserted into the database (for example 1998-01-21).


Schema evolution

A challenging issue is the support of temporal queries in a transaction time database under evolving
schema Schema may refer to: Science and technology * SCHEMA (bioinformatics), an algorithm used in protein engineering * Schema (genetic algorithms), a set of programs or bit strings that have some genotypic similarity * Schema.org, a web markup vocab ...
. In order to achieve perfect archival quality it is of key importance to store the data under the schema version under which they first appeared. However, even the most simple temporal query rewriting the history of an attribute value would be required to be manually rewritten under each of the schema versions, potentially hundreds as in the case of
MediaWiki MediaWiki is free and open-source wiki software originally developed by Magnus Manske for use on Wikipedia on January 25, 2002, and further improved by Lee Daniel Crocker,mailarchive:wikipedia-l/2001-August/000382.html, Magnus Manske's announc ...
. This process would be particularly taxing for users. A proposed solution is to provide automatic query rewriting, although this is not part of SQL or similar standards. Approaches to minimize the complexities of schema evolution are to: * Use a semi-structured database/
NoSQL NoSQL (originally meaning "Not only SQL" or "non-relational") refers to a type of database design that stores and retrieves data differently from the traditional table-based structure of relational databases. Unlike relational databases, which ...
database which reduces the complexities of modeling attribute data but provides no features for handling multiple time axes. * Use a database capable of storing both
semi-structured data Semi-structured data is a form of structured data that does not obey the tabular structure of data models associated with relational databases or other forms of data tables, but nonetheless contains tags or other markers to separate semantic elem ...
for attributes and
structured data A data model is an abstract model that organizes elements of data and standardizes how they relate to one another and to the properties of real-world entities. For instance, a data model may specify that the data element representing a car be ...
for time axes (e.g., SnowflakeDB,
PostgreSQL PostgreSQL ( ) also known as Postgres, is a free and open-source software, free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. PostgreSQL features transaction processing, transactions ...
)


Implementations in notable products

The following implementations provide temporal features in a relational database management system (RDBMS). *
MariaDB MariaDB is a community-developed, commercially supported Fork (software development), fork of the MySQL relational database management system (RDBMS), intended to remain free and open-source software under the GNU General Public License. Developm ...
version 10.3.4 added support for SQL:2011 standard as "System-Versioned Tables". *
Oracle Database Oracle Database (commonly referred to as Oracle DBMS, Oracle Autonomous Database, or simply as Oracle) is a proprietary multi-model database management system produced and marketed by Oracle Corporation. It is a database commonly used for ru ...
Oracle Workspace Manager is a feature of Oracle Database which enables application developers and DBAs to manage current, proposed and historical versions of data in the same database. *
PostgreSQL PostgreSQL ( ) also known as Postgres, is a free and open-source software, free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. PostgreSQL features transaction processing, transactions ...
version 9.2 added native ranged data types that are capable of implementing all of the features of the pgFoundry temporal contributed extension. The PostgreSQL range types are supported by numerous native operators and functions. *
Teradata Teradata Corporation is an American software company that provides cloud database and Analytics, analytics-related software, products, and services. The company was formed in 1979 in Brentwood, California, as a collaboration between researchers a ...
provides two products. Teradata version 13.10 and Teradata version 14 have temporal features based on TSQL2 built into the database. * IBM Db2 version 10 added a feature called "time travel query" which is based on the temporal capabilities of the SQL:2011 standard.Kulkarni, Krishna, and Jan-Eike Michels.
Temporal features in SQL: 2011
. ACM SIGMOD Record 41.3 (2012): 34-43.
*
Microsoft SQL Server Microsoft SQL Server is a proprietary relational database management system developed by Microsoft using Structured Query Language (SQL, often pronounced "sequel"). As a database server, it is a software product with the primary function of ...
introduced Temporal Tables as a feature for SQL Server 2016. The feature is described in a video on Microsoft's "Channel 9" web site. Non-relational, NoSQL database management systems that provide temporal features including the following: * TerminusDB is a fully featured
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
graph database A graph database (GDB) is a database that uses graph structures for semantic queries with nodes, edges, and properties to represent and store data. A key concept of the system is the graph (or edge or relationship). The graph relates the dat ...
that natively supports version control, time-travel queries and diffing functions. It has an immutable layer architecture based on
delta encoding Delta encoding is a way of storing or transmitting data in the form of '' differences'' (deltas) between sequential data rather than complete files; more generally this is known as data differencing. Delta encoding is sometimes called delta comp ...
and
succinct data structure In computer science, a succinct data structure is a data structure which uses an amount of space that is "close" to the information-theoretic lower bound, but (unlike other compressed representations) still allows for efficient query operations. ...
s. *
MarkLogic MarkLogic is an American software business that develops and provides an enterprise NoSQL database, which is also named ''MarkLogic''. They have offices in the United States, Europe, Asia, and Australia. In February 2023, MarkLogic was acquired ...
introduced bitemporal data support in version 8.0. Time stamps for Valid and System time are stored in JSON or XML documents.
SirixDB
stores snapshots of (currently) XML- and JSON-documents very efficiently in a binary format due to a novel versioning algorithm called sliding snapshot, which balances read-/write-performance and never creates write peaks. Time-travel queries are supported natively as well as diffing functions.
XTDB
(formerly Crux) provides point-in-time bitemporal
Datalog Datalog is a declarative logic programming language. While it is syntactically a subset of Prolog, Datalog generally uses a bottom-up rather than top-down evaluation model. This difference yields significantly different behavior and properties ...
queries over transactions and documents ingested from semi-immutable Kafka logs. Documents are automatically indexed to create
Entity–attribute–value model An entity–attribute–value model (EAV) is a data model optimized for the space-efficient storage of sparse—or ''ad-hoc''—property or data values, intended for situations where runtime usage patterns are arbitrary, subject to user variation ...
indexes without any requirement to define a schema. Transaction operations specify the effective Valid times. Transaction times are assigned by Kafka and enable horizontal scalability via consistent reads.
RecallGraph
is a point-in-time, unitemporal (transaction time) graph database, built on top of
ArangoDB ArangoDB is a graph database system developed by ArangoDB Inc. ArangoDB is a multi-model database system since it supports three data models (graphs, JSON documents, key/value) with one database core and a unified query language AQL (ArangoDB Qu ...
. It runs on ArangoDB'
Foxx Microservice
sub-system. It features VCS-like semantics in many parts of its interface, and is backed by a transactional event tracker. Bitemporality is listed as one of the items in it
development roadmap


"is a distributed database that provides ACID transactions, flexible schema, ..Datalog queries, complete data history, and SQL analytics support." For every change made to the data, it records the responsible transaction and the point in time when it happened. Temporal databases were one of the earliest forms of data version control, and influenced the development of modern data versioning systems.


Alternatives

Slowly changing dimension In data management and data warehousing, a slowly changing dimension (SCD) is a dimension that stores data which, while generally stable, may change over time, often in an unpredictable manner. This contrasts with a rapidly changing dimension, su ...
s can be used to model temporal relations.


Further reading

* C.J. Date,
Hugh Darwen Hugh Darwen is a computer scientist who was an employee of IBM United Kingdom from 1967. to 2004, and has been involved in the development of the relational model. Work From 1978 to 1982 he was a chief architect on Business System 12, a dat ...
,
Nikos Lorentzos Nikos Lorentzos is a Greek professor of Informatics. He is a specialist on the Relational Model of Database Management, having made contributions in the field of temporal databases, where he has co-authored a book with Hugh Darwen and Christopher ...
(2002). ''Temporal Data & the Relational Model, First Edition'' (The Morgan Kaufmann Series in Data Management Systems); Morgan Kaufmann; 1st edition; 422 pages. . * Joe Celko (2014). ''Joe Celko's SQL for Smarties: Advanced SQL Programming'' (The Morgan Kaufmann Series in Data Management); Morgan Kaufmann; 5th edition. .—Chapters 12 and 35 in particular discuss temporal issues. * Snodgrass, Richard T. (1999).   (Morgan Kaufmann Series in Data Management Systems); Morgan Kaufmann; 504 pages;


See also

* Anchor modeling *
Database theory Database theory encapsulates a broad range of topics related to the study and research of the theoretical realm of databases and database management systems. Theoretical aspects of data management include, among other areas, the foundations of q ...
*
Data warehouse In computing, a data warehouse (DW or DWH), also known as an enterprise data warehouse (EDW), is a system used for Business intelligence, reporting and data analysis and is a core component of business intelligence. Data warehouses are central Re ...
*
Event store Event may refer to: Gatherings of people * Ceremony, an event of ritual significance, performed on a special occasion * Convention (meeting), a gathering of individuals engaged in some common interest * Event management, the organization of ev ...
*
Spatiotemporal database A spatiotemporal database is a database that manages both space and time information. Common examples include: * Tracking of moving objects, which typically can occupy only a single position at a given time. * A database of wireless communication n ...
*
Time series database A time series database is a software system that is optimized for storing and serving time series through associated pairs of time(s) and value(s). In some fields, ''time series'' may be called profiles, curves, traces or trends. Several early tim ...
* Extended Date Time Format


References


External links

*
Temporal Relations in RDFTemporal Scope for RDF Triples
series of articles by Randy Weis and Tom Johnston

by Martin Fowler {{DEFAULTSORT:Temporal database Database management systems Database theory Transaction processing Temporal databases