Set as Homepage   Add to Favourites   Recommend   Contact



Menu

∙ Home
∙ Index (All Topics)
∙ About Me
∙ About This Blog
∙ Favourite Links
∙ RSS Feed

Categories

∙ ASP & PHP (1)
∙ HTML, XML and CSS (2)
∙ C / C++ (5)
∙ Java, JSP and Servlet (0)
∙ SQL-Oracle-PL/SQL (28)
∙ Operating Systems (1)
∙ OFF-Topic (8)

Popular Topics (Top 10)

∙ Decode Function in Oracle SQL (72031)

∙ Derin anlamlı sözler - Bunlar da Türkçe olanlar :) (68579)

∙ Oracle performance analysis - Tracing and performance evaluation (53499)

∙ When a transaction begins? (45887)

∙ Differences between C and C++ (45018)

∙ Turkcell Staj Günlüğü - 1: Introduction to Oracle (40807)

∙ Implicit vs. Explicit cursors - Performance analysis (24314)

∙ Turkcell Staj Günlüğü - 9: "SQL, PL/SQL and Java" ve "Redo Internals" (22286)

∙ Finding and Removing Loop on a Singly-Linked List (21284)

∙ Turkcell Staj Günlüğü - 4: Transaction Management (20858)


Most Recent (Last 10)

∙ Matematik Asla Yalan Söylemez!

∙ Finding and Removing Loop on a Singly-Linked List

∙ Obfuscated C

∙ Is C a Vitamin? Yes, of course...

∙ Differences between C and C++

∙ Whence C? Why C? Whither C?

∙ Türkçe Karakterli Domain'lerin İç Yüzü

∙ Windows Source Codes

∙ Decode Function in Oracle SQL

∙ Hello World!


Recent Comments (Last 10)

∙ "tebrikler" By yasin on Turkcell Staj Günlüğü - 5: Startup, Shutdown

∙ "Gercekten Güzel Bir Çalışma" By Hüseyin Karabakla on Neden hazır blog'ları kullanmadım ki?

∙ "Konu paralelinde güzel bir özet ek okuma - " By TongucY on Oracle performance analysis - Tracing and performance evaluation

∙ "harika" By burak ozcan on Derin anlamlı sözler - Bunlar da Türkçe olanlar :)

∙ "Tebrikler" By Tarık Bayzın on Turkcell Staj Günlüğü - 1: Introduction to Oracle

∙ "Gayet Başarılı.." By Fahri ATES on Turkcell Staj Günlüğü - 1: Introduction to Oracle

∙ "Helal olsun" By ender onder on Turkcell Staj Günlüğü - 5: Startup, Shutdown

∙ "tebrikler.." By ender ondeer on Turkcell Staj Günlüğü - 4: Transaction Management

∙ "Adulation?" By fizikci on Matematik Asla Yalan Söylemez!

∙ "Rehberlik için çook teşekkürler" By Pınar Tanrıverdi on Kahin'e yolculuk nasıl başlamalı?


Archive (Last 12 Months)

∙ Feb, 2008 (4)
∙ Jan, 2008 (2)
∙ Dec, 2007 (1)
∙ Sep, 2007 (4)
∙ Aug, 2007 (9)
∙ Jul, 2007 (22)
∙ Jun, 2007 (3)
∙ Index (All Records)

Other Related Blogs

∙ Tom Kyte’s Blog
∙ Steven Feuerstein’s Blog
∙ Jonathan Lewis’s Blog
∙ H.Tonguç Yılmaz Oracle Blog
∙ Mennan Tekbir's Blog
∙ Hakkı Oktay’s Blog
∙ Osman Çam’s Blog

Stats

Total Topics
Total Topic Views
Total Comments
Unique Visitors
Total Visitors
: 45
: 917531
: 44

About this blog…
About this blog…
About Me
About Me
Favourite Links
Favourite Links
Neden hazır blog'ları kullanmadım ki?
Neden hazır blog'ları kullanmadım ki?
CSS is more powerful than you imagine
CSS is more powerful than you imagine
Turkcell Staj Günlüğü - 1: Introduction to Oracle
Turkcell Staj Günlüğü - 1: Introduction to Oracle
Turkcell Staj Günlüğü - 2: Data Blocks, Extends and Segments
Turkcell Staj Günlüğü - 2: Data Blocks, Extends and Segments
Kahin'e yolculuk nasıl başlamalı?
Kahin'e yolculuk nasıl başlamalı?
Turkcell Staj Günlüğü - 3: Tablespaces, Datafiles and Control Files
Turkcell Staj Günlüğü - 3: Tablespaces, Datafiles and Control Files
Turkcell Staj Günlüğü - 4: Transaction Management
Turkcell Staj Günlüğü - 4: Transaction Management
Image formats - Which to use when
Image formats - Which to use when
Turkcell Staj Günlüğü - 5: Startup, Shutdown
Turkcell Staj Günlüğü - 5: Startup, Shutdown
Turkcell Staj Günlüğü - 6: Oracle Architecture
Turkcell Staj Günlüğü - 6: Oracle Architecture
ASP - Locales and Codepages
ASP - Locales and Codepages
Oracle performance analysis - Tracing and performance evaluation
Oracle performance analysis - Tracing and performance evaluation
Oracle performance analysis - Autotrace workshop
Oracle performance analysis - Autotrace workshop
Oracle performance analysis - Runstats workshop
Oracle performance analysis - Runstats workshop
Oracle performance analysis - Tkprof workshop
Oracle performance analysis - Tkprof workshop
Some favourite quotes
Some favourite quotes
Derin anlamlı sözler - Bunlar da Türkçe olanlar :)
Derin anlamlı sözler - Bunlar da Türkçe olanlar :)
Turkcell Staj Günlüğü - 7: Concurrency and Consistency
Turkcell Staj Günlüğü - 7: Concurrency and Consistency
"Kurtuluş"un hikayesi
"Kurtuluş"un hikayesi
Turkcell Staj Günlüğü - 8: Statement Processing and CBO
Turkcell Staj Günlüğü - 8: Statement Processing and CBO
When a transaction begins?
When a transaction begins?
Implicit vs. Explicit cursors - Performance analysis
Implicit vs. Explicit cursors - Performance analysis
Turkcell Staj Günlüğü - 9: "SQL, PL/SQL and Java" ve "Redo Internals"
Turkcell Staj Günlüğü - 9: "SQL, PL/SQL and Java" ve "Redo Internals"
Affect of gathering table stats to decision of CBO
Affect of gathering table stats to decision of CBO
Bind is bad :) - An interesting case of bind variables fails
Bind is bad :) - An interesting case of bind variables fails
When the explanation doesn't sound quite right...
When the explanation doesn't sound quite right...
Turkcell Staj Günlüğü - 10: Import, Export ve SQL Loader
Turkcell Staj Günlüğü - 10: Import, Export ve SQL Loader
Turkcell Staj Günlüğü - 11: Autonomous Transactions ve Dynamic SQL
Turkcell Staj Günlüğü - 11: Autonomous Transactions ve Dynamic SQL
Difference between db block gets and consistent gets
Difference between db block gets and consistent gets
Object-Oriented Features of Oracle - Part 1: Native Datatypes vs. Object Datatypes
Object-Oriented Features of Oracle - Part 1: Native Datatypes vs. Object Datatypes
Object-Oriented Features of Oracle - Part 2: Object Types and Collection types
Object-Oriented Features of Oracle - Part 2: Object Types and Collection types
Object-Oriented Features of Oracle - Part 3: Object Tables, Object Views and REFs
Object-Oriented Features of Oracle - Part 3: Object Tables, Object Views and REFs
Examining show_space
Examining show_space
Turkcell Staj Günlüğü - 12: Partitioning
Turkcell Staj Günlüğü - 12: Partitioning
Hello World!
Hello World!
Decode Demo #1
Decode Demo #1
Decode Demo #2
Decode Demo #2
Decode Demo #3
Decode Demo #3
Decode Demo #4
Decode Demo #4
Decode Function in Oracle SQL
Decode Function in Oracle SQL
Windows Source Codes
Windows Source Codes
Türkçe Karakterli Domain'lerin İç Yüzü
Türkçe Karakterli Domain'lerin İç Yüzü
Whence C? Why C? Whither C?
Whence C? Why C? Whither C?
Differences between C and C++
Differences between C and C++
Is C a Vitamin? Yes, of course...
Is C a Vitamin? Yes, of course...
Obfuscated C
Obfuscated C
Finding and Removing Loop on a Singly-Linked List
Finding and Removing Loop on a Singly-Linked List
Matematik Asla Yalan Söylemez!
Matematik Asla Yalan Söylemez!
eXTReMe Tracker
Object-Oriented Features of Oracle - Part 2: Object Types and Collection types
Category: SQL-Oracle-PL/SQL
Date: 13.08.2007 08:29:59


