1. A method for creating a user-defined type in a database system, comprising: receiving code that implements a class defining the structure of a user-defined type and methods that can be invoked on instances of the user-defined type; enforcing a contract against the class, the contract comprising: a first requirement that the class specify one of a plurality of different formats for persisting instances of the user-defined type in a database store; a second requirement that the class be capable of returning a null value for the user-defined type; and a third requirement that the class provide a method for converting the user-defined type to another type; and enabling instances of the user-defined type to be created only when the class meets the requirements of the contract.