Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions...

37
Oracle Object-Relational Oracle Object-Relational Model Model

Transcript of Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions...

Page 1: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

Oracle Object-Relational ModelOracle Object-Relational Model

Page 2: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

- Structures : Structures : tablestables, views, indexes, etc., views, indexes, etc.

- Operations : actions that manipulate data stored in structures- Operations : actions that manipulate data stored in structures

- Integrity rules : laws that determine which operations are - Integrity rules : laws that determine which operations are allowed on data and structures. allowed on data and structures.

Oracle Oracle RelationalRelational Model Model

Page 3: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • Collection of database objects available to the usersCollection of database objects available to the users

• • Schema objects: tables, views, indexes, stored procedures, Schema objects: tables, views, indexes, stored procedures, etc. etc.

SchemaSchema

Page 4: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

Structures(1)Structures(1)

• • TablesTables: basic unit of data storage. They can be queried, : basic unit of data storage. They can be queried, updated, inserted into, deleted from, etc.updated, inserted into, deleted from, etc.

• • ViewsViews: custom-tailored presentation of the data in one or : custom-tailored presentation of the data in one or more table. They do not really contain any data. They can more table. They do not really contain any data. They can be queried, updated, inserted into, deleted from, etc.be queried, updated, inserted into, deleted from, etc.

• • MaterializedMaterialized viewsviews: : storestore the result of a query in a separate the result of a query in a separate schema object. schema object.

Page 5: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • Optional structures associated with tables which can be Optional structures associated with tables which can be created to increase the performance of queriescreated to increase the performance of queries

• • They are created on one or more columns of a tableThey are created on one or more columns of a table

• • Once created, they are automatically maintained and used Once created, they are automatically maintained and used by Oracleby Oracle

• • Changes to tables are transferred to all relevant indexes (in Changes to tables are transferred to all relevant indexes (in a transparent way to users)a transparent way to users)

Structures(2): IndexesStructures(2): Indexes

Page 6: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

Allows to:Allows to:

1. define object types specifying 1. define object types specifying - the structure of the data and - the structure of the data and - the methods of operating on the data- the methods of operating on the data

2. use these datatypes within the relational model2. use these datatypes within the relational model

Object types are abstractions of the real-world entitiesObject types are abstractions of the real-world entities

Oracle Oracle Object-RelationalObject-Relational Model Model

Page 7: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

Three components: Three components:

1.1. NameName: to identify the object type uniquely: to identify the object type uniquely

2. 2. AttributesAttributes: to model the structure of the entity. They : to model the structure of the entity. They are built-in or user-defined datatypesare built-in or user-defined datatypes

3.3. MethodsMethods: functions/procedures written in PL/SQL or : functions/procedures written in PL/SQL or Java and stored in the DB or written in a different Java and stored in the DB or written in a different language and stored externally.language and stored externally.

NOTE: every object type has a constructor method to create NOTE: every object type has a constructor method to create a new object of that typea new object of that type

Object TypesObject Types

Page 8: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

CREATE TYPE person AS OBJECT (name VARCHAR2(30),phone VARCHAR2(20) ); CREATE TYPE lineitem AS OBJECT (item_name VARCHAR2(30),quantity NUMBER, unit_price NUMBER(12,2) );

Object types: PERSON, LINEITEM, Object types: PERSON, LINEITEM,

NAME, PHONE, ITEM_NAME, etc. are attributes of their NAME, PHONE, ITEM_NAME, etc. are attributes of their respective object types. respective object types.

ExampleExample

Page 9: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • ObjectObject: variable of an object type: variable of an object type

• • Characterised by attributes and methods based on its typeCharacterised by attributes and methods based on its type

• • Possible to assign values to object attributes and call object Possible to assign values to object attributes and call object methodsmethods

ObjectObject

Page 10: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • Functions or procedures called by an application to model Functions or procedures called by an application to model the behaviour of an objectthe behaviour of an object

• • Three types: Three types:

- member- member

- static- static

- comparison- comparison

MethodsMethods

Page 11: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • Function or procedure that always has an implicit SELF Function or procedure that always has an implicit SELF parameter and can work with the attributes of a specific parameter and can work with the attributes of a specific objectobject

• • Invoked with dot notation: object_variable.method()Invoked with dot notation: object_variable.method()

• • Useful to write methods where the operation affects a Useful to write methods where the operation affects a specific object and you do not need to pass parametersspecific object and you do not need to pass parameters

