object orientation in oracle april 23 rd, 2007 kangpyo lee jaeseok myung

58
Object Orientation in Oracle April 23 rd , 2007 Kangpyo Lee Jaeseok Myung

Upload: oscar-hunter

Post on 27-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Object Orientation in Oracle

April 23rd, 2007

Kangpyo LeeJaeseok 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: http://www.oracle.com

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

OracleDatabase

OracleApplications

OracleFusion

Middleware

OracleEnterpriseManager

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

RelationalDatabase

Object-RelationalDatabase

Object-OrientedConcepts

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

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 !!!

RDB OODB

Data Model

Entity-relationship model

Object-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), email 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/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(email || ' ' || phone); END;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', '[email protected]', '1-800-555-1212') );

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_ref contact_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', '5061111'), phone_typ ('01', '650', '5062525')));

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', '1-800-555-1212'), 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

3232

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

333333

Background

What Is the Business on IT’s Viewpoint?

33

Lowers TCO(Total Cost of Ownership)

Availability

Integration

Maintenance

Performance

Extensibility

343434

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

CRMCRM

FinancesFinances

Supply ChainSupply Chain

WarehouseWarehouse

353535

Background

Problems over the Business (2/3)

Architecture Problems Based on Multiple Vendors

35

Applications Server Database ServerBusiness Intelligence

Portal

Business Intelligence

ETL

363636

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 HumanResources

CRMSCM

373737

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

383838

Oracle’s Solution

The Power of One (1/3)

One Family of Applications

38

PlanPlan

OrderOrder

HRHR

FinanceFinance

SourceSource

SellSell

ServiceService

ProjectsProjects

ProcureProcure

MarketMarket

FulfillFulfill

MaintainMaintain

ManufactureManufacture

DevelopDevelopDevelopDevelop

393939

Oracle’s Solution

The Power of One (2/3)

One Enterprise Data Model Global Single Data Model (GSD)

39

PlanPlan

OrderOrder

HRHR

FinanceFinance

SourceSource

SellSell

ServiceService

ProjectsProjects

ProcureProcure

MarketMarket

FulfillFulfill

MaintainMaintain

ManufactureManufacture

DevelopDevelop

Customers,Customers,Products,Products,

& Everything& EverythingElse!Else!

404040

Oracle’s Solution

The Power of One (3/3)

One Underlying Technology Platform

40

User InterfaceUser Interface Application LogicApplication Logic Database LogicDatabase Logic

Client Tier Application Tier Database Tier

414141

Oracle Fusion

Next-Generation Enterprise Applications

Oracle procured many application sets by greedy M&A

Integrate those applications, is called “Fusion”

41

424242

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

434343

Oracle E-Business Suite 11i

The True Character of EBS

The Portal System for Enterprise which contains many applications

43

444444

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

4545

Oracle E-Business Suite 11i

How Can Make a View of EBS App?

All pages of EBS application consist of components

A Hie

rarc

hy o

f

A Hie

rarc

hy o

f

Regio

ns

Regio

ns

and

Compo

nent

s

and

Compo

nent

s

4646

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 amodel to the user

The controller responds touser actions and directs

application flowController

Model View

4747

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 HTMLat runtime.

4848

Oracle E-Business Suite 11i

The View – UIX (User Interface XML)

<div xmlns="http://www.w3.org/TR/REC-html40" xmlns:ui="http://xmlns.oracle.com/uix/ui"> Hello world. <ul> <li>First list element</li> <li>Second list element</li> </ul> <ui:button text="Push me" destination="http://www.example.org"/></div>

UIX

ButtonBean button = new ButtonBean();button.setText("Push me");button.setDestination("http://www.example.org");div.addIndexedChild(button);

4949

Oracle E-Business Suite 11i

The View – How It Works

Page Hierarchy

Metadata

OA Framework RuntimeOA Framework Design time

UIX Bean Hierarchy

UIXRenderers

JSP/HTML

Browser

..XML

Cache

5050

Oracle E-Business Suite 11i

The Controller – User Interaction

ApplyApply

User takes an action Browsersendsrequest toController

MetadataWorkflow

Model

Controller

1. Controller delegates data processing to Model

2. Determines next page3. Invokes View to present the

next page to userView

5151

Oracle E-Business Suite 11i

The Model – Data Processing

DatabaseDatabaseTables,ViewsTables,Views

PL/SQLPL/SQL

Entity Objects(Simple DAO)

View Objects(Using SQL DAO)

Application Module(EJB Session Bean)

Application Module

DMLValidationsDefaulting

UIX Bean Hierarchy

View Side

View Side

BC4J OBJECTS

.XML.XML

525252

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

52

CRMCRM

SCMSCM

FCMFCM

HRMHRM

(LCD Market Leader)

US $25.9 Million

(2000 ~ )

535353

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

5454

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 B14260-01, http://download-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.361-394

S. Khoshafian, R. Abnous. "Object Orientation", 2nd edition, John Wiley & Sons, 1995, Chapter 8, p.320-379

Oracle Applications Concepts, Oracle E-Business Suite Online Documentation Library Release 12+, December 2006, Part No. B31450-01, http://www.oracle.com/technology/documentation/applications.html

Nadia Bendjou, Why Architecture Matters, Oracle OpenWorld 2005, http://www.oracle.com/technology/products/applications/architecture/index.html

Lisa Parekh, Oracle E-Business Suite Technology Updates, Oracle OpenWorld 2006, http://www.oracle.com/technology/products/applications/ebs/index.html

Wikipedia, http://en.wikipedia.org/

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 blocksDECLARE

-- Declaration block (optional)BEGIN -- Program properEXCEPTION -- Exception-handling (optional)END

Back!

5858

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 http://www.oracle.com/technology/products/jdev/viewlets/1013/ADF_O

verview_Viewlet_viewlet_swf.html

Reference http://download-west.oracle.com/otn_hosted_doc/jdeveloper/1013/adfd

evguide.pdf

Appendix (2/2)