ORACLE 9I DATABASE TYPES
An upgraded Oracle 9i consists of three different types :
i) Relational : The traditional ORACLE relational database
(RDBMS).
ii) Object-relational : The traditional ORACLE relational database,
extended to include object-oriented concepts and structures such
as abstract datatype, nested tables and varying arrays.
iii) Object-oriented : An object-oriented database whose design is
based only on Object-Oriented Analysis and Design principles.
Oracle provides full support to all the three types. Whatever
method we choose, we must be familiar with the functions and
features of the core ORACLE relational database. Even if OO
capabilities are used, the functions and datatypes available in Oracle
and its programming languages i.e. SQL and PL/SQL should be
known.
USES OF OBECTS
Objects reduce complexity of representing complex data and its
relations. Objects also help to simplify the way to interact the data.
Benefits of using OO features are :
• Object reuse : We can reuse previously written code modules by
writing OO code. If we create OO database objects, chances of
reuse of these database objects will be more.
• Standards adherence : If database objects are built by using
standards, then the chances they will be reused increase
exponentially. We have to create de Facto Standard for
applications or tables if we use the same set of database objects
for multiple applications or tables.
For e.g., if for addresses of students we create a standard
datatype, then all the addresses in the database will use the same
internal format.
The main things we consider while using objects are the time
taken to learn how to use OO features and the added complexity of
the system. The little time required to develop and use condensed
datatype is a good measure for the time required for learning Oracle’s
OO features.
Object is made up of combination of data and the methods which
we use to interact with data.
For example :
If clerk want to make list of addresses of students then there is a
standard for the structure of an address. First there is student’s name,
then street name, city name, state name and then code number.
When new admissions are taken, then the student is added in the list
using same procedure.
Add Student( ) For adding a student to the list.
Update Student( ) For updating student’s information.
Remove Student( ) For deleting a student from the list in case of
cancelling admission.
Method not only manipulate data but can give any information or
report on data. See given example.
If any company want to give new skills training to its workers.
Then information about age of a worker is valuable to see that how
many workers can learn new skills considering their ages.
Here, if workers birthdates are stored then method for calculating
age can be used and we have a report on worker’s current age.
TYPES OF OBJECTS
Oracle have different types of objects. Here some major types are
described.
Abstract Datatype :
Abstract datatype consists of one or more subtypes. Rather than
being constrained to the standard oracle datatype of NUMBER, DATA
and Varchar2, the abstract datatype can describe data more
accurately.
Example :
CREATE TYPE PERSON_TV AS OBJECT (NAME VARCHAR2
(20), ADDRESS ADDRESS_TY);
Output :
Type Created
While using the abstract datatype the benefits for objects like
reuse and standard adherence are realised. A standard for the
representation of abstract data elements, for e.g. address, companies
etc. is created when an abstract datatype is created. When the same
abstract datatype is used in multiple places, the same logical data is
represented in the same manner in each place.
When the same abstract datatype is used in multiple places, the
same logical data is represented in the same manner in each place.
Reuse of the abstract datatype shows the enforcement of
standard representation for the data to which it is bound.
We can use abstract datatype to create an object table. In an
object table, the columns of the table map to the columns of an
abstract datatype.
Nested Tables :
A nested tables means ‘table within a table’. A nested table is a ‘a
collection of rows, represented as a column within the main table’. For
each record within the main table, the nested table may contain
multiple rows. In one sense, it’s a way of storing a one-to-many
relationship within one table.
Consider a table containing information about departments, in
which each department may have many projects in progress at one
time. in a strictly relational model, two separate tables would be
created :
i) DEPARTMETN
ii) PROJECT
Nested tables allow us to store the information about projects
within the DEPARTMENT table. The project table records can be
accessed directly via the DEPARTMENT table, without the need to
perform a join.
The ability to select data without traversing joins makes data
access easier. Even if methods for accessing nested data are not
defined, Department and Project data have clearly been associated.
In a strictly relational model, the association between the
DEPARTMENT and PROJECT tables would be accomplished by a
foreign key.
Varying Arrays :
A varying array is a ‘set of objects, each with the same datatype’.
The size of the array is limited when it is created.
Varying arrays are also known as VARRAYS. They allows storing
repeating attributes in tables.
For example : suppose there is a PROJECT table, and projects
having workers assigned to them.
A project may have many workers, and a worker may work on
multiple projects. In a strictly relational implementation, a PROJECT
table, a WORKER table, and an intersection table
PROJECT_WORKER would be created which store the relationships
between them.
Varying arrays can be used to store the worker names in the
PROJECT table. If projects are limited to fifteen workers or fewer, a
varying array with a limit of fifteen entries can be created. The
datatype for the varying arrays will be whatever datatype is
appropriate for the worker name values.
Then varying array can be populated, so that for each project the
names of all of the project’s workers can be selected without querying
the WORKER table.
Note : When a table is created with a varying array, the array is a
nested table with a limited set of rows.
Large Objects :
A large object or LOB is capable of storing large volumes of data.
The different LOB datatypes available are BLOB, CLOB, NCLOB, and
BFILE.
The BLOB datatype is used for binary data and can extend to
4GB in length.
The CLOB datatype stores character data and can store data
up to 4GB in length.
The NCLOB datatype is used to store CLOB data for multibyte
character sets.
The data for BLOB, CLOB and NCLOB datatype is stored
inside the database. So, there can be a single row in the
database that is over 4GB in length.
One of the LOB datatype, BFILE, is a pointer to an external file.
The files referenced by BFILEs exist at operating system level. The
database only maintains a pointer to the file. The size of the external
file is limited only by the operating system. The data is stored outside
the database, so ORACLE does not maintain concurrency or integrity
of the data.
We can use multiple LOBs per table. For example, consider a
table with a CLOB column and two BLOB columns. This is an
improvement over the LONG datatype, as there can be one LONG per
table, ORACLE provides a number of functions and procedures, which
can be used to manipulate and select LOB data.
References :
Varying arrays and Nested tables are embedded objects. They
are physically embedded within another object. They of object called
as referenced objects, are physically separate from the objects that
refer to them. References (also known as REFs) are essentially
pointers to row objects. A row object is different from a column
object. An example of a column object would be a varying array. It is
an object that is treated as a column in a table. On the other hand, a
row object always represents a row.
References are typically among the last OO features
implemented while migrating a relational database to an objectrelational or pure OO one.
Object Views :
Object views allow adding OO concepts on top of existing
relational table. For example, an abstract datatype can be created
based on an existing table definition. Thus, object views give the
benefits of relational table storage and OO structures. Object views
allow the development of OO features within a relational database, a
kind of bridge between the relational and OO worlds.
FEATURES OF OBJECTS
An object has a name, a standard representation and a standard
collection of operations that affect it. The operations that affect an
object are called ‘methods’. So, an abstract datatype has a name, a
standard representation and defined methods for accessing data
Comments
Post a Comment