Member MethodsMember Methods

Page 12: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • Function or procedure that does not have an implicit SELF Function or procedure that does not have an implicit SELF parameterparameter

• • Invoked with dot notation using the type name: Invoked with dot notation using the type name: type_name.method()type_name.method()

• • Useful for procedures that work with global data rather Useful for procedures that work with global data rather than a specific object or functions that return the same than a specific object or functions that return the same value independently of the particular objectvalue independently of the particular object

Static MethodStatic Method

Page 13: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • Oracle has facilities for comparing two data items of a given Oracle has facilities for comparing two data items of a given built-in type and determining whether one is greater than, built-in type and determining whether one is greater than, equal to, or less than the other. equal to, or less than the other.

• • To compare two objects of a user-defined type, the creator To compare two objects of a user-defined type, the creator of the type must define comparison methods of the type must define comparison methods

• • Two types: Two types: mapmap methods or methods or orderorder methods. methods.

Comparison MethodsComparison Methods

Page 14: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • Map methods produce a single value of a built-in type that Map methods produce a single value of a built-in type that can be used for comparisons and sorting. can be used for comparisons and sorting.

• • For example, if you define an object type called For example, if you define an object type called RECTANGLE, the map method AREA can multiply its RECTANGLE, the map method AREA can multiply its HEIGHT and WIDTH attributes and return the answer. HEIGHT and WIDTH attributes and return the answer.

• • Oracle can then compare two rectangles by comparing their Oracle can then compare two rectangles by comparing their areas.areas.

Map MethodsMap Methods

Page 15: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • They use their own internal logic to compare two objects of a given They use their own internal logic to compare two objects of a given object type and return a value that encodes the order relationship: object type and return a value that encodes the order relationship:

-1 if the first is smaller, -1 if the first is smaller,

0 if they are equal, and 0 if they are equal, and

1 if the first is larger. 1 if the first is larger.

• • For example, an order method can allow you to sort a set of For example, an order method can allow you to sort a set of addresses based on their distance from a fixed point, or some other addresses based on their distance from a fixed point, or some other operation more complicated than comparing individual values. operation more complicated than comparing individual values.

• • In defining an object type, you can specify either a map method or In defining an object type, you can specify either a map method or an order method for it, but not both. an order method for it, but not both.

Order MethodsOrder Methods

Page 16: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • If an object type has no comparison method, Oracle cannot If an object type has no comparison method, Oracle cannot determine a greater-than or less-than relationship between two determine a greater-than or less-than relationship between two objects of that type objects of that type

• • It can, however, attempt to determine whether two objects of It can, however, attempt to determine whether two objects of the type are equal. Oracle compares two objects of a type that the type are equal. Oracle compares two objects of a type that lacks a comparison method by comparing corresponding lacks a comparison method by comparing corresponding attributes: attributes:

-- If all the attributes are non-null and equal, the objects are If all the attributes are non-null and equal, the objects are considered equal.considered equal.

   -- If there is an attribute for which the two objects have unequal non-If there is an attribute for which the two objects have unequal non-null values, the objects are considered unequal.null values, the objects are considered unequal.

-- Otherwise, the objects are considered unequal.Otherwise, the objects are considered unequal.

Other ComparisonsOther Comparisons

Page 17: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

Constructor MethodsConstructor Methods

• Every object type has a system-defined Every object type has a system-defined constructor method constructor method that makes a new object and sets up the values of its that makes a new object and sets up the values of its attributes. attributes.

• The name of the constructor method is the name of the The name of the constructor method is the name of the object type. object type.

• Its parameters have the names and types of the object type’s Its parameters have the names and types of the object type’s attributes. attributes.

• The constructor method is a function. It returns the new The constructor method is a function. It returns the new object as its value. object as its value.

Page 18: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

Constructor Methods: ExampleConstructor Methods: Example

• For example, the expression:For example, the expression: 

purchase_order(1000376,person ("John Smith","1-800-555-1212"),NULL )

 

represents a purchase order object with the following attributes:represents a purchase order object with the following attributes: 

id 1000376contact person("John Smith","1-800-555-1212")lineitems NULL

 • The expressionThe expression person ("John Smith", "1-800-555-1212") is an is an

invocation of the constructor function for the object type PERSON. The invocation of the constructor function for the object type PERSON. The object that it returns becomes theobject that it returns becomes the contact attribute of the purchase attribute of the purchase order.order.

Page 19: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • An An object table object table is a special kind of table in which each row represents an is a special kind of table in which each row represents an object. For example, the following statement defines an object table for object. For example, the following statement defines an object table for objects of the PERSON type:objects of the PERSON type:

 CREATE TABLE person_table OF person;

 • Oracle allows you to view this table in two ways:Oracle allows you to view this table in two ways:  

– A single-column table in which each row is a PERSON object, allowing A single-column table in which each row is a PERSON object, allowing you to perform object-oriented operations.you to perform object-oriented operations.

– A multi-column table in which each attribute of the object type PERSON, A multi-column table in which each attribute of the object type PERSON, namely NAME and PHONE, occupies a column, allowing you to perform namely NAME and PHONE, occupies a column, allowing you to perform relational operations.relational operations.

  

Object Tables (1)Object Tables (1)

Page 20: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• For example, you can execute the following instructions:For example, you can execute the following instructions: 

INSERT INTO person_table VALUES ("John Smith","1-800-555-1212" );

 SELECT VALUE(p) FROM person_table pWHERE p.name = "John Smith";

 • The first instruction inserts a PERSON object into PERSON_TABLE as The first instruction inserts a PERSON object into PERSON_TABLE as

a multi-column table. a multi-column table.

• The second selects from PERSON_TABLE as a single column table.The second selects from PERSON_TABLE as a single column table.  

Object Tables (2)Object Tables (2)

Page 21: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• • Way to access relational data using object-relational featuresWay to access relational data using object-relational features

• Let you develop object-oriented applications without changing Let you develop object-oriented applications without changing the underlying relational schemathe underlying relational schema

• Just as a view is a virtual table, an object view is a virtual object Just as a view is a virtual table, an object view is a virtual object tabletable

• Each row in the view is an object: you can call its methods, access Each row in the view is an object: you can call its methods, access its attributes using the dot notation, etc.its attributes using the dot notation, etc.

• Object views provide the same features as traditional views, Object views provide the same features as traditional views, applied to object dataapplied to object data

Object Views(1)Object Views(1)

Page 22: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

The procedure for defining an object view is:The procedure for defining an object view is:

1.1. Define an object type, where each attribute corresponds to an Define an object type, where each attribute corresponds to an existing column in a relational tableexisting column in a relational table

2. 2. Write a query that specifies how to extract the data from relational Write a query that specifies how to extract the data from relational tables. Specify the columns in the same order as the attributes in the tables. Specify the columns in the same order as the attributes in the object type.object type.

3. 3. Specify a unique value, based on attributes of the underlying data, to Specify a unique value, based on attributes of the underlying data, to serve as an object identifier, which allows you to create pointers serve as an object identifier, which allows you to create pointers (REFs) to the objects in the view. You can often use an existing (REFs) to the objects in the view. You can often use an existing primary key. primary key. 

 

Object Views (2)Object Views (2)

Page 23: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• DefineDefine an object view, where each row an object view, where each row in the view is an object ofin the view is an object of type type EMPLOYEE_T:EMPLOYEE_T:

CREATE TABLE emp_table (empnum NUMBER (5),ename VARCHAR2 (20),salary NUMBER (9, 2),job VARCHAR2 (20) );

CREATE TYPE employee_t ( empno NUMBER (5),ename VARCHAR2 (20),salary NUMBER (9, 2),job VARCHAR2 (20) );

CREATE VIEW emp_view1 OF employee_tWITH OBJECT IDENTIFIER (empno) ASSELECT e.empnum, e.ename, e.salary, e.jobFROM emp_table eWHERE job = ’Developer’;

• To access the data from the EMPNUM column of the relational table, you would To access the data from the EMPNUM column of the relational table, you would access the EMPNO attribute of the object type.access the EMPNO attribute of the object type.

Object Views: ExampleObject Views: Example

Page 24: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

1.1. UseUse INSERT statement to add objects to an object table. statement to add objects to an object table. Example: insert a Example: insert a Person object into object table object into object table persons:

INSERT INTO personsVALUES (’Jennifer’, ’Lapidus’, ...);

2.2. Alternatively, use the constructor for object type Alternatively, use the constructor for object type Person to to insert an object into object table insert an object into object table persons:

INSERT INTO personsVALUES (Person(’Albert’, ’Brooker’, ...));