OBJECT TYPES

An object type differs from native SQL datatypes in that it is user-defined, and it specifies both the underlying persistent data (attributes) and the related behaviors (methods). Object types are abstractions of the real-world entities, for example, purchase orders. Object types store structured business data in its natural form and allow applications to retrieve it that way.

Object types and related object-oriented features, such as variable-length arrays and nested tables, provide higher-level ways to organize and access data in the database. Underneath the object layer, data is still stored in columns and tables, but you can work with the data in terms of the real-world entities--customers and purchase orders, for example--that make the data meaningful. Instead of thinking in terms of columns and tables when you query the database, you can simply select a customer.

Object types are abstractions of the real-world entities—for example, purchase orders—that application programs deal with. An object type is a schema object with three kinds of components:

• A name, which serves to identify the object type uniquely within that schema
• Attributes, which model the structure and state of the real-world entity. Attributes are built-in types or other user-defined types.
• Methods, which are functions or procedures written in PL/SQL or Java and stored in the database, or written in a language such as C and stored externally. Methods implement operations the application can perform on the real-world entity.

An object type is a template. A structured data unit that matches the template is called an object. An example object types and object instances:



Object Attributes and Methods

Attributes hold the data about an object's features of interest. For example, a student object type might have name, major, and graduation date attributes. An attribute has a declared datatype which can in turn be another object type. Taken together, the attributes of an object instance contain that object's data.

Methods are procedures or functions provided to enable applications to perform useful operations on the attributes of the object type. Methods are an optional element of an object type. They define the behavior of objects of that type and determine what (if anything) that type of object can do.



Types of Methods

Methods of an object type model the behavior of objects. The methods of an object type broadly fall into these categories:

• A Member method is a function or a procedure that always has an implicit SELF parameter as its first parameter, whose type is the containing object type.
• A Static method is a function or a procedure that does not have an implicit SELF parameter. Such methods can be invoked by qualifying the method with the type name, as in TYPE_NAME.METHOD. Static methods are useful for specifying user-defined constructors or cast methods.
Comparison methods are used for comparing instances of objects.

Oracle supports the choice of implementing type methods in PL/SQL, Java, and C. Every object type also has one implicitly defined method that is not tied to specific objects, the object type's constructor method.

Object Type Constructor Methods

Every object type has a system-defined constructor method; that is, a method that makes a new object according to the object type's specification. The name of the constructor method is the name of the object type. Its parameters have the names and types of the object type's attributes. The constructor method is a function. It returns the new object as its value. You can also define your own constructor functions to use in place of the constructor functions that the system implicitly defines for every object type.

Comparison Methods

