Metaprogramming adds new expressive power to logic programming which can be advantageous to transfer to the field of deductive databases. We propose metaprogramming as a way to model and develop new, flexible query-answering systems. A model is shown, extending deductive databases by a classification of the clauses in the database, an integration of nonstandard inference rules, and a notion of proof constraints in which a variety of flexible ways of evaluating database queries can be expressed. Furthermore, it is indicated how techniques developed in metalogic programming for abduction and induction may be applied for modelling knowledge discovery and data mining.