Databases Reference
In-Depth Information
Abstraction
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.
abstract datatypes
New datatypes, usually user-created,
that are based on one or more built-in
datatypes and can be treated as a unit.
Methods and Encapsulation
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.
methods
Operations on an object that are
exposed for use by other objects or
applications.
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.
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.
Inheritance
Inheritance allows objects that are derived from other objects to use the methods
available in the parent object. If a new object is created with an existing object
as a base, all of the methods available with the existing object will also be avail-
able with the new object.
For example, if Scott were to implement a new EMPLOYEE type and a new
CUSTOMER type using the PERSON type as the base, then any methods that already
exist for PERSON would be available when using one of the two new types. The
method ChangeLastName, defined with the PERSON type only once, can be used
with objects defined with the CUSTOMER or EMPLOYEE type.
inheritance
Acquiring the properties of the parent, or
base object, in a new object.
Search WWH ::




Custom Search