Relation (database)
Encyclopedia
In relational model
Relational model
The relational model for database management is a database model based on first-order predicate logic, first formulated and proposed in 1969 by Edgar F...

:
A relation is a data structure
Data structure
In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks...

 which consists of a heading and an unordered set
Set (computer science)
In computer science, a set is an abstract data structure that can store certain values, without any particular order, and no repeated values. It is a computer implementation of the mathematical concept of a finite set...

 of tuples which share the same type.
When Edgar F. Codd
Edgar F. Codd
Edgar Frank "Ted" Codd was an English computer scientist who, while working for IBM, invented the relational model for database management, the theoretical basis for relational databases...

 invented the relational model, he generalized the concept of binary relation (mathematical relation)
Binary relation
In mathematics, a binary relation on a set A is a collection of ordered pairs of elements of A. In other words, it is a subset of the Cartesian product A2 = . More generally, a binary relation between two sets A and B is a subset of...

 to n-ary
Arity
In logic, mathematics, and computer science, the arity of a function or operation is the number of arguments or operands that the function takes. The arity of a relation is the dimension of the domain in the corresponding Cartesian product...

 relation
. Relation is a fundamental concept in relational model.
A relation has zero or more tuples.
A relation value is an instance of a relation.
A relation variable (relvar)
Relvar
In relational databases, a relvar is a term coined by C. J. Date as an abbreviation for the concept of relation variable, which is the actual term used by the inventor of the relational model, E. F. Codd, regarding the same concept...

is a variable which has a relation value.

In some context, relation means relation variable. In another context, relation means relation value.

In SQL
SQL
SQL is a programming language designed for managing data in relational database management systems ....

, a database language for relational database
Relational database
A relational database is a database that conforms to relational model theory. The software used in a relational database is called a relational database management system . Colloquial use of the term "relational database" may refer to the RDBMS software, or the relational database itself...

s, a relation variable is called a table
Table (database)
In relational databases and flat file databases, a table is a set of data elements that is organized using a model of vertical columns and horizontal rows. A table has a specified number of columns, but can have any number of rows...

.

A relation value, which is assigned to a certain relation variable, is time-varying. By using a Data Definition Language
Data Definition Language
A data definition language or data description language is a syntax similar to a computer programming language for defining data structures, especially database schemas.-History:...

 (DDL), it is able to define relation variables.
A heading is the unordered set of certain attributes (columns)
Column (database)
In the context of a relational database table, a column is a set of data values of a particular simple type, one for each row of the table. The columns provide the structure according to which the rows are composed....

. A heading has zero or more attributes.
A body is the unordered set of tuples, which constitutes a relation value. In other words, a relation value consists of a heading and a body.
A tuple is a data structure which consists of the unordered set of zero or more attributes.
An attribute (column)
Column (database)
In the context of a relational database table, a column is a set of data values of a particular simple type, one for each row of the table. The columns provide the structure according to which the rows are composed....

 is a pair of its attribute name and domain
Data domain
In data management and database analysis, a data domain refers to all the unique values which a data element may contain. The rule for determining the domain boundary may be as simple as a data type with an enumerated list of values....

 name. Domain can be considered data type
Data type
In computer programming, a data type is a classification identifying one of various types of data, such as floating-point, integer, or Boolean, that determines the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of...

, or simply, type.
An attribute has an attribute value which conforms to its domain. An attribute value is a scalar value
Scalar (computing)
In computing, a scalar variable or field is one that can hold only one value at a time; as opposed to composite variables like array, list, hash, record, etc. In some contexts, a scalar value may be understood to be numeric. A scalar data type is the type of a scalar variable...

 or a more complex structured value.
The degree
Comparative
In grammar, the comparative is the form of an adjective or adverb which denotes the degree or grade by which a person, thing, or other entity has a property or quality greater or less in extent than that of another, and is used in this context with a subordinating conjunction, such as than,...

of a relation is the number of attributes which constitute a heading. The degree of a relation value is zero or more integer. An n-ary relation is a relation value in which its degree is n.
The cardinality of a relation is the number of tuples which constitutes a relation value. The cardinality of a relation value is zero or more integer.


There are no duplicate tuples in a relation value.
A candidate key
Candidate key
In the relational model of databases, a candidate key of a relation is a minimal superkey for that relation; that is, a set of attributes such that# the relation does not have two distinct tuples In the relational model of databases, a candidate key of a relation is a minimal superkey for that...

is a certain minimal set of one or more attributes that can uniquely identify individual tuples in a relation value.

Examples

The following is an example of a heading which consists of three attribute
Column (database)
In the context of a relational database table, a column is a set of data values of a particular simple type, one for each row of the table. The columns provide the structure according to which the rows are composed....

s.
Attribute
Column (database)
In the context of a relational database table, a column is a set of data values of a particular simple type, one for each row of the table. The columns provide the structure according to which the rows are composed....

 name : Domain
Data domain
In data management and database analysis, a data domain refers to all the unique values which a data element may contain. The rule for determining the domain boundary may be as simple as a data type with an enumerated list of values....

 name
ID : Integer
Integer (computer science)
In computer science, an integer is a datum of integral data type, a data type which represents some finite subset of the mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values....

Name : String
String (computer science)
In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....

Address : String


The following is an example of a relation value which consists of the above heading and tuples (row
Row (database)
In the context of a relational database, a row—also called a record or tuple—represents a single, implicitly structured data item in a table. In simple terms, a database table can be thought of as consisting of rows and columns or fields...

s) which conform to the heading.
This example shows a relation value in visual table
Table (database)
In relational databases and flat file databases, a table is a set of data elements that is organized using a model of vertical columns and horizontal rows. A table has a specified number of columns, but can have any number of rows...

 form for the sake of convenience.
ID : Integer Name : String Address : String
102 "YONEZAWA Akinori" "Naha, Okinawa"
202 "MURATA Makoto" "Sendai, Miyagi"
104 "SAKAMURA Ken" "Kumamoto, Kumamoto"
152 "MATSUMOTO Yukihiro" "Okinawa, Okinawa"


The above relation value includes four tuples which share the same type.
As mentioned above, the attributes are unordered.
In other words, it is wrong to say "Address is on Name's right." and it is also wrong to say "Address is the third attribute."
As mentioned above too, the tuples are unordered.
In other words, it is wrong to say "The tuple of 'MURATA Makoto' is above the tuple of 'MATSUMOTO Yukihiro'" and it is also wrong to say "The tuple of 'YONEZAWA Akinori' is the first tuple."

Base relation variable and derived relation variable (view)

Relation variables (relvars)
Relvar
In relational databases, a relvar is a term coined by C. J. Date as an abbreviation for the concept of relation variable, which is the actual term used by the inventor of the relational model, E. F. Codd, regarding the same concept...

 are classified into the two classes, which are base relation variable and derived relation variable.
By applying a relational algebra
Relational algebra
Relational algebra, an offshoot of first-order logic , deals with a set of finitary relations that is closed under certain operators. These operators operate on one or more relations to yield a relation...

 expression or relational calculus
Relational calculus
Relational calculus consists of two calculi, the tuple relational calculus and the domain relational calculus, that are part of the relational model for databases and provide a declarative way to specify database queries...

 expression to one or more relation variable, one new relation value is derived.

A base relation variable is a source relation variable which is not derived from any other relation variables.
In SQL
SQL
SQL is a programming language designed for managing data in relational database management systems ....

, a database language of relational database
Relational database
A relational database is a database that conforms to relational model theory. The software used in a relational database is called a relational database management system . Colloquial use of the term "relational database" may refer to the RDBMS software, or the relational database itself...

, the term base table
Table (database)
In relational databases and flat file databases, a table is a set of data elements that is organized using a model of vertical columns and horizontal rows. A table has a specified number of columns, but can have any number of rows...

can be roughly considered base relation variable.
By using a Data Definition Language
Data Definition Language
A data definition language or data description language is a syntax similar to a computer programming language for defining data structures, especially database schemas.-History:...

 (DDL), it is able to define base relation variables.
In SQL, by using CREATE TABLE syntax, it is able to define base relation variables.
The following is an example.


CREATE TABLE List_of_people (
ID INTEGER,
Name CHAR(40),
Address CHAR(200),
PRIMARY KEY (ID)
)


A derived relation variable is a relation variable which is derived from one ore more relation variables by applying a relational algebra
Relational algebra
Relational algebra, an offshoot of first-order logic , deals with a set of finitary relations that is closed under certain operators. These operators operate on one or more relations to yield a relation...

 expression or relational calculus
Relational calculus
Relational calculus consists of two calculi, the tuple relational calculus and the domain relational calculus, that are part of the relational model for databases and provide a declarative way to specify database queries...

 expression.
View
View (database)
In database theory, a view consists of a stored query accessible as a virtual table in a relational database or a set of documents in a document-oriented database composed of the result set of a query or map and reduce functions...

is considered derived relation variable.
By using a Data Definition Language (DDL), it is able to define derived relation variables.
In SQL, by using CREATE VIEW syntax, it is able to define derived relation variables.
The following is an example.


CREATE VIEW List_of_Okinawa_people AS (
SELECT ID, Name, Address
FROM List_of_people
WHERE Address LIKE '%, Okinawa'
)

See also

  • Relation (mathematics)
    Relation (mathematics)
    In set theory and logic, a relation is a property that assigns truth values to k-tuples of individuals. Typically, the property describes a possible connection between the components of a k-tuple...

  • Domain (Type)
    Data domain
    In data management and database analysis, a data domain refers to all the unique values which a data element may contain. The rule for determining the domain boundary may be as simple as a data type with an enumerated list of values....

  • Attribute (Column)
    Column (database)
    In the context of a relational database table, a column is a set of data values of a particular simple type, one for each row of the table. The columns provide the structure according to which the rows are composed....

  • Tuple (Row)
  • Data model
    Data model
    A data model in software engineering is an abstract model, that documents and organizes the business data for communication between team members and is used as a plan for developing applications, specifically how data is stored and accessed....

  • Data modeling
    Data modeling
    Data modeling in software engineering is the process of creating a data model for an information system by applying formal data modeling techniques.- Overview :...

  • Data management
    Data management
    Data management comprises all the disciplines related to managing data as a valuable resource.- Overview :The official definition provided by DAMA International, the professional organization for those in the data management profession, is: "Data Resource Management is the development and execution...

  • Database
    Database
    A database is an organized collection of data for one or more purposes, usually in digital form. The data are typically organized to model relevant aspects of reality , in a way that supports processes requiring this information...

  • Database design
    Database design
    Database design is the process of producing a detailed data model of a database. This logical data model contains all the needed logical and physical design choices and physical storage parameters needed to generate a design in a Data Definition Language, which can then be used to create a database...

  • Database normalization
    Database normalization
    In the design of a relational database management system , the process of organizing data to minimize redundancy is called normalization. The goal of database normalization is to decompose relations with anomalies in order to produce smaller, well-structured relations...

  • Unique key
    Unique key
    In relational database design, a unique key can uniquely identify each row in a table, and is closely related to the Superkey concept. A unique key comprises a single column or a set of columns. No two distinct rows in a table can have the same value in those columns if NULL values are not used...

    • Candidate key
      Candidate key
      In the relational model of databases, a candidate key of a relation is a minimal superkey for that relation; that is, a set of attributes such that# the relation does not have two distinct tuples In the relational model of databases, a candidate key of a relation is a minimal superkey for that...

    • Primary Key
    • Alternate key
    • Super key
  • Relational model
    Relational model
    The relational model for database management is a database model based on first-order predicate logic, first formulated and proposed in 1969 by Edgar F...

  • Relational database
    Relational database
    A relational database is a database that conforms to relational model theory. The software used in a relational database is called a relational database management system . Colloquial use of the term "relational database" may refer to the RDBMS software, or the relational database itself...

     (RDB)
  • Relational database management system
    Relational database management system
    A relational database management system is a database management system that is based on the relational model as introduced by E. F. Codd. Most popular databases currently in use are based on the relational database model....

     (RDBMS)
  • Database language / Query language
    Query language
    Query languages are computer languages used to make queries into databases and information systems.Broadly, query languages can be classified according to whether they are database query languages or information retrieval query languages...

    • Data Definition Language
      Data Definition Language
      A data definition language or data description language is a syntax similar to a computer programming language for defining data structures, especially database schemas.-History:...

       (DDL)
    • SQL
      SQL
      SQL is a programming language designed for managing data in relational database management systems ....

    • D (data language specification)
      D (data language specification)
      D is a set of requirements for what Christopher J. Date and Hugh Darwen believe a relational database query language ought to be like. It is proposed in their book The Third Manifesto.-Overview:...

      • Tutorial D
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK