Documente Academic
Documente Profesional
Documente Cultură
Outline
Why Object database management systems (ODBMSs)? ODBMS and RDBMS and ORDBMS Oracle Database Object Relational
Why ODBMS?
The need for storing and manipulating complex data is increasing. We can not use relational databases to store this kind of data. The complex data types appear in several applications:
CAD/CAM Geometric modeling Geographical Information Systems Knowledge-based systems / through frames Web applications that need to store, index, search and manipulate diverse objects.
The impedance mismatch becomes apparent when trying to map these OO language properties to a RDBMS.
Object Types
Object Types
Given a LineItem_objtyp object instance, the price of the item is easily accessed with the following:
<instance_variable>.DEREF(stock_ref).price
Varray
Nested tables.
CREATE OR REPLACE TYPE Customer_objtyp AS OBJECT ( CustNo NUMBER, CustName VARCHAR2(200), Address_obj Address_objtyp, PhoneList_var PhoneList_vartyp ) NOT FINAL;
Member Methods
CREATE OR REPLACE FUNCTION formatAsXML (customer_id NUMBER)
Constructor Methods
CREATE OR REPLACE TYPE Customer_objtyp AS OBJECT ( ... some code snipped ... CONSTRUCTOR FUNCTION customer_objtyp(id IN NUMBER) RETURN SELF AS RESULT, ) NOT FINAL;
Using Constructor
DECLARE newCustomer customer_objtyp := NULL; BEGIN newCustomer := customer_objtyp (42, Adams, Douglas, Address_objtyp(123 Handy Road, Dandyville, CA, 94999), phonelist_vartyp(+1-650-555-1212, +61-8-9555-1212) ); END;
Comparison Methods
CREATE OR REPLACE TYPE Customer_objtyp AS OBJECT ( ORDER MEMBER FUNCTION compareCustOrders(x IN Customer_objtyp) RETURN INTEGER ... some code snipped ... ) NOT FINAL; CREATE OR REPLACE TYPE BODY customer_objtyp AS ORDER MEMBER FUNCTION compareCustOrders(x IN Customer_objtyp) RETURN INTEGER IS BEGIN RETURN SELF.CustNo - x.CustNo; END compareCustOrders; ... some code snipped ... END;
Inheritance
Conclusion
Further reading
[1] Object-Oriented Oracle , J.W.Rahayu, IRM Press, 2005 [2] Professional Oracle Programming, Rick Greenwald, Wrox, 2005 (Chapter 21) Using Oracle Object Types with Java ([2], page 501 - 520)
Exercise