The need for handling preferences arises, e.g., in design of autonomous systems that make choices generated by the environment where they act (context). This problem is addressed by representing the context as a database (DB) instance and a proposal of a fully declarative language capable of encoding various kinds of preferences studied in AI. Such preferences may order some pairs of choices nondeterministically, they may be extrinsic (when a dominance relationship between two choices depends also on other choices), and also context-dependent. The selection of most desirable choices can be augmented by other mandatory requirements encoded as a DB query that takes the DB instance as input. Semantics is well-defined even for conflicting preferences as it is based on the principle known in AI as minimal logic of preferences and on non-monotonic reasoning mechanism yielding a non-empty set of preference models. This set has a compact representation that can be encoded as a tractable disjunctive datalog program with optimal model semantics and exploited to denote most desirable choices as a DB query. The presented approach is flexible and promising in formulating policies to improve and automate preference based decision making in complex and dynamic contexts.