Patent ID: 7376656

Claim:
A method for allowing users to define new aggregates in a database system, comprising: receiving code that instantiates an object of a class defining the structure of a user-defined aggregate and methods that can be invoked on instances of the user-defined aggregate; and enforcing a contract against the class so that the code, when executed at runtime, satisfies requirements of the contract to ensure desired execution thereof, the contract requiring that the class comprise a first method that is invoked to initialize the computation of an instance of the user-defined aggregate, a second method that is invoked to accumulate a plurality of values to be aggregated, and a third method that is invoked to compute a final result of the instance of the user-defined aggregate, the contract further comprising a requirement that the class specify one of a plurality of different formats which describes how instances of the user-defined aggregate are to be persisted in a database store, wherein the plurality of different formats which describe how instances of the user-defined aggregate are to be persisted in the database store comprises: a first format in which an instance of the user-defined aggregate is automatically serialized in accordance with a native format of the database system; and a second format in which an instance of the user-defined aggregate is serialized in a manner defined by the class.