Inserting ObjectsInserting Objects

Page 25: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

3.3. To insert objects into an object table, you can use a subquery To insert objects into an object table, you can use a subquery that returns objects ofthat returns objects of the same type. the same type. ExampleExample::

INSERT INTO persons2

SELECT VALUE(p) FROM persons p

WHERE p.last_name LIKE ’%Jones’;

The rows copied to object table persons2 are given new object The rows copied to object table persons2 are given new object identifiers. Noidentifiers. No object identifiers are copied from object table object identifiers are copied from object table persons.

Inserting ObjectsInserting Objects

Page 26: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• Useful for modelling one-to-many relationshipsUseful for modelling one-to-many relationships

• ExampleExample: a purchase order has an arbitrary number of line : a purchase order has an arbitrary number of line items, so you may want to put the line items into a collectionitems, so you may want to put the line items into a collection

• Oracle supports two Oracle supports two collectioncollection datatypes: varrays and nested datatypes: varrays and nested tablestables

 

CollectionsCollections

Page 27: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

Varrays have a maximum number of elements (but upper bound Varrays have a maximum number of elements (but upper bound can be changed); the order of elements is defined can be changed); the order of elements is defined 

Nested tables can have any number of elements, and you can Nested tables can have any number of elements, and you can select, insert, delete (as with regular tables); the order of the select, insert, delete (as with regular tables); the order of the elements is not definedelements is not defined

ExampleExample: a purchase order object may have a nested table of line : a purchase order object may have a nested table of line items, while a rectangle object may contain a varray with 4 items, while a rectangle object may contain a varray with 4 coordinates.coordinates.

VARRAYS and Nested TablesVARRAYS and Nested Tables

Page 28: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• Use varrays when you need to:Use varrays when you need to:

- loop through the elements in order, - loop through the elements in order,

- store only a fixed number of items, - store only a fixed number of items,

- retrieve and manipulate the entire collection as a value- retrieve and manipulate the entire collection as a value

• Use nested tables when you need to Use nested tables when you need to

- run efficient queries on collections, - run efficient queries on collections,

- handle arbitrary numbers of elements, - handle arbitrary numbers of elements,

- do mass insert/update/delete operations- do mass insert/update/delete operations

VARRAYS and Nested Tables:VARRAYS and Nested Tables:

NotesNotes

Page 29: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• You can make an object of a collection type by calling its You can make an object of a collection type by calling its constructor methodconstructor method

• The name of the constructor method is the name of the type, and The name of the constructor method is the name of the type, and its argument is a list of the new collection’s elements (separated its argument is a list of the new collection’s elements (separated by commas)by commas)

• Calling the constructor method with an empty list creates an Calling the constructor method with an empty list creates an empty collection of that typeempty collection of that type

Creating CollectionsCreating Collections

Page 30: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• ArrayArray = ordered set of data elements of the same datatype = ordered set of data elements of the same datatype

• Each element has an index = a number corresponding to the Each element has an index = a number corresponding to the element’s position in the arrayelement’s position in the array

• Oracle VARRAYs: arrays of variable size Oracle VARRAYs: arrays of variable size

• You must specify a maximum size when you declare the array You must specify a maximum size when you declare the array type type

VARRAYSVARRAYS

Page 31: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• Example: Example: 

CREATE TYPE prices AS VARRAY(10) OF NUMBER(12,2);

• The VARRAYs of type PRICES have no more than ten elements, The VARRAYs of type PRICES have no more than ten elements, each of datatype NUMBER(12,2).each of datatype NUMBER(12,2).

• Creating an array type does not allocate space. It defines a Creating an array type does not allocate space. It defines a datatype, which you can use as:datatype, which you can use as:

- The datatype of a column of a relational table- The datatype of a column of a relational table

- An object type attribute- An object type attribute

- The type of a PL/SQL variable, parameter, or function return value- The type of a PL/SQL variable, parameter, or function return value

VARRAYS: ExampleVARRAYS: Example

Page 32: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• Nested Nested tabletable = unordered set of data = unordered set of data elementselements, all of the same , all of the same datatype. datatype.

• It has a single column, and the type of that column is a built-in It has a single column, and the type of that column is a built-in type or an object type. type or an object type.

• If the column in a nested table is an object type, the table can also If the column in a nested table is an object type, the table can also be viewed as a multi-column table, with a column for each be viewed as a multi-column table, with a column for each attribute of the object type. attribute of the object type.

• ExampleExample: in the purchase order example, the following statement : in the purchase order example, the following statement declares the table type used for the nested tables of line items:declares the table type used for the nested tables of line items:

 

CREATE TYPE lineitem_table AS TABLE OF lineitem;

Nested Tables (1)Nested Tables (1)

Page 33: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• A table type definition does not allocate space. It defines a type, A table type definition does not allocate space. It defines a type, which you can use as:which you can use as:

– The datatype of a column of a relational tableThe datatype of a column of a relational table

– An object type attributeAn object type attribute

– A PL/SQL variable, parameter, or function return typeA PL/SQL variable, parameter, or function return type

Nested Tables (2)Nested Tables (2)

Page 34: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

CREATE TYPE person AS OBJECT (name VARCHAR2(30),phone VARCHAR2(20) ); CREATE TYPE lineitem AS OBJECT (item_name VARCHAR2(30),quantity NUMBER, unit_price NUMBER(12,2) );  CREATE TYPE lineitem_table AS TABLE OF lineitem;  CREATE TYPE purchase_order AS OBJECT ( id NUMBER, contact person, lineitems lineitem_table, MEMBER FUNCTION get_value RETURN NUMBER );

ExampleExample

Page 35: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• Object types: PERSON, LINEITEM, LINEITEM_TABLE, and Object types: PERSON, LINEITEM, LINEITEM_TABLE, and PURCHASE_ ORDER. PURCHASE_ ORDER.

• NAME, PHONE, ITEM_NAME, and so on are attributes of their NAME, PHONE, ITEM_NAME, and so on are attributes of their respective object types. respective object types.

• The attribute CONTACT is an object, and the attribute LINEITEMS is The attribute CONTACT is an object, and the attribute LINEITEMS is a nested table. a nested table.

• LINEITEM_TABLE is a table in which each row is an object of type LINEITEM_TABLE is a table in which each row is an object of type LINEITEM.LINEITEM.

• Simplified example. It does not show how to specify the body of the Simplified example. It does not show how to specify the body of the method GET_VALUE, which you do with the CREATE OR REPLACE method GET_VALUE, which you do with the CREATE OR REPLACE TYPE BODY statement.TYPE BODY statement.

Example: notesExample: notes

Page 36: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• Defining an object type does not allocate any storage. You can use Defining an object type does not allocate any storage. You can use LINEITEM, PERSON, or PURCHASE_ORDER in SQL statements in LINEITEM, PERSON, or PURCHASE_ORDER in SQL statements in most of the same places you can use types like NUMBER or VARCHAR2.most of the same places you can use types like NUMBER or VARCHAR2.

• For example, you might define a relational table to keep track of your For example, you might define a relational table to keep track of your contacts:contacts:

CREATE TABLE contacts (contact persondate DATE );

• The CONTACTS table is a relational table with an object type defining The CONTACTS table is a relational table with an object type defining one of its columns. Objects that occupy columns of relational tables are one of its columns. Objects that occupy columns of relational tables are called called columncolumn objectsobjects..

Example: notesExample: notes

Page 37: Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.

• PURCHASE_ORDER has a method named GET_VALUEPURCHASE_ORDER has a method named GET_VALUE

• EachEach purchase order object has its own GET_VALUE methodpurchase order object has its own GET_VALUE method

• For example, if X_OBJ andFor example, if X_OBJ and Y_OBJ are PL/SQL variables that hold purchase order Y_OBJ are PL/SQL variables that hold purchase order objects and W_NUM and Z_NUM are variables that hold numbers, the following two objects and W_NUM and Z_NUM are variables that hold numbers, the following two statements can retrievestatements can retrieve values from the objects:values from the objects:

w_num = x_obj.get_value();w_num = x_obj.get_value();z_num = y_obj.get_value();z_num = y_obj.get_value();

• Both objects, being of the same type, have the GET_VALUE methodBoth objects, being of the same type, have the GET_VALUE method • The methodThe method call does not need any parameters, because it operates on its own set of call does not need any parameters, because it operates on its own set of

data: thedata: the attributes of X_OBJ and Y_OBJattributes of X_OBJ and Y_OBJ

• In this In this selfish styleselfish style of method invocation, the method of method invocation, the method uses the appropriate set of data uses the appropriate set of data depending upon the object for which it is called.depending upon the object for which it is called.

Example: notesExample: notes