1 10/17/2017
Outline
Background
ORDBMS features, advantages,
disadvantages
Stonebrakers View
ADTs & Encapsulation
Inheritance
Objects, OIDs, Rererence types
Structured data types
Database Design for an ORDBMS
ORDBMS Implementation challenges
Comparing OODBMS & ORDBMS
Background
Relational DBMSs are not good enough for
todays advanced database applications
RDBMS support a small, fixed collection of data
types (e.g. int, date, string), which are adequate
for traditional application domains such as
administrative data processing.
In many application domains, more complex
kind of data must be handled. Such complex data
has to be stored in OS files or specialized data
structures, rather than in a DBMS. Examples of
domains with complex data are CAD/CAM,
multimedia repositories, document mgmt, etc
To support such applications, a DBMS must
support complex data types.
Background
Need for Complex Data Types
E.g. addresses, an entire address can be viewed
as an atomic data item of string type, but this will
hide details such as street, city, zip code which
can be of interest to queries. If they are
represented by breaking into parts then queries
will be complicated. Better alternative is to allow
structured data type, allow a type address with
subparts city, street etc.
Multivalued attributes: solution to it is creating a
new relation but it is expensive
Advanced Database Applications (such
applications involve complex data
type usage)
2nd Generation
Relational Database
3rd Generation
Object Oriented Database
Object-Relational Database
Evolution of Database Management Systems
12 10/17/2017
ORDBMSs - Features
It support object oriented capabilities to relational DBMS
& also preserves full relational capabilities
OO features being added include:
User-extensible type
Abstract data types (ADTs)
Encapsulation
Inheritance
Method overloading and binding
Dynamic binding of methods
Object identity
ORDBMSs
CREATE TABLE
COMPANY_INFO( COMPANY_NAME
VARCHAR2(50), ADDRESS
COMPANY_ADDRESS_TY);
Structured Data Types
SQL:1999 introduced two type constructors that allow
to define new types with internal structure.Types
defined using type constructors are called structured
types.So,field values need not be atomic only.
32
OBJECTS, OBJECT IDENTITY, AND REFERENCE
TYPES
Large objects in SQL: SQL:1999 includes a
new data type called LARGE OBJECT or LOB,
with two variants called BLOB (binary large object)
and CLOB (character large object).This standardizes
the large object support found in many current
relational DBMSs
LOBs cannot be included in primary keys, GROUP
BY, or ORDER BY clauses.They can be compared
using equality, inequality, and substring operations
A LOB has a locator that is essentially a
unique id and allows LOBs to be manipulated
without extensive copying.
LOBs are typically stored separately from the data
records in whose fields they appear. IBM DB2,
Informix, Microsoft SQL Server, Oracle 8, and
Sybase ASE all support LOB
33
URLs and OIDs in SQL:1999
OIDs uniquely identify a single object over all
time, but the web resource pointed at by an URL
can change over time
OIDs are simply identifiers and carry no physical
information about the objects they identify-this makes
it possible to change the storage location of an object
without modifying pointers to the object. But URLs
include network addresses and often file-system names
also, meaning that if the resource identified by the URL
has to move to another file or network address, then all
links to that resource are either incorrect or require a
change
OIDs are autonomatically generated by the DBMS for
each object, whereas URLs are user-generated. URLs,
they often embed semantic information into the URL
via machine, directory; this can become confusing if
the object's properties change over time
For URLs,deletion can be dangerous, leads to 404
page not found". For OIDs,SQL:1999 allows to say
REFERENCES ARE CHECKED as part of the SCOPE
clause.This is a direct extension of reverential
integrity.
REFERENCES: How it is
Implemented
This data type acts as a pointer to an object. A REF
can also be used in a manner similar to a foreign key
in a RDBMS.A is used primarily to store an object
identifier.
REF establish relationship between two object
tables, much the same way a primary/foreign key
relationship in relational tables. Relational tables have
difficulty ,if more than one table is needed in a
primary/foreign key relationship related to a single
tabl .e.g an address table that stores addresses from
several entities. The use of REF eliminates this
problem, as unscoped REF can refer to any accessible
object table
A SCOPE clause in a definition forces a set of REFs
for a given column to be confined to a single object
table
There can be only one REF clause for a given REF
column.REF SCOPE can be set at either the column or
table .
REFERENCES: How it is
Implemented
REF values can be stored with
or without a ROWID.Storing a REF with a ROWID
speeds dereferencing operations, but takes more
space. If WITH ROWID is not specified with REF
clause, the default is to not store ROWIDs with the
REF values
SCOPE clauses prevent dangling references, as
they will not allow REF values unless the
corresponding entries in the SCOPE table is
present
They are physically separate from the objects that
refer to them
REF are essentially pointers to row objects
Column object would be a varying array; it is an
object that is treated as a column in a table
A call to a REF returns the OID of the object
instance.An OID is a 128-byte base-64 number, which
isnt very useful except as a handle to the object
instance.
REFERENCES: How it is
Implemented
To get the value stored in the instance that is
referred to by a REF,the DEREF routine is used. DEREF
returns the values in the object instance referenced by
a specific REF value
REF types have values that are unique
identifiers or OIDs.SQL:1999 requires that a given REF
type must be associated with a specific table.e.g. A
column theater is declared as of type
REF(theater_t).The SCOPE clause specifies that items
in this column are references to rows in the Theater
table
An item of reference type REF(basetype) is not the
same as the basetype item to which it points.To access
the referenced basetype item, a built-in deref() method
is provided along with the REF type constructor.e.g.
given a table of Nowshowing table, one can access the
name field of the referenced theater_t object with the
syntax Nowshowing.deref(theater).name
Since references to tuple types are common,
some systems provide a java-style arrow operator
Using the arrow notation, the name of the referenced
theater can be accessed with the equivalent syntax
Nowshowing.theater->name
1. For creating a TYPE
object: CREATE TYPE
DEPT_TY AS OBJECT(
DNAME VARCHAR2(100), ADDRESS VARCHAR2(200));
2. For creating a TABLE object using the
aboveTYPE object: CREATE TABLE DEPT OF
DEPT_TY;
3. For creating a TABLE object that references to the TYPE
object and also specifies the SCOPE:
CREATE TABLE EMP(ENAME VARCHAR2(100), ENUMBER NUMBER,
EDEPT REF DEPT_TY SCOPE IS DEPT);
4. For inserting values in the DEPT table:
INSERT INTO DEPT VALUES(DEPT_TY('Sales', '501 Baliga
Street')); INSERT INTO DEPT VALUES(DEPT_TY('Accounts',
'84 Darya Ganj'));
5. For viewing the
DEPT table: SELECT * FROM
DEPT;
6. For viewing the REF from the
DEPT table: SELECT REF(D) FROM
DEPT D; 00000280kdfkdlldlld
6. For inserting a row into the EMP table for an employee in
Sales department: INSERT INTO EMP SELECT 'Nirmal
Pandey', 1, REF(D) FROM DEPT D
WHERE D.DNAME = 'Sales';
8. For viewing records from the
EMP table: SELECT * FROM
EMP;
9. For viewing the ENAME, ENUMBER and the details of EDEPT
column of the EMP table using the DEREF routine:
SELECT ENAME, ENUMBER, DEREF (EDEPT) FROM EMP;
Output:
Ename Enumber Deref(edept)(Dname,address)
40
Database design for an ORDBMS: Object
Identity