Object-Relational Features in Oracle Database!: View of The Database World!
Object-Relational Features in Oracle Database!: View of The Database World!
Object-Relational Features in
Oracle Database!
1
2
8/11/13
3
4
8/11/13
5
6
8/11/13
7
8
8/11/13
9
10
8/11/13
INSERT INTO person_table!
VALUES (person_type (Scott Tiger, 321-123-1234));
p = person_type(Scott Tiger, 321-123-1234);! SELECT VALUE(p) FROM person_table p WHERE p.name = Scott! Tiger;!
--Built-in constructor method, person_type(att1, att2) is invoked! -- Single-column table: each row is a person_type object!
--to create a new object instance of person_type, specify values! -- Perform object-oriented operations!
--for its attributes(name, phone), and set the object into a!
--variable p.!
D Comparing to a relational table!
CREATE TABLE person_table (!
INSERT INTO contacts! name VARCHAR2(30),
VALUES! (person_type(Scott Tiger, 321-123-1234), phone! VARCHAR2(20) );!
10 Feb 2004));! INSERT INTO person_table!
--Same! thing occurs here.! VALUES (Tommy Trojan, 213-740-1212);!
SELECT name, phone FROM person_table;!
-- Multi-column table: treat person_table as a relational! table!
11
12
8/11/13
15
16
8/11/13
D Single inheritance: When a subclass inherits D Overriding: To redefine an inherited property by defining
from no more than one superclass (note: forming the same property differently at the subclass level.!
class hierarchies is permissible here).! D Overloading: A general case of overriding where the same
D Multiple inheritance: When a subclass inherits method name is reused within a class definition (overriding)
from more than one superclass (note: a or across class definitions. !Hence, a single message can
mechanism is required to resolve conflicts when perform different functions depending on which object
the Superclasses have the same attributes and/or receiving it and, if appropriate what parameters are passed
methods). !Due to its complexity, not all OO to the method (e.g., print method for different objects).!
languages and database systems support this D Polymorphism: Having many forms in Greek, is a
concept.! The image general case of overloading.!
cannot be
D Example! --To permit subtype, object type should be! defined!as NOT FINAL.!
Person! --By default, an object type is FINAL!
19
20
8/11/13
21
22
8/11/13
23
24
8/11/13
Oracle Object Types and References! Oracle Object Types and Reference!
D REF Datatype! D Querying to a REF!
u !REF is a logical "pointer" to a row object.!
D For an object type t, REF t is the reference to the values of type t.!
SELECT *!
CREATE TABLE! contacts (! FROM contacts;!
contact REF person_type,
c_date! DATE );! CONTACT !C_DATE!
--contact attribute is a reference to the values of person_type.! --------------------------------------------------------------
0000220208D28EEDE1C5736BD7E034080020B68B64 !12-JAN-04!
CREATE TABLE person_table OF person_type;!
--create object table consisting of person_type objects!
SELECT c.contact.name, c.c_date
INSERT INTO person_table VALUES (Tommy Trojan, 213-740-1212); FROM contacts c;!
25
26
8/11/13
References!
27