It is widely recognized that production rules in database systems can be used to automatically maintain derived data such as views. However, writing a correct set of rules for e ciently maintaining a given view can be a di cult and ad-hoc process. We provide a facility whereby a user de nes a view as an SQL select expression, from which the system automatically derives set-oriented production rules that maintain a materialization of that view. The maintenance rules are triggered by operations on the view's base tables. Generally, the rules perform incremental maintenance: the materialized view is modi ed according to the sets of changes made to the base tables, which are accessible through logical tables provided by the rule language. However, for some operations substantial recomputation may be required. We give algorithms that, based on key information, perform syntactic analysis on a view de nition to determine when e cient maintenance is possible.