Object Tables   «Prev  Next»

Lesson 3 Object-oriented terms
Objective Understand the different terms for Oracle objects.

Object Oriented Terms used with Oracle

The commonly used object-oriented terms within Oracle. These Object Terms include
  1. object type,
  2. object,
  3. attribute,
  4. method, and
  5. object table.

The following SlideShow illustrates each term in detail:

  1. If you are familiar with object terminology, an object type is similar to a class.
  2. The variables that constitute the data structure are called attributes.
  3. This example defines the physical address of a customer as an object type.
  4. An object is an instance of an object type.
  5. The following example defines a customer object.
  6. An attribute is an integral part of an Oracle object, similar to a column within a table.
  7. A method is a procedure or function, usually implemented within PL/SQL
  8. An object table is a table defined on an object or a set of objects.


PL/SQL Object Characterization

1) If you are familiar with object terminology, an object type is similar to a class.
1) If you are familiar with object terminology, an object type is similar to a class. An object type is a user-defined composite data type that can be created and maintained using the Data Definition Language (DDL). An object type represents a data structure that encapsulates data, functions and procedures needed to manipulate data.

2) The variables that constitute the data structure are called attributes. The functions and procedures that characters the behavior of the object type are called methods.
2) The variables that constitute the data structure are called attributes. The functions and procedures that characterize the behavior of the object type are called methods. The type is simply a template and holds no data on its own. You can create variables, tables, columns, and other constructs with the object type.

3) This example defines the physical address of a customer as an object type.
3) This example defines the physical address of a customer as an object type.

4) This example defines the physical address of a customer as an object type
4) This attributes of the object type are defined as scalar data types.

Object Oriented Programming
5) An object is an instance of an object type. The object is the location where the actual data resides.
5) An object is an instance of an object type. The object is the location where the actual data resides. There are two types of objects: 1) persistent and 2) transient. An object stored within a table is a persistent object. An object that exists temporarily within PL/SQL variables is a transient object.

6) The following example defines a customer object.
6) The following example defines a customer object.

7) The following example defines a customer object.
7) The object has attributes of its own. Additionally, this object is associated with the address object type.

8) An attribute is an integral part of an Oracle object, similar to a column within a table.
8) An attribute is an integral part of an Oracle object, similar to a column within a table. Each attribute must be defined as a single data type, either scalar, such as VARCHAR2 or INTEGER, or composite, such as a user-defined nested-table or another object. In the above example, CUST_ID, FIRST_NAME, LAST_NAME, FULL_ADDRESS, PHONE_LIST, LAST_UPDATE, and UPDATED_BY_USER are the attributes of the object.

9) A method is a procedure or function, usually implemented within PL/SQL and stored within the database or written in a language such as C and stored externally.
9) A method is a procedure or function, usually implemented within PL/SQL and stored within the database or written in a language such as C and stored externally. A method implements specific operations that an application can perform on the data.

10) An object table is a table defined on an object or a set of objects.
10) An object table is a table defined on an object or a set of objects. The object table can have its own attributes other than the attributes of the associated object.


Generally, you can think of the relationship between objects and object tables in the following way:
  1. Classes (object types), which represent entities, map to object tables.
  2. Attributes map to columns.
  3. Objects map to rows.
Viewed in this way, each object table is an implicit type whose objects (specific rows) have the same attributes (column values). Creating explicit user-defined data types and object tables introduces a new level of functionality. The following example defines CUSTOMER_OBJ_TABLE based on the CUSTOMER_TYPE object:


CREATE TABLE CUSTOMER_OBJ_TABLE
OF CUSTOMER_TYPE
(CONSTRAINT CUSTOMER_OBJ_PK 
    PRIMARY KEY (CUST_ID)
)

Many Rooms in the Oracle House

Most of the common Oracle objects (1. stored programs, 2. tables, 3. indexes) are owned by individual Oracle accounts. When user scott creates a stored procedure, it goes into his own "room" inside Oracle and his place is known as a schema. You cannot see into his schema unless he (or the administrator) lets you in through the door.
The "walls" separating them are a set of rules that the database enforces. By default, a stored procedure can read or write from any table in the same schema, but not from tables in another schema. However, if goodguy so wishes, he can let you view or even modify the contents of his tables. He can also give you permission to execute his PL/SQL programs. If he does not give you these rights, you probably will not even know that his tables and programs exist. You have no way of "seeing" into his account even to determine whether he owns anything interesting unless you have received administrator-level privileges. And of course, the reverse is also true; he cannot see your data unless he has been specifically authorized. In the next lesson, the basic techniques used to query object tables will be discussed.

Object Oriented Databases