Object Identity and Reference Types in SQL
Object Identity and Reference Types in SQL
2
Object Identity
• One goal of an Object Data Management System
(ODMS) is to maintain direct correspondence
between real-world and database objects without
losing the object’s Integrity and identity.
• TheODMS gives a unique, system generated
identifier called Object Identifier (OID) to each
independent object stored in the database.
3
Object Identity cont.…
• Properties of OID:
Its is not visible to the external user.
It is Immutable
I.e. the OID value of a particular object should not
change.
And even if an object is removed from the database
the OID should be preserved.
The OID should not be dependent on any attribute
of the object.
4
A little back in history
• Some early ODMSs have used the physical
address as the OID to increase the efficiency of
object retrieval.
If the physical address of the object changes, an indirect pointer
can be placed at the former address, which gives the new
physical location of the object.
• Some other early OO data models require that
everything (basic values, such as an integer, string,
or Boolean) to be represented as an object.
5
A little back in history cont….
• This
is not very practical, since it leads to the
generation of too many OIDs.
• As a solution for this problem, latest OODSs
represent objects with an immutable OID,
whereas a literal value has no OID and its value
just stands for itself.
6
Object Identifiers Using Reference Types
in SQL
• Unique system-generated object identifiers can be
created via the reference type in the latest version of SQL.
For example:
CREATE TYPE PERSON_TYPE AS (
NAME VARCHAR (35),
SEX CHAR,
BIRTH_DATE DATE,
ADDR USA_ADDR_TYPE
7
Object Identifiers Using Reference Types
in SQL cont….
• The “REF IS SYSTEM GENERATED”
statement indicates that whenever a new
PERSON_TYPE object is created, the system
will assign it a unique system-generated
identifier.
• ButIt is also possible not to have a system-
generated object identifier and use the traditional
keys of the basic relational model if desired.
8
Object Identifiers Using Reference Types
in SQL cont….
• Theuser can specify that system-generated object
identifiers for the individual rows by using the
syntax:
REF IS <OID_ATTRIBUTE> <VALUE_GENERATION_METHOD> ;
9
Object Identifiers Using Reference Types
in SQL cont….
• The options for <VALUE_GENERATION_METHOD>
are:
SYSTEM GENERATED: in which case the system
will automatically generate a unique identifier for
each tuple.
DERIVED: in which , the traditional method of
using the user-provided primary key value to
identify tuples is applied.
10