eyond the operators defined for its base type. For example, you might create a distinct type namedADDRESS, based on the built-in type VARCHAR(50). You might then create a user-defined function (UDF) TIMEZONE(ADDRESS) that computes the time zone of a given address. Depending on the database, the UDF TIMEZONE function would be written in a proprietary language or a commercial language like Java and C++. Typically, UDFs need to be registered in the database in which they will be used.
In an object-relational system, it is important to capture not only the state of stored objects but their behavior as well. The behavior of a distinct type is captured by the functions that are defined on that type. For example, unary functions such asTIMEZONE(ADDRESS) and ZIPCODE(ADDRESS) might be considered to be "methods" that define the behavior of the ADDRESS type. Therefore, it’s possible to enforce the integrity of the data and the behavior of the data as a resource that can be shared by multiple applications.
Comparing Apples to Apples
With the use of User Defined Types and Functions, we can place certain business rules directly into the database. In the above example, we have not set up any UDFs to handle the division and equals operation. The database can then enforce how apples and oranges are manipulated, and if it’s legal to compare apples.
# # #