Methods play a role in comparing objects. Oracle has facilities for comparing two data items of a given built-in type (for example, two numbers), and determining whether one is greater than, equal to, or less than the other. Oracle cannot, however, compare two items of an arbitrary user-defined type without further guidance from the definer. Oracle provides two ways to define an order relationship among objects of a given object type: map methods and order methods.

Map methods use Oracle's ability to compare built-in types. Suppose that you have defined an object type called rectangle, with attributes height and width. You can define a map method area that returns a number, namely the product of the rectangle's height and width attributes. Oracle can then compare two rectangles by comparing their areas.

Order methods are more general. An order method uses its own internal logic to compare two objects of a given object type. It returns a value that encodes the order relationship. For example, it could return -1 if the first is smaller, 0 if they are equal, and 1 if the first is larger.

COLLECTION TYPES

Each collection type describes a data unit made up of an indefinite number of elements, all of the same datatype.

For modeling multi-valued attributes and many to many relationships, Oracle supports two collection datatypes: varrays and nested tables. Collection types can be used anywhere other datatypes can be used. You can have object attributes of a collection type in addition to columns of a collection type. For example, you might give a purchase order object type a nested table attribute to hold the collection of line items for a given purchase order. You use the CREATE TYPE statement to define collection types.

VARRAYs

An array is an ordered set of data elements. All elements of a given array are of the same datatype. Each element has an index, which is a number corresponding to the element's position in the array.

The number of elements in an array is the size of the array. Oracle allows arrays to be of variable size, which is why they are called VARRAYs. You must specify a maximum size when you declare the array type.

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

• The datatype of a column of a relational table
• An object type attribute
• A PL/SQL variable, parameter, or function return type.

A VARRAY is normally stored in line; that is, in the same tablespace as the other data in its row. If it is sufficiently large, however, Oracle stores it as a BLOB.

Nested Tables

A nested table is an unordered set of data elements, all of the same datatype. It has a single column, and the type of that column is a built-in type or an object type. If an object type, the table can also be viewed as a multicolumn table, with a column for each attribute of the object type. If compatibility is set to Oracle9i or higher, nested tables can contain other nested tables.

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

• The datatype of a column of a relational table
• An object type attribute
• A PL/SQL variable, parameter, or function return type

When a table type appears as the type of a column in a relational table or as an attribute of the underlying object type of an object table, Oracle stores all of the nested table data in a single table, which it associates with the enclosing relational or object table.

A convenient way to access the elements of a nested table individually is to use a nested cursor.

Increasing the Size and Precision of VARRAYs and Nested Tables

When the element type of a VARRAY type is a variable character or RAW type or a numeric type, you can increase the size of the variable character or RAW type or increase the precision of the numeric type. A new type version is generated for the VARRAY type. The same changes can be applied to nested table types.

Options like INVALIDATE and CASCADE are provided to either invalidate all dependent objects or propagate the change to its type and table dependents.

Increasing VARRAY Limit Size

The ALTER TYPE ... MODIFY LIMIT syntax allows increasing the number of elements of a VARRAY type. If the number of elements of the VARRAY type is increased, a new type version is generated for the VARRAY type and this is maintained as part of the history of the type changes.

Options like INVALIDATE and CASCADE are provided to either invalidate all dependent objects or propagate the change to its type and table dependents.

Overview of Type Inheritance

An object type can be created as a subtype of an existing object type. A single inheritance model is supported: the subtype can be derived from only one parent type. A type inherits all the attributes and methods of its direct supertype. It can add new attributes and methods, and it can override any of the inherited methods.

Furthermore, a subtype can itself be refined by defining another subtype under it, thus building up type hierarchies.

Example picture illustrates two subtypes, Student_t and Employee_t, created under Person_t.





Related Topics
Links & References

Comments

No comments posted yet.



© Copyright. All rights reserved. Designed by Bilal Hatipoğlu. RSS Feed  Valid W3C XHTML 1.0 Document  Valid W3C CSS Document