Relational model: Difference between revisions

Content deleted Content added
Replace the previous image with a cleaner SVG
Rewrite and cite the Definitions section
Line 17:
[[File:Relational database terms.svg|thumb|A relation with 5 attributes (its degree) and 4 tuples (its cardinality) can be visualized as a table with 5 columns and 4 rows. However, unlike rows and columns in a table, a relation's attributes and tuples are unordered.]]
 
A ''relation'' consists of a ''heading'' and a ''body''. The heading defines a [[Set (mathematics)|set]] of ''attributes'', each with a ''name'' and ''data type'' (sometimes called a ''___domain''). The number of attributes in this set is the relation's ''degree'' or ''[[arity]]''. The ''body'' is a set of ''tuples'', each with ''n'' elements corresponding to the attributes in the heading.{{refn|group=nb|Despite its name, a ''tuple'' in the relational model is not a mathematical [[tuple]]. In mathematics, the elements of a tuple are ordered. In the relational model, attributes are unordered, so the corresponding elements in a tuple are also unordered.}} The number of tuples in this set is the relation's ''[[cardinality]]''.<ref name="professionals"/>{{rp|17-22}}
The basic relational building block is the [[Data ___domain|___domain]] or [[data type]], usually abbreviated nowadays to '''''type'''''. A ''[[tuple]]'' is an unordered [[set (mathematics)|set]] of '''''attribute values'''''. An [[Attribute (computing)|attribute]] is an unordered pair of '''''attribute name''''' and '''''type name'''''. An attribute value is a specific valid value for the type of the attribute. This can be either a scalar value or a more complex type.
 
Relations are represented by ''relational [[Variable (computer science)|variables]]'' or ''relvars'', which can be reassigned.<ref name="professionals"/>{{rp|22-24}}. A ''[[database]]'' is a collection of relvars.<ref name="professionals"/>{{rp|112-113}}.
A relation consists of a '''''heading''''' and a '''''body'''''. A heading is a set of attributes. A body (of an ''n''-ary relation) is a set of ''n''-tuples. The heading of the relation is also the heading of each of its tuples.
 
In this model, databases follow the ''Information Principle'': At any given time, all information in the database is represented solely by values within tuples, corresponding to declared attributes, in relations identified by relvars.<ref name="professionals"/>{{rp|111}}
A relation is defined as a [[set (mathematics)|set]] of ''n''-tuples. In both mathematics and the relational database model, a set is an ''unordered'' collection of unique, non-duplicated items. (In mathematics, a [[tuple]] has an order, and allows for duplication).
 
A ''[[relvar]]'' is a named variable of some specific relation type, to which at all times some relation of that type is assigned, though the relation may contain zero tuples.
 
The basic principle of the relational model is the [[Information Principle]]: all [[information]] is represented by data values in relations. t
 
=== Constraints ===