An Introduction To Relational Database
An Introduction To Relational Database
CHAPTER III
EMP
EMP# ENAME DEPT# BUDGET
E1 Lopez D1 40K
E2 Cheng D1 42K
E3 Finzi D2 30K
E4 Saito D2 35K
Fig. 3.1 The departments and employees database(sample values)
Join:
DEPTs and EMPs over DEPT#E4
EMP
EMP# NAME DEPT# SALARY
E1 Lopez D1 40k
E2 Chenz D1 42k
E3 Finzi D2 30k
Relation Va1riable
Conceptually, the old relation value of EMP has been replaced by an entirely new
relation value. The old value (with four rows) and the new one (with three) are very similar, but
conceptually they are different values.
Indeed, the delete operation is basically just shorthand for a certain relational assignment
operation.
Both the original DELETE and the equivalent assignment statement are also basically
shorthand for certain relational assignments.
INSERT, UPDATE
The term relvar as a convenient shorthand for relation variable and relation mean relation
value.
Relation Value(Relation)
Restrict, project and join (examples) Every relation value has two parts
The heading is a set of column name: type- name pairs.
The body is a set of rows that conform to the heading.
4
EMP
EMP#: EMP# ENAME:NAME DEPT:DEPT SALARY
E1 Lopez D1 40k
E2 Chanz D1 42k
E3 Finzi D2 30k
E4 Saito D2 35k
Employee
EMP# is named ENAME, works in department DEPT#, and earns salary
SALSARY.
Employee
E1 is named Lopez, works in department D1, and earns salary 40k.
(obtained by substitution the EMP# value E1, the NAME value Lopez, the DEPT# value
D1, and the MONEY value 40k for the appropriate parameters);
Employee
E2 is named Chenz, works in department D1, and earns salary 42k.
(obtained by substitution the EMP# value E2, the NAME value Chenz, the DEPT# value
D1, and the MONEY value 42k for the appropriate parameters); and so on.
The original(given) relvars are called base relvars, and their relation values are called
base relations;
A relation that is or can be obtained from those base relations by means of some
relational expression is called a derived or derivable relation.
Base relvars are called real relvars.
Relational systems obviously have to provide a means for creating the base relvars in the
first place.
5
For example:
For example:
TOPEMP
EMP# ENAME DEPT# SALARY
E1 Lopez D1 42k
E2 Chenz D1 40k
E3 Finzi D2 30k
E4 Saito D2 35k
If DEPT and EMP are thought of as real relvars, then TOPEMP might be thought of
as a virtual relvar:- i.e., a relvar that apparently exiats in its own right, but in fact does
not (its value at any given time depends on the value (s) of certain other relvar(s)).
The base relvar vs. view distinction is frequently characterized thus:
Base relvars
6