Database Relations
Applying the above concepts to databases, we can define a relation schema.
Relation A named relation defined by a set of attribute and domain name pairs.
schema
Let A1, A2, . . . , An be attributes with domains D1, D2, . . . , Dn. Then the set {A1:D1, A2:D2,
. . . , An:Dn} is a relation schema. A relation R defined by a relation schema S is a set of
mappings from the attribute names to their corresponding domains. Thus, relation R is a
set of n-tuples:
(A1:d1, A2:d2, . . . , An:dn) such that d1 ¸D1, d2 ¸D2, . . . , dn ¸Dn
Each element in the n-tuple consists of an attribute and a value for that attribute. Normally,
when we write out a relation as a table, we list the attribute names as column headings and
write out the tuples as rows having the form (d1, d2, . . . , dn), where each value is taken
from the appropriate domain. In this way, we can think of a relation in the relational model
as any subset of the Cartesian product of the domains of the attributes. A table is simply a
physical representation of such a relation.
In our example, the Branch relation shown in Figure 3.1 has attributes branchNo, street,
city, and postcode, each with its corresponding domain. The Branch relation is any subset of
the Cartesian product of the domains, or any set of four-tuples in which the first element
is from the domain BranchNumbers, the second is from the domain StreetNames, and so on.
One of the four-tuples is:
{(B005, 22 Deer Rd, London, SW1 4EH)}
or more correctly:
{(branchNo: B005, street: 22 Deer Rd, city: London, postcode: SW1 4EH)}
We refer to this as a relation instance. The Branch table is a convenient way of writing out
all the four-tuples that form the relation at a specific moment in time, which explains why
table rows in the relational model are called tuples. In the same way that a relation has a
schema, so too does the relational database.
Relational database A set of relation schemas, each with a distinct name.
schema
If R1, R2, . . . , Rn are a set of relation schemas, then we can write the relational database
schema, or simply relational schema, R, as:
R = {R1, R2, . . . , Rn}
Reviewed by Shopping Sale on 22:48 Rating: 5

No comments:

Powered by Blogger.