Share on Facebook Share on Twitter Email
Answers.com

Relation

 
Wikipedia: Relation (database)

In relational model:

a relation is a data structure which consists of a heading and an unordered set of tuples which share the same type.
When Edgar F. Codd invented relational model, he generalized the concept of binary relation (mathematical relation) to n-ary relation. Relation is a fundamental concept in relational model.
A relation has zero or more tuples.
A relation value is an instance of relation.
A relation variable (relvar) is a variable which has a relation value.

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

In SQL, a database language for relational databases, a relation variable is called a table.

Relational model concepts including relation

A relation value , which is assigned to a certain relation variable, is time-varying. By using a Data Definition Language (DDL), it is able to define relation variables.

A heading is the unordered set of certain attributes (columns). 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) is a pair of its attribute name and domain name. Domain can be considered data type, or simply, type.
An attribute has a attribute value which conforms to its domain. An attribute value is a scalar value or a more complex structured value.
The degree 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. The certain minimal set of one or more attributes can identify individual tuples in a relation value. Such an attribute set is called as a candidate key.

Contents

Examples

The following is an example of a heading which consists of three attributes.

An example of a heading which consists of three attributes
Attribute name : Domain name
ID : Integer
Name : String
Address : String

The following is an example of a relation value which consists of the above heading and tuples (rows) which conform to the heading. This example shows a relation value in visual table form for the sake of convenience.

An example of a relation value which consists of tuples which share the same type
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) are classified into the two classes, which are base relation variable and derived relation variable. By applying a relational algebra expression or relational calculus 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, a database language of relational database, the term base table can be roughly considered base relation variable. By using a Data Definition Language (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 expression or relational calculus expression. View 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

References


Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
 
 

 

Copyrights:

Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Relation (database)" Read more