Professional Documents
Culture Documents
www.elsevier.com/locate/infsof
Abstract
In this paper, we present methods of translating transactions from object-oriented database (OODB) to relational database (RDB). The
process involves schema mapping in data de®nition language and transaction translation in data manipulation language. They include scheme
de®nition, data query and transaction operation of insert, update, and deletion. We also discuss the object-oriented features in OODB
operations that are not supported by RDB, such as class hierarchy, class composition hierarchy, and set attribute, and provide a general
solution to realize those mechanisms by traditional relation operations. The result of the transaction translation can be applied into adding
object-oriented interface into relational database management system and to the interoperability between OODB and RDB. q 2002 Elsevier
Science B.V. All rights reserved.
Keywords: Object-oriented database; Relational database; Object-relational database; Multidatabase; Transaction translation; Interoperability
² OODB class: level such that each class is mapped to a relation scheme.
T oid: type of implied attribute having object identi®er The other is attribute level such that different type attributes
as its value. are treated differently. Implied OID is mapped to a key
T atomic: type of atomic attribute. attribute. Atomic attribute is mapped into an attribute with-
T class: type of aggregate attribute. out change. Composite attribute is mapped into a foreign
T set: type of set attribute. key attribute referencing to the key of the relation corre-
AC or ATC : an attribute of class C or a T type attribute of sponding to the attribute domain class. Set attribute is
class C. mapped into an atomic attribute plus an extra relation
NAME(AC): name of attribute AC. scheme which has two attributes. One is to set a link to
DOM(AC): class or type of attribute AC. the attribute corresponding to the set attribute. The other
ELEDOM
Aset C : class or type of set element. is to deal with set elements. Suppose we have SC
NAME(C): name of class C. {C1 ; ¼; C m }; SA {A1C ; ¼; AnC }; m $ 0 and n $ 0 in class
ATT(C): a set of attributes de®ned in class C. creation operation Co(C,SC,SA). The scheme mapping rS is
SUB(C): a set of subclasses of class C. expressed as
² OODB operation:
Co(C,SC,SA): create class C as a subclass of classes in rS Co C; {C 1 ; ¼; Cm }; A1C ; ¼; AnC
set SC with additional attributes in set SA.
Io(C,SV): create an object of class C with values in set
SV. ! Cr RC ; A1RC ; ¼; AkRC
So(C,QC,AC): select values, satisfying quali®cation QC,
of attribute AC of class C. and Cr RAiC ; A1RAi ; A2RAi uDOM AiC T set
Uo(C,QC,AC,vC): update values, satisfying quali®cation C C
QC, of attribute AC of class C with new value vC. and attribute mapping is
Do(C,QC): delete objects of class C, which satis®es
quali®cation QC. rS Aoid
C ! Akey
RC
rS Aatomic
C ! AR C
3. Transaction translation
rS Aset 1 2
C ! ARC 1 RAC ARA ; ARA
Transaction translation is to realize the functions and C C
case DOM
AiC T class : object with OID attribute assigned by system. The set values
AiRC Akey
R i
; of an attribute will be mapped into multiple tuples in an
DOM
A
C
case DOM
AiC T set : additional relation. If the set is empty, there is no tuple
AiRC Aset ; // A set is an atomic type attribute inserted to the relation.
de®ned by system //
NAME
RAiC NAME
C 1 NAME
AiC ; 3.2.1. Translation mapping
Suppose we have SV {v1C ; ¼; vnC } in operation Io(C,SV)
A1RAi AiRC ;
C which creates an object of class C with values v1C ; ¼; vnC :
if
ELEDOM
AiC T class Each value viC corresponds to one attribute AiC de®ned in the
A2RAi Akey
RELEDOM
Ai ; class C, 1 # i # n and n uATT
Cu: The value of a
else C C
composite attribute is an OID. Based on the scheme transla-
2 ele
AR A i A ; ==NAME
Aele tion, creation operation mapping is
NAME
AC and DOM
A ELEDOM
AiC
C i ele
} 1 n 1 n
} rC Io C; vC ; ¼; vC ! Ir RC ; oidRC ; vRC ; ¼; vRC
After the scheme translation, both the source scheme
and Ir RAiC ; oidRAi ; vjR i u DOM AiC T set
and target scheme are kept by system as metadata. The C
A
C
information about the relationship between superclass
and its subclasses, between composite class and its
and
1 # i # n and 1 # j # vic
component classes, between class and its attributes,
between class and its corresponding relations, and
between relation and its attributes are available for
transaction translations. 3.2.2. Translation algorithm
Based on the mapping rC, we have an algorithm for
3.1.3. Example scheme translation to produce a unique OID.
Below is an example of schema translation. Suppose we
have a series of class creation operations for the following creation_translation(C,v1c ; ¼; vnc ;rS)
class de®nitions: // input: Io(C,{v1c ; ¼; vnc }) and rS
// output:
Ir(RC,{oidRC ; viRC ; ¼; vnRC }) and
j
class S1(A1:integer) // Ir RAiC ; oidRAi ; vR i u DOM AiC T set and
C
A
C
class S2(A2:integer, A3:string, A4:¯oat) subclass of S1
1 # i # n and 1 # j # vic
class S3(A5:S2) subclass of S1 {
class S4(A6:set of (string), A7:integer) subclass of S3 RC Ã rS(C);
class S5(A8:S3, A9:S4) subclass of S1 oidRC oid_generator
;
for (i 1; i # ATT
C; i i 1 1)
According to the scheme translation algorithm, the crea- {
tion operations create the relation schemes as follows: case AiC T atomic :
viRC viC ;
relation scheme S1(S1_OID:atomic type, A1:integer)
case AiC T class :
relation scheme S2(S2_OID:atomic type, A1:integer,
viRC viC ; // the value of a composite type attri-
A2:integer, A3:string, A4:¯oat)
bute is an oid of an object //
relation scheme S3(S3_OID:atomic type, A1:integer,
case AiC T set :
S2_OID:atomic type)
if
uviC u 0
relation scheme S4(S4_OID:atomic type, A1:integer,
viRC null;
S2_OID:atomic type, A6_SET:atomic type, A7:integer)
else
relation scheme S4A6(A6_SET:atomic type, A6:string)
{
relation scheme S5(S5_OID:atomic type, A1:integer,
viRC oid_generator
;
S3_OID:atomic type, S4_OID:aomic type)
RAiC Ã rS
AiC ;
oidRAi viRC ;
C
3.2. Creation translation for ( j 1; j # uviC u; j j 1 1) // viC should be a
set of values //
Creation translation maps an insertion operation of a class vjR i vijC ; // vijC is the jth element of set viC //
object to the insertion operation of a relation tuple with }
A
C
for every edge to the vertex do Continuing to the above example by using breadth-®rst
{ search to traverse the graph of Fig. 3, we get
replace the annotated attribute of the edge
QR {
S5:A1 , 10;
S5:S3_OID S3:S3_OID;
by join predicates (i.e. the attribute, corre-
sponding to the annotated attribute, of the
S5:S4_OID S4:S4_OID;
relation of the tail vertex is set to be equal
to the key attribute of the relation of the
S3:S2_OID S2:S2_OID;
head vertex);
}
S4:S2_OID S2:S2_OID;
}
else
S4:A6_SET S4A6:A6_SET;
S2:A2 . 0;
{
if the attribute in the terminal vertex is not a
S2:A3 `abc';
S2:A4 5:5;
`bcd' in S4A6}
set type
replace the attribute in the terminal vertex
3.3.5. Quali®cation translation algorithm
by corresponding relation attribute;
As mentioned before, the algorithm of quali®cation trans-
else
lation is
{
insert a new vertex between the terminal quali®cation_translation(QC,rS);
vertex and its adjacent from vertex; // input: QC and rS
set the new inserted vertex as the relation // output: QR
mapped from the set attribute; {
annotate the edge to the new inserted vertex OQG_organizing(QC,rS); // organizing GC from QC //
with a join predicate (i.e. the ®rst attribute OQG_to_RQG_translating(GC,rS); // translating GC to
of the relation of the head vertex is equal to GR //
the attribute, corresponding to the set attri- RQ_producing(GR,rS); // producing QR from GR //
bute, in the relation of the tail vertex); }
modify the terminal vertex predicate accord-
ing to the semantic of set operator;
} 3.4. Query translation
}
} Query So(C,QC,A) in OODB is divided into three parts.
} Range part C indicates the class that the selected objects
belong. Quali®cation part QC indicates predicates that the
selected objects must satisfy. Target part A indicates the
3.3.4. Producing RDB quali®cation attributes that the result values come from. But compared
By traversing graph GR, we can produce the set of the with RDB counterparts, each part in OODB query has new
predicates which constitute the corresponding relation mechanisms. Range part indicates one class or a set of
quali®cation. The translation algorithm is classes in a class hierarchy. Quali®cation part may contain
new kinds of operands and operators. Target part can be an
RQ_producing(GR,rS) attribute of the given class in range part or one attribute of a
// input: GR and rS class that is derived by navigating through the class compo-
// output: QR sition hierarchy rooted at the given class.
{ For query translation, we map object query operation to
QR B; relation query operations and select the tuples correspond-
traverse graph GR and for each vertex do ing to the objects quali®ed by QC from the appropriate rela-
{ tions mapped from indicated class or the class with all of its
if the vertex is a terminal vertex subclasses. The selected tuples are ®ltered by relational
QR QR < {the predicate of the vertex}; quali®cation QR, mapped from QC, and also from path
else expressions in target part of object query operation.
{
QR QR < {the predicates of the edges to the 3.4.1. Translation mapping
vertex}; The general form of target part A is expressed as
} AC0 :AC1 :AC2 :¼:ACn ; where n $ 0; C C0 when n 0;
} and (DOM
ACi Ci11 ; 0 # i # n 2 1) when n . 0. The
} values of ACn of the selected objects are the result of
48 J. Fong / Information and Software Technology 44 (2002) 41±51
2 1 n
!
n[ o
* rQUA
QC < RCi :ARCi RCi11 :Akey
RCi11 ; DOM
ACn ± T set
i0
QR !
2 1 n
n[ o n o
rQUA
QC < RCi :ARCi RCi11 :Akey
RCi11 < RCn :ARCn RACn :A1RA DOM
ACn T set
Cn
i0
*A DOM
ACn ± T set
RCn ; Sr
S4;
S5:A1 , 10 ^
S5:S3_OID
AR
A2RA DOM
ACn T set
Cn
S3:S3_OID ^
S5:S4_OID
S4:S4_OID ^ S3:S2_OID
* U
R ; Q ; A ; v ; DOM
AC ± T set
r C R RC RC
rU
Uo
C; QC ; AC ; vC ! n n o o
Dr
RAC ; Q 0R ; Ur
RC ; QR ; ARC ; vRC and Ir RAC ; oidRA ; vjRA uI # j # uvC u ; DOM
AC T set
C C
Uo(C all,QC,AC,vC) {Uo(C i,QC i,AC i,vC i)u(C i [ {C} < deletion_translation1(C,QC,rS)
SUB(C)) and
0 # i # uSUB
Cu and
C 0 // input: Do(C,QC) and rS
i
C and
ACi [ ATT
C }; and // output: {Dr
RAiC ; QiR u
DOM
AiC T set and
1 # i #
update_translation2(C all,QC,AC,vC,rS) uATT
Cu};
{ // {Ur
RCj ; QjR ; ARCj ; nulluDOM
ACj
for (every C i [ {C} < SUB(C)) do C} and Dr
RC ; QR
update_translation1(C i,QC,AC,vC,rS); {
} QR qualification_translation
QC ; rS ;
for (i 1; i # uATT
Cu; i i 1 1)
if
DOM
AiC T set
3.5.2. Example {
According to the translation algorithm, we translate RAiC Ã rS
AiC ;
50 J. Fong / Information and Software Technology 44 (2002) 41±51
delete from STUDENT The author thanks Zeng Xiaoqin of the City University of
where STUDENT.name ªJohn Smithº; Hong Kong for his assistance in drafting the paper.
7. update STUDENT
set STUDENT.dept_oid null;
where STUDENT.student_oid in
References
(select STUDENT.student_oid
from STUDENT, DEPT [1] A.P. Sheth, J.A. Larson, Federated database systems for managing
where DEPT.dept_name ªmathematicsº distributed, heterogeneous, and autonomous databases, ACM
and DEPT.dept_oid STUDENT.dept_oid); Comput. Surv. 22 (3) (1990) 183±236.
8. delete from DEPT [2] W. Meng, et al., Construction of a relational front-end for object-
9. where DEPT.dept_name ªMathematicsº; oriented database systems, Proc. IEEE Data Engng (1993) 476±
483.
[3] D. Keim, H.P. Kriegel, A. Miethsam, Object-oriented querying of
existing relational database, Proceedings of the Fourth International
5. Conclusion Conference on Database and Expert System Applications (DEXA
'93), September 1993.
[4] C. Yu, et al., Translation of object-oriented queries to relational
Transaction translation between OODB and RDB plays
queries, IEEE Proceedings of the 11th International Conference On
an important role in the multidatabase interoperability. In Data Engineering, 1995, pp. 90±97.
this paper, we show methods of mappings and algorithms [5] Xiuzhen Zhang, Joseph Fong, Translating update operations from
which translate transactions of OODB to transactions of relational to object-oriented databases, J. Info. Soft. Technol. 42 (3)
RDB. The discussion aims at the functions in OODB (2000).
operations which are not supported by RDB operations [6] Joseph Fong, Paul Chitson, Query translation from SQL to OQL for
database reengineering, Int. J. Info. Technol. 3 (1) (1997) 83±101.
without translation. In transactions translation, the class [7] E. Bertino, M. Negri, G. Pelagatti, L. Sbattella, Object_oriented query
hierarchy semantics in OODB are mapped to relational languages: the notion and the issues, IEEE Trans. Knowledge Data
union operation. The semantics of navigation through Engng 4 (3) (1992) 223±237.
composition hierarchy are mapped to relational join [8] V.M. Markowitz, A. Shoshani, Object queries over relational data-
operation, and set operations are mapped to relevant rela- base: language, implementation, and applications, Proc. IEEE Data
Engng (1993) 71±80.
tion operations. To map multiple path expressions origi-
[9] Q. Xiaolei, R. Louiqa, Query interoperation among object-oriented
nated from one class in a quali®cation of an object and relational databases, IEEE Proceedings of the 11th International
operation, we use a graph to model and process the Conference On Data Engineering, 1995, pp. 271±278.
mapping. For future research of this paper, we will [10] M. Blaha, W. Premerlani, H. Shen, Converting OO models into
include the PSM [14] routine (cover both user-de®ned RDBMS schema, IEEE Soft. 1 (1) (1994) 28±39.
functions and procedures) in the transaction translation [11] J.G. Hughes, Object-Oriented Databases, Prentice-Hall, Englewood
Cliffs, NJ, 1991.
processing. [12] D. Maier, The Theory of Relational Database, Computer Science
Press, 1983.
[13] UniSQL/X User's Manual, UniSQL, Inc.
Acknowledgement [14] C.J. Date, Hugh Darwen, A Guide to the SQL Standard, Addison-
Wesley Publishing, 1993.
This research project is supported by a strategic research
grant 7001240 of City University of Hong Kong.