You are on page 1of 14

Relation schema

and relation

Adatbázisrendszerek és alkalmazásaik
Relation schema
Definition
A relation schema R, denoted by R(A1, A2, ..., An), is
made up of a relation name R and a list of attributes, A1,
A2, ..., An.
Each attribute Ai is the name of a role played by some
domain D in the relation schema R. D is called the domain
of Ai and is denoted by dom(Ai), n is the degree of relation.

Adatbázisrendszerek és alkalmazásaik
Relation schema

Example
● CAR(brand, type, year_of_manufacture,
license_plate_number)
● STUDENT(name, address, speciality, year,
neptun_code)
● DEPARTMENT(id, dep_name,dep_dean,faculty)
Remark
It is possible that many attribute has the same domain. The attributes
indicates the different roles, interpretations of domain.
Adatbázisrendszerek és alkalmazásaik
Relation

Definition
A relation r of the relation schema R(A1, A2, ..., An), also
denoted by r(R), is a set of n-tuples r = {t1, t2 ...tm}.

Each n-tuple t is an ordered list of n values t =<v1, v2, ..,


vn>, where each value vi 1 ≤ i ≤ n, is an element of dom(Ai)
or is a special NULL value.

Adatbázisrendszerek és alkalmazásaik
Relation

Definition in another approach


A relation (or relation state) r(R) is a mathematical relation
of degree n on the domains dom(A1), dom(A2),...,dom(An),
which is a subset of the Cartesian product (denoted by ×)
of the domains that define R:
r(R) ⊆ dom(A1) × dom(A2) × … × dom(An)
In this definition the NULL value contenplates in domains
of Ai attributes.

Adatbázisrendszerek és alkalmazásaik
Relation schema and relation

Interpretation

● r is the concrete content of R relation schema(intension)


● R is the extension, abstraction of the r lation(extension)

Heuristical

● R is an empty scheleton of a table


● r is the table filled with values
Adatbázisrendszerek és alkalmazásaik
Relation and records

Remarks

● the n’s elements which we mentioned in the definition


we called records
● We referred to the ith value in the t record which
belongs to Ai attribute by t[Ai] or shortly t[i]

Adatbázisrendszerek és alkalmazásaik
Relation and record

Remark
The Cartesian product specifies all possible combinations
of values from the under-lying domains.
We denote the total number of values, or cardinality, in a
domain D by |D| , the total number of tuples in the
Cartesian product is:
|dom(A1)| ∙ |dom(A2)| ∙ … ∙ |dom(An)|
Can be proved by induction!
Adatbázisrendszerek és alkalmazásaik
Relation and record

Ordering

● The records do not assumed ordered in the theoretical


model, but at the physical level usually they are ordered
(by indexing).
● In the relation schema and all records the values are
ordered.
Adatbázisrendszerek és alkalmazásaik
Relation and record

Remarks
● From all possible combinations, a relation state at a
given time—the current relation state—reflects only
the valid tuples that represent a particular state of the
real world. As the state of the real world changes, so
does the relation state.
● the schema R is relatively static and changes very
infrequently.
Adatbázisrendszerek és alkalmazásaik
Relation and record
● Interpretation of relation
○ Predicate
■ Each record in relation correspond to a fact or a concrete
entity of the predicate
■ Example: a concrete student of STUDENT’schema : name Dick
Davidson, neptuncode HFJ345, date_of_birth 1991-
05-12
○ Condition
■ the values in every record satisfy a condition
■ Example: the STUDENT schema is true for 5 records in the
STUDENT relation, because represents 5 different facts from the
real
Adatbázisrendszerek és world
alkalmazásaik
Conventions
● A relation schema R of degree n is denoted by
R(A1, A2, ..., An)
● Q, R, S denote relation schema names.
● q, r, s denote relations/relation states
● t, u, v denote tuples
● A relation name represents the current state of relation
while R(A1, A2, …, An) refers only to the relation
schema
● An A attribute can be qualified with the name of relation
schema R to which its belong to: R.A
Adatbázisrendszerek és alkalmazásaik
Conventions

● An n-tuple t in a relation r(R) is denoted by


t = <v1, v2, …, vn>where vi is the value corresponding
to attribute Ai
○ both t[Aj] and t.Aj refer to the value vj in t for attribute Aj
○ both t[Au, Aw, …, Az] and t.(Au, Aw, …, Az), where (Au,
Aw, …, A) is a list of attributes from R, refer to the
subtuple of values <vu, vw, …, vz> from t record.

Adatbázisrendszerek és alkalmazásaik
The STUDENT relation

Adatbázisrendszerek és alkalmazásaik

You might also like