Relational Data Structure
Relation A relation is a table with columns and rows.
An RDBMS requires only that the database be perceived by the user as tables. Note, however,
that this perception applies only to the logical structure of the database: that is, the
external and conceptual levels of the ANSI-SPARC architecture discussed in Section 2.1.
It does not apply to the physical structure of the database, which can be implemented using
a variety of storage structures (see Appendix C).
Attribute An attribute is a named column of a relation.
In the relational model, relations are used to hold information about the objects to be
represented in the database. A relation is represented as a two-dimensional table in which
the rows of the table correspond to individual records and the table columns correspond to
attributes. Attributes can appear in any order and the relation will still be the same relation,
and therefore convey the same meaning.
For example, the information on branch offices is represented by the Branch relation,
with columns for attributes branchNo (the branch number), street, city, and postcode.
Similarly, the information on staff is represented by the Staff relation, with columns for
attributes staffNo (the staff number), fName, lName, position, sex, DOB (date of birth), salary,
and branchNo (the number of the branch the staff member works at). Figure 3.1 shows
instances of the Branch and Staff relations. As you can see from this example, a column contains
values of a single attribute; for example, the branchNo columns contain only numbers
of existing branch offices.
Domain A domain is the set of allowable values for one or more attributes.
Domains are an extremely powerful feature of the relational model. Every attribute in a
relation is defined on a domain. Domains may be distinct for each attribute, or two or more
attributes may be defined on the same domain. Figure 3.2 shows the domains for some of
the attributes of the Branch and Staff relations. Note that, at any given time, typically there
will be values in a domain that do not currently appear as values in the corresponding
attribute.
The domain concept is important because it allows the user to define in a central place
the meaning and source of values that attributes can hold. As a result, more information is
available to the system when it undertakes the execution of a relational operation, and
operations that are semantically incorrect can be avoided. For example, it is not sensible
to compare a street name with a telephone number, even though the domain definitions
for both these attributes are character strings. On the other hand, the monthly rental on a
property and the number of months a property has been leased have different domains
(the first a monetary value, the second an integer value), but it is still a legal operation to
multiply two values from these domains. As these two examples illustrate, a complete
implementation of domains is not straightforward and, as a result, many RDBMSs do not
support them fully.
Tuple A tuple is a row of a relation.
The elements of a relation are the rows or tuples in the table. In the Branch relation,
each row contains four values, one for each attribute. Tuples can appear in any order and
the relation will still be the same relation, and therefore convey the same meaning.
The structure of a relation, together with a specification of the domains and any other
restrictions on possible values, is sometimes called its intension, which is usually fixed
unless the meaning of a relation is changed to include additional attributes. The tuples are
called the extension (or state) of a relation, which changes over time.
Degree The degree of a relation is the number of attributes it contains.
The Branch relation in Figure 3.1 has four attributes or degree four. This means that each
row of the table is a four-tuple, containing four values. A relation with only one attribute
would have degree one and be called a unary relation or one-tuple. A relation with two
attributes is called binary, one with three attributes is called ternary, and after that the term
n-ary is usually used. The degree of a relation is a property of the intension of the relation.
Cardinality The cardinality of a relation is the number of tuples it contains.
By contrast, the number of tuples is called the cardinality of the relation and this
changes as tuples are added or deleted. The cardinality is a property of the extension of the
relation and is determined from the particular instance of the relation at any given moment.
Finally, we have the definition of a relational database.
Relational database A collection of normalized relations with distinct relation
names.
A relational database consists of relations that are appropriately structured. We refer to
this appropriateness as normalization. We defer the discussion of normalization until
Chapters 13 and 14.
Relation A relation is a table with columns and rows.
An RDBMS requires only that the database be perceived by the user as tables. Note, however,
that this perception applies only to the logical structure of the database: that is, the
external and conceptual levels of the ANSI-SPARC architecture discussed in Section 2.1.
It does not apply to the physical structure of the database, which can be implemented using
a variety of storage structures (see Appendix C).
Attribute An attribute is a named column of a relation.
In the relational model, relations are used to hold information about the objects to be
represented in the database. A relation is represented as a two-dimensional table in which
the rows of the table correspond to individual records and the table columns correspond to
attributes. Attributes can appear in any order and the relation will still be the same relation,
and therefore convey the same meaning.
For example, the information on branch offices is represented by the Branch relation,
with columns for attributes branchNo (the branch number), street, city, and postcode.
Similarly, the information on staff is represented by the Staff relation, with columns for
attributes staffNo (the staff number), fName, lName, position, sex, DOB (date of birth), salary,
and branchNo (the number of the branch the staff member works at). Figure 3.1 shows
instances of the Branch and Staff relations. As you can see from this example, a column contains
values of a single attribute; for example, the branchNo columns contain only numbers
of existing branch offices.
Domain A domain is the set of allowable values for one or more attributes.
Domains are an extremely powerful feature of the relational model. Every attribute in a
relation is defined on a domain. Domains may be distinct for each attribute, or two or more
attributes may be defined on the same domain. Figure 3.2 shows the domains for some of
the attributes of the Branch and Staff relations. Note that, at any given time, typically there
will be values in a domain that do not currently appear as values in the corresponding
attribute.
The domain concept is important because it allows the user to define in a central place
the meaning and source of values that attributes can hold. As a result, more information is
available to the system when it undertakes the execution of a relational operation, and
operations that are semantically incorrect can be avoided. For example, it is not sensible
to compare a street name with a telephone number, even though the domain definitions
for both these attributes are character strings. On the other hand, the monthly rental on a
property and the number of months a property has been leased have different domains
(the first a monetary value, the second an integer value), but it is still a legal operation to
multiply two values from these domains. As these two examples illustrate, a complete
implementation of domains is not straightforward and, as a result, many RDBMSs do not
support them fully.
Tuple A tuple is a row of a relation.
The elements of a relation are the rows or tuples in the table. In the Branch relation,
each row contains four values, one for each attribute. Tuples can appear in any order and
the relation will still be the same relation, and therefore convey the same meaning.
The structure of a relation, together with a specification of the domains and any other
restrictions on possible values, is sometimes called its intension, which is usually fixed
unless the meaning of a relation is changed to include additional attributes. The tuples are
called the extension (or state) of a relation, which changes over time.
Degree The degree of a relation is the number of attributes it contains.
The Branch relation in Figure 3.1 has four attributes or degree four. This means that each
row of the table is a four-tuple, containing four values. A relation with only one attribute
would have degree one and be called a unary relation or one-tuple. A relation with two
attributes is called binary, one with three attributes is called ternary, and after that the term
n-ary is usually used. The degree of a relation is a property of the intension of the relation.
Cardinality The cardinality of a relation is the number of tuples it contains.
By contrast, the number of tuples is called the cardinality of the relation and this
changes as tuples are added or deleted. The cardinality is a property of the extension of the
relation and is determined from the particular instance of the relation at any given moment.
Finally, we have the definition of a relational database.
Relational database A collection of normalized relations with distinct relation
names.
A relational database consists of relations that are appropriately structured. We refer to
this appropriateness as normalization. We defer the discussion of normalization until
Chapters 13 and 14.
Reviewed by Shopping Sale
on
22:45
Rating:
No comments: