Object Orientation in Oracle April 23 rd, 2007 Kangpyo Lee Jaeseok Myung
2 Contents Part 1: OO in Oracle Database 10g About Oracle Object-Relational Databases OO in Oracle Database 10g Part 2: OO in Oracle E-Business Suite 11i Background Oracle’s Solution Oracle E-Business Suite 11i References & Appendix
3 About Oracle (1/4) Oracle Corporation One of the world’s greatest IT company, offering database and middleware S/W, and applications S/W Has been an unchallenged leader in database market Headquartered in Redwood Shores, California Web Site:
4 About Oracle (2/4) History Oracle was founded by Lawrence J. Ellison in 1977 He realized there was tremendous business potential in RDB model The timeline highlights 30 years of Oracle innovation Oracle has refined its technology by early adopting pervasive ideas of those days
5 About Oracle (3/4) Market Share
6 About Oracle (4/4) Oracle Products Oracle Database Oracle Applications Oracle Fusion Middleware Oracle Enterprise Manager
7 Contents Part 1: OO in Oracle Database 10g About Oracle Object-Relational Databases OO in Oracle Database 10g Part 2: OO in Oracle E-Business Suite 11i Background Oracle’s Solution Oracle E-Business Suite 11i References & Appendix
8 Object-Relational Database (1/4) Object-Relational Data Model Extends the relational data model to support Complex data types Type inheritance Object identity Relational Database Object-Relational Database Object- Oriented Concepts
9 Pure Object-Oriented Databases Around 1985 Information is represented in the form of objects ODBMS Object DataBase Management System Database capabilities are combined with OO programming capabilities Object-Relational Database (2/4) DB OOPL DB Extending an existing DB language with OO capabilities Extending an existing OOPL with DB capabilities
10 Object-Relational Database (3/4) RDB vs. OODB !!! RDBOODB Data ModelEntity-relationship modelObject-Oriented Model Killer Domain Business areas (commercial databases) Application areas (engineering & spatial databases, telecommunications) & scientific areas (high energy physics & molecular biology) Query Language SQL (Structured Query Language) OQL (Object Query Language) Access to Data Slower (Joins among tables are often needed) Faster (An object can be retrieved by following pointers)
11 Object-Relational Database (4/4) Why Did OODB Lose the Game? Benchmarks have shown that ODBMS can be clearly superior for certain kinds of tasks, but… Eventually absorbed into RDB ⇒ ORDB 1 Failure to make great impact on mainstream commercial data processing 2 For general- purpose queries, pointer-based techniques will tend to be slower and more difficult to formulate 3 Lack of interoperability with a great # of tools/features 4 Intentional resistance from major RDB vendors
12 Contents Part 1: OO in Oracle Database 10g About Oracle Object-Relational Databases OO in Oracle Database 10g Part 2: OO in Oracle E-Business Suite 11i Background Oracle’s Solution Oracle E-Business Suite 11i References & Appendix
13 Oracle Object Types User-defined types Make it possible to model the real-world entities as objects in the database Attributes + methods OO in Oracle Database 10g Oracle Objects (1/3)
14 OO in Oracle Database 10g Oracle Objects (2/3) Example for Creating an Object CREATE TYPE person_typ AS OBJECT ( idno NUMBER, first_name VARCHAR2(20), last_name VARCHAR2(25), VARCHAR2(25), phone VARCHAR2(20), MEMBER FUNCTION get_idno RETURN NUMBER, MEMBER PROCEDURE display_details ( SELF IN OUT NOCOPY person_typ )); attributes methods
15 OO in Oracle Database 10g Oracle Objects (3/3) Oracle Object Methods Functions or procedures that you can declare in an object type definition to implement behavior Written in PL/SQLPL/SQL CREATE TYPE BODY person_typ AS MEMBER FUNCTION get_idno RETURN NUMBER IS BEGIN RETURN idno; END; MEMBER PROCEDURE display_details ( SELF IN OUT NOCOPY person_typ ) IS BEGIN DBMS_OUTPUT.PUT_LINE(TO_CHAR(idno) || ' ' || first_name || ' ' || last_name); DBMS_OUTPUT.PUT_LINE( || ' ' || phone); END; Member function Member procedure
16 OO in Oracle Database 10g Object Tables Oracle Object Tables A special kind of table where each row represents an object CREATE TABLE person_obj_table OF person_typ; INSERT INTO person_obj_table VALUES ( person_typ(101, 'John', 'Smith', ' ') ); SELECT VALUE(p) FROM person_obj_table p WHERE p.last_name = 'Smith'; DECLARE person person_typ; BEGIN SELECT VALUE(p) INTO person FROM person_obj_table p WHERE p.idno = 101; person.display_details(); END; Returns object instances corresponding to rows of the table
17 OO in Oracle Database 10g Inheritance in Object Types (1/3) Type Inheritance The new subtype inherits all the attributes and methods that its parent type has Supertypes & subtypes No multiple inheritance is allowed Determines whether subtypes can be derived from that type by FINAL NOT FINAL CREATE TYPE student_typ UNDER person_typ ( dept_id NUMBER, major VARCHAR2(30), NOT FINAL;
18 Method Overloading & Overriding Adding new methods Adding new methods that have the same names as methods it inherits (overloading) Redefining methods it inherits (overriding) Example for Creating a Subtype with an Overloading Method CREATE TYPE MyType_typ AS OBJECT (..., MEMBER PROCEDURE draw(x NUMBER),...) NOT FINAL; CREATE TYPE MySubType_typ UNDER MyType_typ (..., MEMBER PROCEDURE draw(x VARCHAR2(20)),...); OO in Oracle Database 10g Inheritance in Object Types (2/3)
19 OO in Oracle Database 10g Inheritance in Object Types (3/3) Example for Creating a Subtype with an Overriding Method CREATE TYPE student_typ UNDER person_typ ( dept_id NUMBER, major VARCHAR2(30), OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2) NOT FINAL; CREATE TYPE BODY student_typ AS OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2 IS BEGIN RETURN person_typ.show_super ( SELF ) || ' -- Major: ' || major ; END; END; Displays the newly added attribute major
20 Oracle REF Oracle built-in datatype A logical pointer to a row object constructed from the OID Provides an easy mechanism for navigating between objects Uses the dot (.) notation to follow the pointers Scoped REF Constrains a REF to contain only references to a specified object table OO in Oracle Database 10g Object Identity (1/2)
21 Example for Using a scoped REF to an Object CREATE TABLE contacts_ref ( contact_ref REF person_typ SCOPE IS person_obj_table, contact_date DATE ); INSERT INTO contacts_ref SELECT REF(p), '26 Jun 2007' FROM person_obj_table p WHERE p.idno = 101; OO in Oracle Database 10g Object Identity (2/2) contact_refcontact_date ▪ ’26 Jun 2007’ ▪ ’23 Feb 2007’ person_obj_1 person_obj_2 person_obj_table contacts_ref
22 Oracle Collection Datatypes Varrays Nested tables Varrays An ordered set of elements, all of the same datatype Each element has an index CREATE TYPE phone_varray_typ AS VARRAY(5) OF phone_typ; CREATE TABLE dept_phone_list ( dept_no NUMBER(5), phone_list phone_varray_typ); INSERT INTO dept_phone_list VALUES (100, phone_varray_typ( phone_typ ('01', '650', ' '), phone_typ ('01', '650', ' '))); OO in Oracle Database 10g Support for Collection Datatypes (1/3) phone_ object_1 phone_ object_2 …...… phone_list
23 Nested Tables An unordered set of elements, all of the same datatype No maximum & no order A nested table has a single column Elements of a nested table are actually stored in a separate table CREATE TYPE people_typ AS TABLE OF person_typ; CREATE TABLE people_tab ( group_no NUMBER, people_column people_typ ) NESTED TABLE people_column STORE AS people_column_nt; INSERT INTO people_tab VALUES ( 100, people_typ( person_typ(1, 'John Smith', ' '), person_typ(2, 'Diane Smith', NULL))); OO in Oracle Database 10g Support for Collection Datatypes (2/3)
24 Multilevel Collection Types Nested table of nested table type Nested table of varray type Varray of nested table type Varray of varray type Nested table or varray of a user-defined type that has an attribute that is a nested table or varray type OO in Oracle Database 10g Support for Collection Datatypes (3/3)
25 OO in Oracle Database 10g Object Functions & Operators Functions & Operators Useful with Objects CAST CURSOR DEREF IS OF type REF SYS_TYPEID TABLE() TREAT VALUE SELECT VALUE(p) FROM person_obj_table p WHERE VALUE(p) IS OF (student_typ); SELECT TREAT(VALUE(p) AS student_typ) FROM person_obj_table p; SELECT name, SYS_TYPEID(VALUE(p)) typeid FROM person_obj_table p;
26 OO in Oracle Database 10g Object Views (1/2) Oracle Object View A virtual object table Each row in the view is an object Useful in prototyping or transitioning to OO applications The data in the view can be taken from relational tables and accessed Can be used like table views Presents only the data that you want users to see CREATE TABLE emp_table ( empnum NUMBER (5), ename VARCHAR2 (20), salary NUMBER (9,2), job VARCHAR2 (20)); CREATE TYPE employee_t AS OBJECT ( empno NUMBER (5), ename VARCHAR2 (20), salary NUMBER (9,2), job VARCHAR2 (20)); CREATE VIEW emp_view OF employee_t WITH OBJECT IDENTIFIER (empno) AS SELECT e.empnum, e.ename, e.salary, e.job FROM emp_table e WHERE job = 'Developer'; A pointer (REF) to the objects in the view
27 OO in Oracle Database 10g Object Views (2/2) Object View Hierarchies A set of object views each of which is based on a different type in a type hierarchy Superviews, subviews CREATE VIEW Person_v OF person_typ WITH OBJECT OID(ssn) AS SELECT ssn, name, address FROM AllPersons WHERE typeid = 1; CREATE VIEW Student_v OF student_typ UNDER Person_v AS SELECT ssn, name, address, deptid, major FROM AllPersons WHERE typeid = 2; CREATE VIEW Employee_v OF employee_typ UNDER Person_v AS SELECT ssn, name, address, empid, mgr FROM AllPersons WHERE typeid = 3;
28 OO in Oracle Database 10g Support for XML (1/3) Oracle XML DB Treats XML as a native data type in the database Applications can use standard SQL and XML operators to generate complex XML documents from SQL queries to store XML documents Benefits
29 OO in Oracle Database 10g Support for XML (2/3)
30 OO in Oracle Database 10g Support for XML (3/3) Oracle XML Developer’s Kits (XDK) Contain the basic building blocks for reading, manipulating, transforming, & viewing XML documents XML Parsers XSLT Processor XML Schema Processor XML Class Generator XML Java Beans XML SQL Utility XSQL Servlet
31 Summary of Pt. 1 Oracle Database 10g Fully supports the basic OO concepts such as Object Types Object Tables Inheritance in Object Types Object Identity Support for Collection Datatypes Object Views Object Functions & Operators Support for XML
32 Contents Part 1: OO in Oracle Database 10g About Oracle Object-Relational Databases OO in Oracle Database 10g Part 2: OO in Oracle E-Business Suite 11i Background Oracle’s Solution Oracle E-Business Suite 11i References & Appendix
33 Background What Is the Business on IT’s Viewpoint? 33 Lowers TCO (Total Cost of Ownership) Availability Integration Maintenance Performance Extensibility
34 Background Problems over the Business (1/3) Fragmented Systems and Data Consistency Each data source value may different Accuracy Can’t make a good decision Performance Need additional transactions Integration Difficult combine other systems 34 CRM Finances Supply Chain Warehouse
35 Background Problems over the Business (2/3) Architecture Problems Based on Multiple Vendors 35 Applications Server Database Server Business Intelligence Portal Business Intelligence ETL
36 Background Problems over the Business (3/3) Various Business Solutions Separated applications take long time to be an expert Separated applications cause many administration costs 36 Financials Human Resources CRM SCM
37 Contents Part 1: OO in Oracle Database 10g About Oracle Object-Relational Databases OO in Oracle Database 10g Part 2: OO in Oracle E-Business Suite 11i Background Oracle’s Solution Oracle E-Business Suite 11i References & Appendix
38 Oracle’s Solution The Power of One (1/3) One Family of Applications 38 Plan Order HR Finance Source Sell Service Projects Procure Market Fulfill Maintain Manufacture DevelopDevelop
39 Oracle’s Solution The Power of One (2/3) One Enterprise Data Model Global Single Data Model (GSD) 39 Plan Order HR Finance Source Sell Service Projects Procure Market Fulfill Maintain Manufacture Develop Customers,Products, & Everything Else!
40 Oracle’s Solution The Power of One (3/3) One Underlying Technology Platform 40 User Interface Application Logic Database Logic Client TierApplication TierDatabase Tier
41 Oracle Fusion Next-Generation Enterprise Applications Oracle procured many application sets by greedy M&A Integrate those applications, is called “Fusion” 41
42 Contents Part 1: OO in Oracle Database 10g About Oracle Object-Relational Databases OO in Oracle Database 10g Part 2: OO in Oracle E-Business Suite 11i Background Oracle’s Solution Oracle E-Business Suite 11i References & Appendix
43 Oracle E-Business Suite 11i The True Character of EBS The Portal System for Enterprise which contains many applications 43
44 Oracle E-Business Suite 11i The Technology Stack of EBS Oracle AS and Database have technical components EBS has a framework to manipulate other layers EBS applications are developed by such framework 44
45 Oracle E-Business Suite 11i How Can Make a View of EBS App? All pages of EBS application consist of components A Hierarchy of Regions and Components
46 Oracle E-Business Suite 11i MVC Architecture A component-based design with clean interfaces among model, view, and controller objects The model encapsulates underlying data and business logic of the application The view formats and presents data from a model to the user The controller responds to user actions and directs application flow Controller Model View
47 Oracle E-Business Suite 11i The View – Using Java Objects Table Bean Header Bean Submit button Bean Each UI widget corresponds to one or more Java objects (beans) The Java objects are used to create HTML at runtime.
48 Oracle E-Business Suite 11i The View – UIX (User Interface XML) <div xmlns=" xmlns:ui=" Hello world. First list element Second list element UIX ButtonBean button = new ButtonBean(); button.setText("Push me"); button.setDestination(" div.addIndexedChild(button);
49 Oracle E-Business Suite 11i The View – How It Works Page Hierarchy Metadata OA Framework RuntimeOA Framework Design time UIX Bean Hierarchy UIX Renderers JSP/HTML Browser..XML Cache
50 Oracle E-Business Suite 11i The Controller – User Interaction Apply User takes an action Browser sends request to Controller Metadata Workflow Model Controller 1. Controller delegates data processing to Model 2. Determines next page 3. Invokes View to present the next page to user View
51 Oracle E-Business Suite 11i The Model – Data Processing DatabaseTables,ViewsPL/SQL Entity Objects (Simple DAO) View Objects (Using SQL DAO) Application Module (EJB Session Bean) Application Module DML Validations Defaulting UIX Bean Hierarchy View Side BC4J OBJECTS.XML
52 Oracle E-Business Suite 11i Applied Case – LG Philips LCD (1/2) Oracle Financials Oracle Treasury Oracle Financial Analyzer Oracle Purchasing Oracle Manufacturing Oracle Order Management Oracle Self-Service Human Resources Oracle Training Administration Oracle Time and Labor Oracle Payroll Oracle Advanced Benefits 52CRM SCM FCM HRM (LCD Market Leader) US $25.9 Million (2000 ~ )
53 Oracle E-Business Suite 11i Applied Case – LG Philips LCD (2/2) Inventory Turnover(in days) Summary of Benefits by Business Area Over a five-year period(2001 ~ 2005), LG Philips LCD realizes US $104.7 million in gross benefits from the ERP and HR projects
54 Summary of Pt. 2 The Oracle E-Business Suite 11i Provides many business applications Lowers total cost of ownership The Oracle solution is the power of one One family applications One enterprise data model One underlying technology platform
55 Contents Part 1: OO in Oracle Database 10g About Oracle Object-Relational Databases OO in Oracle Database 10g Part 2: OO in Oracle E-Business Suite 11i Background Oracle’s Solution Oracle E-Business Suite 11i References & Appendix
56 References Oracle® Database Application Developer's Guide - Object-Relational Features 10g Release 2 (10.2) Part Number B , east.oracle.com/docs/cd/B19306_01/appdev.102/b14260/toc.htm Silberschatz, Korth, Sudarshan, "Database System Concepts" 5th edition, McGraw-Hill, 2006, Part 3, Chapter 9, p S. Khoshafian, R. Abnous. "Object Orientation", 2nd edition, John Wiley & Sons, 1995, Chapter 8, p Oracle Applications Concepts, Oracle E-Business Suite Online Documentation Library Release 12+, December 2006, Part No. B , Nadia Bendjou, Why Architecture Matters, Oracle OpenWorld 2005, x.html Lisa Parekh, Oracle E-Business Suite Technology Updates, Oracle OpenWorld 2006, Wikipedia,
57 Appendix (1/2) PL/SQL Procedural Language/Structured Query Language Oracle’s proprietary server-based procedural extension to the SQL database language Consists of blocks DECLARE -- Declaration block (optional) BEGIN -- Program proper EXCEPTION -- Exception-handling (optional) END Back!
58 Oracle Applications Framework 100% Java & XML, middle-tier application framework Use XML files to define pages and data Use PL/SQL to generate the HTML page JDeveloper extension Deploying applications to application server Demo et_viewlet_swf.html et_viewlet_swf.html Reference Appendix (2/2)