Jump to content

Table (database)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 119.92.151.236 (talk) at 00:25, 10 February 2020. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A table is a collection of related data held in a table format within a database. It consists of columns, and rows.


"Table" is another term for "relation"; although there is the difference in that a table is usually a multiset (bag) of rows where a relation is a set and does not allow duplicates. Besides the actual data rows, tables generally have associated with them some metadata, such as constraints on the table or on the values within particular columns.[dubiousdiscuss]


Tables versus relations

In terms of the relational model of databases, a table can be considered a convenient representation of a relation, but the two are not strictly equivalent. For instance, a SQL table can potentially contain duplicate rows, whereas a true relation cannot contain duplicate rows that we call as tuples. Similarly, representation as a table implies a particular ordering to the rows and columns, whereas a relation is explicitly unordered. However, the database system does not guarantee any ordering of the rows unless an ORDER BY clause is specified in the SELECT statement that queries the table.

An equally valid representation of a relation is as an n-dimensional chart, where n is the number of attributes (a table's columns). For example, a relation with two attributes and three values can be represented as a table with two columns and three rows, or as a two-dimensional graph with three points. The table and graph representations are only equivalent if the ordering of rows is not significant, and the table has no duplicate rows.

Comparisons

Hierarchical databases

In non-relational systems, hierarchical databases, the distant counterpart of a table is a structured file, representing the rows of a table in each row of the file and each column in a row. This structure implies that a row can have repeating information, generally in the child data segments. Data are stored in sequence of physical records.

Spreadsheets

Unlike a spreadsheet, the datatype of a column is ordinarily defined by the schema describing the table. Some SQL systems, such as SQLite, are less strict about column datatype definitions.

See also

References