Database Reference
In-Depth Information
1. n is a positive integer, and c 1
,...,
c n ,
K are constants in
Q
;
φ (
)
2.
is a (possibly empty) conjunction of atoms constructed from relation names,
constants, and all the variables in x;
3. each
x
χ
(
)
is an aggregation function, where y i is a list of variables and con-
stants, and every variable that occurs in y i also occurs in x.
y i
i
The semantics of an aggregate constraint is the “natural” one, that is, given a
database instance D over the database scheme
D
, an aggregate constraint of the
form (2.1) imposes that, for all the substitutions
θ
of the variables in x with constants
i
of D making
K holds on D .
Observe that aggregate constraints enable equalities to be expressed as well, since
an equality can be viewed as a pair of inequalities. For the sake of brevity, in the
following, equalities will be written explicitly.
φ ( θ (
x
))
true , the inequality
1 c i · χ i ( θ (
y i ))
=
Example 2.2. The constraint
κ 1 defined in Example 1.3 can be expressed as follows:
x
,
y
,
s
,
w
,
v BalanceSheets
(
y
,
x
,
s
,
w
,
v
)= ⇒ χ 1 (
x
,
y
,
'det'
) − χ 1 (
x
,
y
,
'aggr'
)=
0
For the sake of simplicity, in the following we will use a shorter notation for de-
noting aggregate constraints, where universal quantification is implied and variables
in
which do not occur in any aggregation function are replaced with the symbol
' '. For instance, the constraint of Example 2.2 can be written as:
φ
BalanceSheets
(
y
,
x
,
,
, )= ⇒ χ 1 (
x
,
y
,
' det '
) − χ 1 (
x
,
y
,
' aggr '
)=
0
Example 2.3. The constraints
κ
2 and
κ
3 of Example 1.3 can be expressed as follows:
κ 2 : BalanceSheets
(
x
,
,
,
, )=
χ 2 (
x
,
'net cash inflow'
)
χ 2 (
) =
x
,
'total cash receipts'
) − χ 2 (
x
,
'total disbursements'
0
κ 3 : BalanceSheets
(
x
,
,
,
, )=
χ 2 (
x
,
'ending cash balance'
)
χ 2 (
) =
x
,
'beginning cash'
)+ χ 2 (
x
,
'net cash inflow'
0
The following examples show additional usages of aggregate constraints.
Example 2.4. Consider the database scheme
resulting from the integration of the
three source databases consisting of the following relation schemes, respectively:
D
R 1 (
Year , Costs
)
R 2
(
Project , Year , Costs
)
R 3
(
Project , Month , Year , Costs
)
M
= {
}
[
..
]
where
.
The above-introduced three relations come from three distinct sources, each of
them containing information about the costs of the projects developed by a univer-
sity, with different level of granularity. Specifically, the central administration of the
university received and maintained in R 1 the total yearly costs of the projects, while
the business offices of the faculty and the department received and stored the costs
Costs
, for each i
1
3
R i
Search WWH ::




Custom Search