Quality Functions

Description

Quality functions can be used to reduce the size of a result set. The result of a Preference SQL query only consists of the BMO set. Normally, the underlying preference query has a multi-dimensional structure involving several attributes. The Pareto preference delivers compromise tuples which are not dominated by others. Having weak orders as input relations, quality functions are defined on categorical preferences by LEVELSCOREd(aNumericalPreference) or on numerical preferences by DISTANCE(aNumericalPreference). Top tuples are identified by the zero value of any quality function for all attributes. The BUT ONLY clause may be used for postfiltering the BMO result set by quality functions in order to cancel compromise tuples of bad quality.

Quality functions may also be used in the projection list of the SELECT clause by naming any preference.

Definition of DISTANCE

Formal Definition of DISTANCE(aNumericalPreference)

Definition of LEVEL

Formal Definition of LEVELSCOREd(aNumericalPreference)
Consider the above defined scoring function

Use Case

For the use case of purchasing a new car, consumers may decide that intervals of 1.000 EUR are precise enough to describe their preference with respect to the price. The price should be less than 5000 EUR. The age of the new car should be about 4 years. 2 years more are less do not matter. The age and the price are of equal importance.

SELECT name, age, LEVEL(p1), price, LEVEL(p2) 
FROM car
PREFERRING (age AROUND 4, 2 AS p1) AND (price LESS THAN 5000, 1000 AS p2)

Result set:

nameagelevel(p1)pricelevel(p2)
car144 3 1.0 7000 2.0
car136 8 4.0 4000 0.0
car235 4 0.0 10000 5.0
car184 7 3.0 6000 1.0

The quality function level(aNumericalPreference) is used in the BUT ONLY clause to further reduce the result set by guaranteeing quality levels.

SELECT name, age, LEVEL(p1), price, LEVEL(p2) 
FROM car
PREFERRING (age AROUND 4, 1 AS p1) AND (price LESS THAN 5000, 1000 AS p2)
BUT ONLY LEVEL(p1) < 2 AND LEVEL(p2) < 3

Reduced result set:

nameagelevel(p1)pricelevel(p2)
car144 3 1.0 7000 2.0

Remark

Top tuples are filtered by either LEVEL(aNumericalPreference)= 0 or DISTANCE(aNumericalPreference) = 0.0 in the BUT ONLY clause.

The LIMIT clause restricts the size of the result set by the indicated number of the clause. This syntactic reduction happens after the semantic reduction of the BUT ONLY clause.