Database Reference
In-Depth Information
value from
. The latter define algebraic relationships among measure attributes,
and are formally defined in what follows.
An attribute expression e on R is either a constant or the name of a numerical
(either measure or non-measure) attribute of R . Given an attribute expression e on
R and a tuple t over R , we denote as e
Δ
(
t
)
the value e ,if e is a constant, or the value
t [ e ]
,if e is an attribute.
Given a relation scheme R and a sequence y of variables, an aggregation function
χ (
y
)
on R is a triplet
R
,
e
(
y
)
, where e is an attribute expression on R and
α (
y
)
is a (possibly empty) boolean combination of atomic comparisons of the form X
Y ,
where X and Y are constants, attributes of R , or variables in y, and
is a comparison
operator in
{ = , = ,≤,≥,<,>}
. When empty,
α
will be denoted as
.
Given an aggregation function
χ (
y
)=
R
,
e
(
y
)
and a sequence a of constants
with
|
a
| = |
y
|
,
χ (
a
)
maps every instance r of R to
t r t | = α ( a ) e
(
t
)
, where
α (
a
)
is
the (ground) boolean combination of atomic comparisons obtained from
by
replacing each variable in y with the corresponding value in a. We assume that,
given a relation R and an aggregation function
α (
y
)
χ
on R , if the condition
α
of
χ
is not
satisfied by any tuple in the instance of R , then
returns 0.
Example 2.1. The following aggregation functions are defined on the relation scheme
BalanceSheets (Year, Section, Subsection, Type, Value) of Example 1.3, where
K BalanceSheets = {
χ
Year , Subsection
}
,
M BalanceSheets = {
Value
}
, and the measure at-
tribute Value ranges over domain
Z
:
χ 1 (
x
,
y
,
z
)=
BalanceSheets, Value,
(
Section
=
x
Year
=
y
Type
=
z
)
χ 2 (
x
,
y
)=
BalanceSheets, Value,
(
Year
=
x
Subsection
=
y
)
1 returns the sum of Value of all the tuples having Section x , Year y and
Type z . Basically,
χ
Function
χ 1
(
x
,
y
,
z
)
corresponds to the following SQL expression:
SELECT sum ( Value )
FROM BalanceSheets
WHERE Section = x AND Year = y AND Type = z
For instance, evaluating
χ 1 ( 'Receipts', '2008', 'det' )
on the relation instance shown in
Table 1.1 results in 900
+
100
=
1000, whereas
χ 1 ( 'Disbursements', '2008', 'aggr' )
re-
turns 1220. Function
χ 2 returns the sum of Value of all the tuples where Year=x
and Subsection=y . In our running example, as the pair Year , Subsection is a key for
BalanceSheets , the sum returned by
χ 2 is an attribute value of a single tuple. For in-
stance,
χ 2 (
'2008', 'cash sales'
)
returns 900, whereas
χ 2 (
'2008', 'net cash inflow'
)
returns 30.
Definition 2.1 (Aggregate constraint). Given a database scheme
D
, an aggregate
constraint on
D
is an expression of the form:
x
i = 1 c i · χ i ( y i ) K
n
φ (
x
)=
(2.1)
where:
Search WWH ::




Custom Search