Lets given sets D1, D2,…, Dn (does not obligatory distinct). Cartesian product of these sets, denoted as D1 × D2 ×…× Dn, is a set of all possible tuples (d1, d2,…, dn), such that di ∈ Di, i = 1,n.
R is a relation on the sets D1, D2,…, Dn, if:
R ⊆ D1 × D2 ×…× Dn = {(d1, d2,…, dn) ⏐ di ∈ Di, i = 1,2,…,n}
D1 D2 … Dn
R a11 a12 … a1n
a22 a22 … a2n
. . .
ak1 ak2 … akn
Domains
Degree, arity
Cardinality
Relation name
Relation
Tuple
As a logical condition: R(x,y,...,z) = {(x,y,...,z) | φ(x,y,...,z)}
In relational data structure order of “columns” is not essential. It is achieved at the expense of introducing of the concept “attribute”.
Attribute – is semantically sensible names of the relation columns.
Properties of the relation schema:
Every schema has a name.
Attribute names in schema must be unique.
Order of attributes in schema is not fixed
Properties of a relation instance:
Order of attributes is arbitrary, but it is defined by a relation schema.
Order of tuples is arbitrary
(tuples may be located in an arbitrary order)
Tuples must be unique within the instance
As relational structure the set of the relational schema and its instance (state).
The relational schema is a set of the schemas of relations: R1(A1,…,An)
R2(B1,…,Bk)
…
Rn(K1,…,Km)
Instance of relational schema is a set of instances of the relations in
relational schema .
Teachers: No: Name: Post: Salary:
ID NAME POST SALARY
1 John assistant 700
2 Ann senior assist. 800
3 Bob analyst 500
4 Tom professor 900
Attributes
Relation schema
Relation instance
Domains
Example: In the relation STUDENT(No, Name, Course) set of attributes (No, Name, Course) are key because tuples of any relation are unique.
Assertion. Any relation may has many keys.
Example. In the relation:
STUDENT(ID-No, Name, Pasp-ser, Pasp-No, Course)
ID-No is a simple key and pair of attributes
(Pasp-ser, Pasp-No) is a compound key.
Example. In the relation:
STUDENT(ID-No, Name, Pasp-ser, Pasp-No, Course)
key (Pasp-ser, Pasp-No, Course) is redundant key because its subset (Pasp-ser, Pasp-No, Course) is also a key
Nonredundant key is called minimal.
Among set of all candidate (minimal) keys only one is selected as a primary key.
Components of a primary may not be unique
This tuple violates primary key constraint because it contains duplicate value of the primary key
The last two tuples violate primary key constraint because they contain NULL values
Child relation may references only to primary key (or unique key) of the parent relation.
Supporting referential integrity constraints in SQL Oracle:
[ON DELETE {CASCADE | SET NULL}]
ON DELETE RESTRICT
This tuple cannot be deleted because it is referenced by tuples of a child relation
This tuple may be deleted because it is not referenced
ON UPDATE RESTRICT
The “No” attribute of these tuples cannot be updated because they are referenced by foreign keys of a child relation
This tuple may be changed including “No” attribute
ON DELETE CASCADE
When deleting this tuple the following tuples of parent relation are also deleted.
ON UPDATE CASCADE
When “No” attribute of this tuple is changed the following values of “FacNo” atribute are also changed.
ON DELETE SET NULL
On deleting this tuple the following values of “FacNo” attribute are set to NULL.
ON UPDATE SET NULL
When “No” attribute of this tuple is changed the following values of “FacNo” atribute are set to NULL.
ON DELETE SET DEFAULT
On deleting this tuple the following values of “FacNo” attribute are set to default value.
ON UPDATE SET DEFAULT
When “No” attribute of this tuple is changed the following values of “FacNo” atribute are set to default value.
It allows to model hierarchy structure that is defined on one relation.
Если не удалось найти и скачать доклад-презентацию, Вы можете заказать его на нашем сайте. Мы постараемся найти нужный Вам материал и отправим по электронной почте. Не стесняйтесь обращаться к нам, если у вас возникли вопросы или пожелания:
Email: Нажмите что бы посмотреть