Oracle Database Foundations
暂无分享,去创建一个
ion abstract datatypes New datatypes, usually user-created, that are based on one or more built-in datatypes and can be treated as a unit. One of the ways in which Oracle supports the object-relational model is by using abstraction. As noted earlier, Oracle has many built-in datatypes, such as numeric, string, date, and others. In addition, you can define user-defined objects as an aggregate of several other datatypes. These new user-defined types are called abstract datatypes. For example, when Scott’s widget company grows, there may be other systems where he needs to represent an employee or a customer, or in more general terms, a person. Scott can define a datatype called PERSON that stores a first name, last name, middle initial, and gender. When the new customer tables are being built, Scott just needs to use the new PERSON type in the table definition. This brings to the table two immediate benefits: reusability and standards. Creating the new table is faster, since the datatype has already been defined, and it’s less error prone than creating four individual fields. In addition, any developer who moves from an employee-oriented project to a customer-oriented project at Scott’s company will find familiarity in common objects and naming conventions.datatypes New datatypes, usually user-created, that are based on one or more built-in datatypes and can be treated as a unit. One of the ways in which Oracle supports the object-relational model is by using abstraction. As noted earlier, Oracle has many built-in datatypes, such as numeric, string, date, and others. In addition, you can define user-defined objects as an aggregate of several other datatypes. These new user-defined types are called abstract datatypes. For example, when Scott’s widget company grows, there may be other systems where he needs to represent an employee or a customer, or in more general terms, a person. Scott can define a datatype called PERSON that stores a first name, last name, middle initial, and gender. When the new customer tables are being built, Scott just needs to use the new PERSON type in the table definition. This brings to the table two immediate benefits: reusability and standards. Creating the new table is faster, since the datatype has already been defined, and it’s less error prone than creating four individual fields. In addition, any developer who moves from an employee-oriented project to a customer-oriented project at Scott’s company will find familiarity in common objects and naming conventions. Methods and Encapsulation methods Operations on an object that are exposed for use by other objects or applications. Another way in which object-oriented techniques are reflected in the Oracle object-relational database is through the use of methods and encapsulation. Methods define which operations can be performed on an object. Encapsulation restricts access to the object other than via the defined methods. encapsulation An object-oriented technique that may hide, or abstract, the inner workings of an object and expose only the relevant characteristics and operations on the object to other objects. Take a simple example of an employee object: It contains characteristics such as the employee name, address, and salary. A method against an employee object might be to get the name or change the name. Another method might be to increase the salary but never to decrease the salary. The encapsulation of the employee object prevents the direct manipulation of the characteristics of an employee object other than what the methods, driven by business rules, dictate.