of atoms. Consequently, the set of preferred atoms,
with respect to the preference rules ρ
2
and ρ
1
, is
{fish, white-wine}.
Contributions. In this paper we study the use of
preferences in querying databases. We consider gen-
eral (stratified) Datalog queries and general preferen-
ces: the head of preference rules may contain atoms
belonging to different relations and the body consists
of a conjunction of literals. A semantics where both
query and preferences are partitioned into strata is
defined. Under such a semantics, the query is com-
puted one stratum at time and for each stratum (of
the query), the preferences are applied one stratum at
time.
Related Work. The increased interest in preferen-
ces in logic programs is reflected by an extensive
number of proposals and systems for preference han-
dling. Most of the approaches propose an extension
of logic programming by adding preference informa-
tion. The most common form of preference consists
in specifying a strict partial order on rules (Delgrande
et al., 2003; Gelfond and Son, 1997; Sakama and
Inoue, 2000; Zhang and Foo, 1997), whereas more
sophisticated forms of preferences also allow priori-
ties to be specified between conjunctive (disjunctive)
knowledge with preconditions (Brewka et al., 2003;
Sakama and Inoue, 2000) and numerical penalties for
suboptimal options (Brewka, 2004).
Considering the use of preferences in querying
databases, an extension of relational calculus express-
ing preferences for tuples in terms of logical con-
ditions has been proposed in (Lacroix and Lavency,
1987). Preferences requiring non-deterministic
choice among atoms which minimize or maximize the
value of some attribute has been proposed in (Greco
and Zaniolo, 2002). An extension of Datalog with
preference relations, subsuming the approach propo-
sed in (Lacroix and Lavency, 1987), has been pro-
posed in (Kostler et al., 1995), whereas an exten-
sion of SQL including preferences has been propo-
sed in (Kieβling, 2002; Kieβling and Kostler, 2002).
In the last proposal several built-in operators and a
formal definition of their combinations (i.e. intersec-
tion, union, Pareto composition, etc.) has been con-
sidered. Borzsonyi et al. proposed the skyline opera-
tor (Borzsonyi et al., 2001), to filter out a set of “inter-
esting” point (i.e. not dominated by any other point)
from a potential large set of points. An extension of
SQL with a skyline operator has been also proposed.
A framework for specifying preferences using logical
formulas and its embedding into relational algebra has
been introduced in (Chomicki, 2003). The paper also
introduces the winnow operator which generalizes the
skyline operator. The implementation of winnow and
ranking is also studied in (Torlone and Ciaccia, 2002).
Algorithms for computing skyline operators are also
studied in (Kossmann et al., 2002; Papadias et al.,
2003; Chomicki et al., 2003). In (Agrawal and Wim-
mers, 2002) the use of quantitative preferences (scor-
ing functions) in queries is proposed.
In this work, in contrast with previous proposals, gen-
eral preferences and a different (stratified) semantics,
which we believe to be more intuitive, are considered.
2 BACKGROUND
Familiarity with disjunctive logic programs and di-
sjunctive deductive databases is assumed (Ullman,
1988).
Datalog Programs. A term is either a constant or a
variable. An atom is of the form p(t
1
, . . . , t
h
), where
p is a predicate symbol of arity h and t
1
, . . . , t
h
are
terms. A literal is either an atom A or its negation
not A. A (Datalog) rule r is a clause of the form
A ← B
1
, ..., B
m
, not B
m+1
, ..., not B
n
, ϕ n ≥ 0
where A, B
1
, . . . , B
n
are atoms, whereas ϕ is a conjunc-
tion of built-in atoms of the form uθv where u and v
are terms and θ is a comparison predicate. A is the
head of r (denoted by Head(r)), whereas the conjunc-
tion B
1
, ..., B
m
, not B
m+1
, ..., not B
n
, ϕ is the body of r
(denoted by Body(r)). It is assumed that each rule
is safe, i.e. a variable appearing in the head or in a
negative literal also appears in a positive body literal.
A (Datalog) program is a finite set of rules. A not-free
program is called positive. The Herbrand Universe
U
P
of a program
P is the set of all constants appear-
ing in
P , and its Herbrand Base B
P
is the set of all
ground atoms constructed from the predicates appear-
ing in
P and the constants from U
P
. A term (resp. an
atom, a literal, a rule or a program) is ground if no
variable occurs in it. A rule r
′
is a ground instance
of a rule r if r
′
is obtained from r by replacing every
variable in r with some constant in
U
P
; ground(
P )
denotes the set of all ground instances of the rules in
P .
An interpretation M for a Datalog program
P is any
subset of
B
P
; M is a model of
P if it satisfies all rules
in ground(
P ). The (model-theoretic) semantics for
positive
P assigns to P the set of its minimal models
M M (P ), where a model M for P is minimal if no
proper subset of M is a model for
P . For any interpre-
tation M,
P
M
is the ground positive program derived
from ground(
P ) by 1) removing all rules that contain
ICEIS 2007 - International Conference on Enterprise Information Systems
120