scieee Science in your language
[en] (orig)

Implementing Associations among Classes in an Environment of Active Databases

Abstract

The association is a native concept from relational databases, one that has been adapted to object oriented (OO) modelling. It is an interesting operator used to describe links among objects of a system, commonly included in the most popular diagram-based OO methodologies. However, those methodologies sometimes present a lack of formality that may undermine its use. In this paper we formalize the semantics of associations. Firstly, we will describe an OO model based on different kinds of constraints. Some of them will be especially useful for describing the semantics of associations. Finally, we will present some remarks about implementation by means of triggers, a new feature incorporated in databases to specify an inner active behavior.

Read accessible full text

Implementing Associations among Classes in an Environment of Active Databases

Author: Torres Valderrama, Jesús; Martín Díaz, Octavio; Troyano Jiménez, José Antonio; Toro Bonilla, Miguel
Publisher: MAIK Nauka/lnterperiodica
Year: 2000
DOI: 10.1007/BF02759470
Source: https://idus.us.es/bitstreams/624e881f-8661-472c-93e9-dab68d53cf2b/download
P og amming and C mpu e So wa e, Vol. 26, No. 4, 2000, pp. 207-215.
O iginal English Tex Copy igh 9 2000 by To es, Ma in, l oyano, Time.
Implemen ing Associa ions among Classes in an En i onmen
o Ac i e Da abases
J. To es, O. Ma in, J. A. T oyano, and M. To o
Depa men o Languages and Compu e Sys ems, Uni e si y o Se ille (Spain)
e-mail: j o es( oc a io )( oyano )( m o o ) @ lsi. us.es
Recei ed Sep embe 23, 1999
Abs ac --The associa ion is a na i e concep om ela ional da abases, one ha has been adap ed o objec
o ien ed (OO) modelling. I is an in e es ing ope a o used o desc ibe links among objec s o a sys em, com-
monly included in he mos popula diag am-based OO me hodologies. Howe e , hose me hodologies some-
imes p esen a lack o o mali y ha may unde mine i s use. In his pape we o malize he seman ics o associa-
ions. Fi s ly, we will desc ibe an OO model based on di e en kinds o cons ain s. Some o hem will be espe-
cially use ul o desc ibing he seman ics o associa ions. Finally, we will p esen some ema ks abou
implemen a ion by means o igge s, a new ea u e inco po a ed in da abases o speci y an inne ac i e beha io .
I. INTRODUCTION
The associa ion is a na i e concep om ela ional
da abases ( ela ionships a e one o he pilla s o he
En i y-Rela ionship model). This ope a o has been
adap ed o OO modelling om he e y s a , by some
e y impo an me hods [14, 15]. Associa ion is,
oge he wi h inhe i ance, one o he mos popula
mechanisms in OO me hods based on diag ams. Asso-
cia ions among classes a e used o desc ibe links
be ween objec s o a sys em. Links may be c ea ed and
des oyed eely (al hough i is common o de ine se -
e al kinds o cons ain s o es ic
his eedom)
[16].
Howe e , he associa ion usually has many in e p e-
a ions (an e en mo e se ious p oblem a ises wi h he
agg ega ion) [2, 7, 12]. In his wo k, we p esen a o -
maliza ion o he p ope ies o associa ions by means o
a po en OO model. We do no in end he e o gi e a new
de ini ion o associa ion. Nei he do we in end o sub-
s i u e me hods based on diag ams. These a e e y use-
ul, because hey acili a e communica ion wi h use s
and he alida ion o models. Howe e , we belie e ha
i is necessa y o o malize hese me hods [4]. This way,
ou sole objec i e is o o malize one o he possible
in e p e a ions ha can be gi en [3, 14, 15].
This pape is o ganized as ollows. This in oduc-
ion cons i u es he i s sec ion. In he second sec ion
we will desc ibe an OO model based mainly on he de -
ini ion o cons ain s. In he hi d sec ion, bo h he
p ope ies and ea u es o associa ions will be
desc ibed. These p ope ies a e ep esen ed in ou
model acco ding o he s eps desc ibed in he ou h
sec ion. In he i h sec ion, we will desc ibe ou main
ideas in o de o hold he de ined seman ics in an en i-
onmen o ac i e da abases (like O acle 8). Finally, in
1 This a icle was submi ed by he au ho s in English.
he six h sec ion we will ex ac some conclusions o
ou wo k.
2. AN OBJECT ORIENTED MODEL
Objec s a e he undamen al elemen s in any OO
model. In ou model, an objec is cha ac e ized by a
g oup o a ibu es ha de ine i s s uc u e, a g oup o
e en s ha desc ibe i s beha io and some ansi ion
ules ha deno e he s a e changes o objec s. Objec s
sha ing cha ac e is ics a e g ouped in o classes.
Each a ibu e has a ype, de ined by an
abs ac
da a ype
(ADT) o a class o objec s. Values o he
a ibu es o an objec gi e in o ma ion abou i s s a e.
A ibu es can be cons an , a iable o de i ed.
Each objec has an
iden i ica ion
ha emains
unchanged du ing i s
li e.
Iden i ica ion should be
unique o each objec in he sys em. We conside ha
each objec has a p ede ined a ibu e, called
oid
(objec
iden i ie ) [ I I ].
Beha io aspec s o a class a e desc ibed by means
o e en s. An e en desc ibes some hing ha happens in
a momen o ime. Objec s in e ac wi h hei
en i on-
men
by means o e en s, which ake place h ough
communica ion channels.
These channels ini ially
coincide wi h he names o e en s. All objec s o he
same class sha e each communica ion channel de ined
in ha class. A name and se e al pa ame e s ha will be
communica ed h ough he e en s o his name de ine a
channel. E en s a e e y impo an because hey a e
synch oniza ion and communica ion elemen s. We
de ine in e ac ions be ween di e en objec s wi h hem.
Objec s can be c ea ed and des oyed dynamically.
All objec s composing a sys em a a gi en ins an in e -
ac concu en ly. Howe e , he indi idual beha io o
0361-7688/00/2604-0207525.00 9 2000 MAIK "Nauka/ln e pe iodica"
208 TORRES e al.
each objec is sequen ial. Remembe ha objec s in e -
ac synch onously by means o e en s.
O he impo an cha ac e is ics in ou model a e he
ollowing:
We use an ADT lib a y o desc ibe he s uc u e and
unc ionali y o objec s.
Speci ica ion is ca ied ou wi h di e en kinds o
cons ain s. These cons ain s allow us o de ine h ee
undamen al aspec s o objec s: (I) wha alues he
a ibu es o objec s can ake, (2) how objec s can
beha e in unc ion o hei s a e and (3) how objec s can
in e ac and wi h whom.
The model o in e ac ion be ween objec s is qui e
lexible. The classes o objec s ha should in e ac a e
de ined s a ically, while objec s o hese classes ha
eally in e ac a e chosen dynamically. All objec s ul-
illing hei cons ain s can pa icipa e.
Facili ies a e p o ided o manipula e he ex ension
o classes (g oup o objec s o a class ha exis a a ce -
ain ins an ). This allows us o impose cons ain s on
objec s on mul iple le els, as we will see in he nex
sec ion.
2. I. Kinds o Cons ain s
A la ge di e si y o cons ain s exis s in ou model
[17]. Acco ding o he scope whe e cons ain s a e
de ined, hey can be o wo kinds:
9 lndi Mual cons ain s. These cons ain s a e
de ined in he class empla e. They mus be ul illed
indi idually by all objec s belonging o ha class.
9 Collec i e cons ain s. Objec s o a
class,
consid-
e ed as a collec ion, mus sa is y hese cons ain s,
a he han indi idual objec s.
Acco ding o he way cons ain s a ec he objec s,
hey can be o h ee kinds:
1. Cons ain s on s a es o objec s. They allow us o
de ine cons ain s on alues o a ibu es. Acco ding o
he numbe o s a es a ec ed, hese cons ain s can be
o wo kinds:
(a) S a ic cons ain s. They es ic he alues o
a ibu es and hey should no be iola ed in any s a e.
I hey a e ul illed in he cu en s a e, hey should con-
inue being ul illed in he nex s a e. I an objec does
no ul ill hese cons ain s in he ini ial s a e, i will no
be c ea ed. These cons ain s can be de ined in an indi-
idual o collec i e way.
(b) Dynamic cons ain s. They a e bonds be ween
wo s a es: he cu en and he nex . The e a e wo kinds
o dynamic cons ain s: (1) s a e changes associa ed
wi h he occu ence o an e en , which ha e he
es ic ed o m o an assignmen , and (2) mo e gene ic
ansi ion cons ain s, which a e no associa ed wi h
e en s and ac acco ding o de ined s a e changes. They
can be de ined ei he in an indi idual o a collec i e
way.
2. Pa icipa ion cons ain s. They de ine when an
objec is in e es ed in pa icipa ing in an e en o when
i mus pa icipa e. They can be speci ied in wo ways:
(a) Pa icipa ion pe missions. They a e p edica es
es ablished bo h on he s a e o an objec and on he
pa ame e s o an e en . I hey a e no ul illed, hey
will p e en he objec om pa icipa ing in ha e en .
They can be de ined ei he in an indi idual o collec i e
way.
(b) Pa icipa ion obliga ions. Pe missions uniquely
allow o objec s pa icipa e in an e en , wi hou assu -
ing i s pa icipa ion ( o example, when cons ain s on
s a es a e no ul illed). I pa icipa ion obliga ions a e
ul illed, we a e assu ed ha objec s will pa icipa e in
ha e en . They can only be de ined in an indi idual
way.
3. In e ac ion cons ain s among objec s. They
de ine how objec s in e ac be ween hem ( h ough
e en s). Objec s ha should in e ac h ough an e en
ha e o:
(a) Synch onize. Ou model is o ally synch onous.
I is necessa y ha all obliged objec s pa icipa e. I
some objec ha is obliged o pa icipa e canno make
i , hen he e en will no be able o happen.
(b) Communica e. A communica ion o alues
migh ake place be ween in e ac ing objec s. Values
should ul ill all cons ain s imposed by hose objec s,
bo h locally and globally. This way, a nego ia ion
should be es ablished. I mo e han one alue is alid,
he selec ion o he alue will be non-de e minis ic.
Each class will ha e a local iew o e en s in which
i pa icipa es. By means o in e ac ions, we uni y in a
single global e en he di e en local iews o ha
e en in he pa icipan classes.
2.2. Well-Fo med Exp essions
Exp essions should be o med by e ms ha a e syn-
ac ically co ec . This is done by any ope a ion de ined
in he lib a y whose pa ame e s a e also syn ac ically
co ec e ms o a iables o he co esponding so s
(also de ined in he lib a y). Va iables o hese exp es-
sions can be:
9 A ibu es e alua ed in he objec i sel .
9 A ibu es e alua ed in o he objec s, whose iden-
i ica ion is known. Thus, i he class cll has he de ini-
ion a j : c 2, he a ibu e ah is used o iden i y an
objec o he class cl2. Then, he exp ession a e.a 2,
being an a 2 a ibu e o objec s o he class cl2, is well
o med. The ype o his exp ession is he same as he
ype o he a ibu e a 2, and i deno es he alue o his
a ibu e e alua ed in he objec a I.
9 Pa ame e s o e en s. These can only be used in
speci ying pe missions, obliga ions and s a e changes.
Exp essions o he ex ension can be o med in a
simila way. We will conside ha :
PROGRAMMING AND COMPUTER SOFTWARE Vol. 26 No. 4 2000
IMPLEMENTING ASSOCIATIONS AMONG CLASSES 209
1. The e exis s an implici ly de ined a ibu e ha
holds he se o iden i ica ions o all objec s o each
class. We will deno e by c~ he se o class cl.
2. The ollowing collec ion cons uc o s can be used:
(a) {xi : cl ..... x, :
c, I p ed(xl ..... x,) 9 exp(xl .....
x,,) }. Fo each combina ion x I ..... x,, o elemen s, i
builds a se wi h alues e u ning he exp ession
exp
i
he p edica e
p ed
is ue. This no a ion is only used i
he se s c, ..... c, a e ini e.
(b)
[xi : bl ..... b,,
:l
p ed(xl ..... x,) 9 exp(x I ..... x,)].
Fo each combina ion xj ..... x, o elemen s, i builds a
bag wi h alues e u ning he exp ession
exp,
when he
p edica e
p ed
is ue. This no a ion is only used i bags
bj ..... b,, a e ini e.
3. Since se s and bags a e manipula ed in he ex en-
sion, we can also ha e ope a ions like
add, p oduc ,
max, min, and, o ,
and so on. These ope a ions a e con-
side ed as gene aliza ions o he co esponding bina y
ope a ions.
~ Objec s.willing ~----'~
~ pa clpa e "~ L I
Objec s.obliged ~ ~ ]
o pa icipa e - ~,,.._
Fig. 1. When can happen an e en ?
An e en will be able o happen i
(~ ~ ~c,( )
(Fig. 1) and ~,.,,( ,) ~: O, 'Vi 9 {l..n}. Finally, i he
e en
cn( )
happens, all objec s o 9 ~c,,,,~ will ca y
ou he s a e changes associa ed o his e en .
In sho , in ou model, se e al classes can pa ici-
pa e in an e en and o each class all hose objec s ul-
illing hei cons ain s. So, we ha e a mo e lexible
communica ion model han he adi ional
clien -se e
app oach.
2.3. Dynamics o he Sys em
An e en will be able o happen i , o each class
synch onizing h ough his e en , he e is a leas one
in e es ed objec . I some class does no ha e any
objec s in e es ed in pa icipa ing, hen ha e en will
no be able o happen.
Cons ain s on s a es a e condi ions ha mus be ul-
illed du ing he li e ime o objec s. Since he occu -
ence o an e en can change he alue o some
a ibu es, o he es ablished cons ain s should no be
iola ed.
In o de o exp ess hese ideas o mally, we will
de ine wo se s. Le o,( ) be an e en o he sys em,
wi h he channel cn and pa ame e s , in which he
classes
cl i
pa icipa e h ough hei local iews
cni( i),
' 'i e { I ..n }. We de ine:
9 ~c,,(,,,) o deno e he se o objec s o he class
cli
ha can pa icipa e h ough he local iew
cni( i)
o he
e en . This se is composed o hose objec s o
cl i
ha
ul ill hei pe missions on he local iew cni( i) and i s
cons ain s on s a es a e no iola ed (a any le el).
Then, he se o objec s ha can pa icipa e h ough all
local iews o cn( ) will be
~c,,( ) = k..) ~c,,( i)"
ie {I...n}
9 ~,.,,( ,)
o deno e he se o objec s o
cli
ha mus
pa icipa e h ough he local iew
cni( 3
o he e en .
This se is composed o hose objec s o
cli
ha ul ill
i s obliga ions o pa icipa ing in
cni( i).
The se o
objec s ha mus pa icipa e h ough all local iews o
cn( ) will be:
ie { I...n}
3. ASSOCIATIONS AMONG CLASSES
In OO sys ems, he s a e is s uc u ed on di e en
le els. This way, he s a e o an objec is de ined by he
alues o i s a ibu es a a gi en momen . The s a e o
he sys em, in p inciple, is de ined by he s a e o all
objec s a es composing i a a gi en momen .
Howe e , he s a e o a sys em canno always be
desc ibed in his way. Such a s a e should also con ain
links
be ween objec s. These links a e speci ied by
means o associa ions; i.e., links a e ins ances o asso-
cia ions.
3.1. Cha ac e is ics o Associa ions
Acco ding o he numbe o classes in ol ed, asso-
cia ions can be o h ee ypes:
bina y,
i hey a e de ined
be ween objec s o wo di e en classes,
una y,
i hey
a e de ined be ween objec s o he same class and
com-
plex,
i hey a e de ined be ween objec s o h ee o
mo e classes. Hence o h, we will no conside he las
one because i can become a se o bina y associa ions.
An associa ion is de ined by (1) a
name
(2) he
ole
played by objec s o a class wi h ega d o he o he
class, and (3) he
mul iplici y
o each ole. The mul i-
plici y indica es how many objec s o a class can be
ela ed wi h an objec o he o he class o he associa-
ion.
Associa ions a e commonly ep esen ed as con inu-
ous lines be ween he pa icipan classes in he ela ion-
ship, as shown in Fig. 2 (in UML no a ion [3]), whe e
he name o he associa ion is omi ed o easons o
cla i y. A each endpoin o he line he ole and he
mul iplici y o he nea es class is indica ed. This
deno es ha each objec o
Class
can be ela ed wi h
mul iplici y2
objec s o
Class2.
On he o he hand, each
PROGRAMMING AND COMPUTER SOFTWARE Wol. 26 No. 4 2000
210 TORRES e al.
Classl I ole I
mul iplici yl
ole 2
mul iplici y2
Class2
Fig. 2. UML ep esen a ion o a bina y associa ion.
Pe son
Teaches in I
I ca : Ca ego y I
p o esso . i
1..*(se )
cen e
O..l(se )
Uni e si y
Fig. 3. Associa ion wi h a ibu es.
objec o Class 2 can be ela ed wi h he mul iplici y 1
objec s o Classl.
Mul iplici y is de ined by means o a ange no a ion
(in ..sup). The lowe limi speci ies he minimum num-
be o objec s linked wi h he gi en one. Acco ding o
his numbe , an associa ion can be manda o y (posi i e
numbe ) o op ional (0). The uppe limi speci ies he
maximum numbe o objec s linked wi h he gi en one.
I he lowe and uppe limi s coincide, a unique numbe
will be indica ed. An as e isk (*) deno es a non-exis ing
uppe limi [2, 3, 7].
In Fig. 2, ole I deno es he ole ha objec s o Class
play wi h ega d o he Class2, I is like a unc ion ha ,
gi en an objec o Classy, e u ns he associa ed objec
o collec ion o objec s o Classl. On he o he hand,
ole2 has a simila meaning. Roles can be o ganized in
a se (uno de ed collec ion o objec s o he same class,
wi hou duplica es) o bag (uno de ed collec ion o he
same class o objec s, wi h duplica es).
We can also de ine a ibu es o associa ions. These
a ibu es will ake alue when objec s a e associa ed,
bu hey do no belong o hose objec s. Simila ly,
e en s and ansi ions can be added like in classes.
The e o e, we ha e a homogeneous ea men o
classes and associa ions. Figu e 3 shows he associa ion
be ween a uni e si y and people ha a e p o esso s o
his uni e si y. Each p o esso belongs o a ca ego y
and has a sala y. These a ibu es a e no common o he
es o he people. This way, in he associa ion eaches
in he e will be a link wi h hese a ibu es o each p o-
esso wo king a he uni e si y.
Ano he in e es ing p ope y ha can be conside ed
in associa ions is he exclusi i y. By de aul , we con-
side ha pa icipa ion o a class in an associa ion is no
exclusi e. I a class has mo e han one associa ion, and
in some o hem i s pa icipa ion is exclusi e, objec s
wi h links in he exclusi e associa ion canno ha e links
in o he s. This way, in he p e ious example we can
also de ine he associa ion s udies in be ween Uni e -
si y and Pe son. Now, o ins ance, we can de ine a con-
s ain indica ing ha a p o esso canno be a s uden ,
o ha a pe son canno be in bo h associa ions.
3.2. Dynamics o Associa ions
In he p e ious sec ion we ha e de ined s a ic
aspec s o associa ions. In his sec ion we will exp ess
dynamic aspec s o associa ions; i.e., how links
be ween wo objec s a e es ablished and elimina ed. We
ha e o emembe ha objec s o associa ed classes a e
obliged o ce ain hings. They a e no able o wo k
independen ly.
As we ha e said, links can be c ea ed and des oyed.
Thus, in associa ion shown in Fig. 3a pe son can lea e
his job as p o esso in a uni e si y (whe he he inishes
his con ac o o ano he eason). So i is necessa y o
emo e he co esponding link. Howe e , we will no be
able o des oy a link i i implies iola ing some o he
de ined cons ain s ( o example, abou he mul iplici y).
When an associa ed objec disappea s, i s links
should also be dele ed. A link will no be able o exis i
he objec i connec s does no exis . So, in he example
in Fig. 3, i a uni e si y is elimina ed, all links o p o es-
so s ha each in ha uni e si y will also be elimina ed.
4. FORMALIZING ASSOCIATIONS
AMONG CLASSES
The e a e wo common app oaches ha a e adop ed
when associa ions a e ep esen ed in languages ha
do no ha e a co esponding high-le el mechanism [7-
9, 12]:
1s app oach. Rep esen ing associa ions by means
o a ibu es in associa ed classes. I is he mos basic
o m. The main p oblem is ha a ibu ed associa ions
canno be ep esen ed, bu can only ep esen oles.
2 id app oach. Rep esen ing associa ions by means
o classes and a se o cons ain s o hold hei p ope -
ies.
We will ollow he second, mo e gene al app oach.
We will mainly make use o simple classes, collec i e
cons ain s and in e ac ion cons ain s o ou model.
Le as be an associa ion be ween he classes cl~ and
cl 2 aking he oles ole I and ole 2, espec i ely. Things
o do o hold cons ain s imposed by ha associa ion
a e he ollowing:
1. The associa ion will be ep esen ed by a class ha
will ini ially ha e all i s cha ac e is ics. Each objec o
his class will ep esen a link be ween wo objec s o
associa ed classes.
2. I is necessa y o add o his class he ollowing
concep s:
(a) Two cons an a ibu es o he associa ed class
ypes o ep esen he iden i ica ions o linked objec s.
We will deno e hese a ibu es by he name o he co -
esponding oles o he associa ed classes.
PROGRAMMING AND COMPUTER SOFTWARE Vol. 26 No. 4 2000
IMPLEMENTING ASSOCIATIONS AMONG CLASSES 211
(b) Two channels o he collec i e des uc ion o
links, so ha when we des oy an objec o an associa ed
class, i s links also be des oyed. I is also necessa y o
add bo h pe missions and obliga ions so ha all implied
links pa icipa e (and only hose links)9 We deno ed by
cnds '
he channel o collec i e des uc ion o he class
cli, Vi
~ { 1..2}; i s pe missions and obliga ions will be
he ollowing:
Cnds,(sid, idi)
pe missions oid ~ sid
obliga ions oid ~ sid
The channel
Cnd,~,
will ha e wo pa ame e s
sid
and
id~
whe e
sid
is he se o links o ha objec o
cl i
whose
iden i ica ion is
ida.
(c) I is also necessa y o add pe missions o his e en
in he ex ension in o de o calcula e which a e he
implied links. The se
sid
ha
idi
has wi h objec s o he
o he class o he associa ion, is calcula ed as ollows:
cnds,(sid, idi)
pe missions sid = {y : 631y. olei = id i9 y}
(d) S a e changes o e en s o he collec i e
des uc ion o links, in o de o elimina e hese links
om he ex ension:
cnds,(sid, idi)
s a e changes 63' = 63- sid
whe e 63' deno es he alue o he a ibu e 63' in he
s a e ollowing he occu ence o an e en 9
(e) Cons ain s on he ex ension o hold cons ain s
imposed by oles de ined in he associa ion. Fi s ly, i is
calcula ed wha objec s o a class a e linked wi h a
gi en objec o he o he class. Fo example, o he
class
cl I
we ha e:
link1(63, id i) = [y :
631y. olel
= id I * y. ole2],
whe e
id I
is he iden i ica ion o an objec o
Cll.
A e wa ds i is necessa y o e i y ha cons ain s
on he co esponding oles a e ul illed, i.e., cons ain s
on bo h he numbe o objec s and he kind o o ganiza-
ion. The e o e, o he class
cl~,
he ollowing p edi-
ca es mus be calcula ed:
p edl(63, id ) = le m = linkj(63, idl) in
in_ ange2(#m ) and p 2(m )
end le
in_ ange2(n) = (n
>=
in 2)
and (n <=
sip2 )
is_se (m) i o g2 is se
p E(m) = ~ [ ue i o g 2 is no se ,
whe e he p edica e
in_ ange
con ols ha he numbe
o objec s linked wi h he gi en one is in he co ec
ange. I he uppe limi is an *, i is no necessa y o
speci y he condi ion and (#m <=
sup2).
On he o he
hand, he p edica e
p
e i ies ha he o ganiza ion is
he co ec one. The necessa y p edica es o
cl2
a e
ob ained in a symme ical way.
Finally, i is necessa y o e i y ha all objec s o he
associa ed classes ul ill he p e ious p edica es. So we
will de ine he ollowing s a ic cons ain on he ex en-
sion:
and([idi : cl i 9 p edi(63, idi)]);
' 'i ~ { 1..2}.
Such and ope a ion is he and ope a ion on Booleans
ex ended o ope a e wi h a Boolean bag.
3. We should ex end he in e ac ion cons ain s so
ha whene e an objec is des oyed, i s links a e also
des oyed. So, o each in e ac ion whe e he channel o
des uc ion o
cl~
appea s, i will be necessa y o include
he channel
cnd.,.
4. All links a e among exis ing objec s. The e o e, i
is necessa y o add collec i e s a ic cons ain s9 We
should:
(a) De ine, in he ex ension o he class
as,
a de i ed
a ibu e o each class in he associa ion. This a ibu e
will be a bag e e ing o hose objec s ha ha e a link
wi h an objec o he o he class:
a e~ , = lid " 63 9 id. olei];
Vi ~ { 1..2}.
(b) In o de o e i y ha hose objec s eally belong
o he ex ension o
cli,
we will add he ollowing global
cons ain :
b os(63.a ed, ) inc cli;
' 'i e { 1..2 },
whe e he
b os
ope a ion, gi en a bag o elemen s,
e u ns a se wi hou duplica es.
(c) I he pa icipa ion o a class in an associa ion is
de ined as exclusi e, hen objec s in ha associa ion
canno ha e links in o he associa ions. We will ha e o
add mo e collec i e cons ain s9 This way, i he class
cl
has de ined he associa ions
as,
wi h he classes
clj,
9 , .J . . .
Vj ~ { 1 ..m }, and excluswe pamclpa lon m
asi,
hen we
will ha e:
( Ti.a ec n 63-j.a ed) = emp y;
Vj ~ { i..m }, j ~ i,
whe e
a ecl
is he de i ed a ibu e de ined in he asso-
cia ion
as, Vj
e { l..m}, in o de o hold iden i ica ions
9 J
o objec s o he class
cl
wi h some link in he associa-
ion.
5. IMPLEMENTATION WITH ACTIVE
DATABASES
T adi ionally, bina y associa ions ha e been main-
ained in ela ional da abases by means o e e en ial
in eg i y. Howe e , when associa ions a e a bi mo e
PROGRAMMING AND COMPUTER SOFTWARE Vol. 26 No. 4 2000

212 TORRES
e al.
complex, we will need o make use o ano he me hod
o main ain hem. The design o ac i e ules allows us
o de ine p ocedu al ac ions o be ca ded ou o epai -
ing an in eg i y iola ion, al hough i loses he decla a-
i e ad an age o being able o speci y he cons ain s.
In he ollowing sec ions, we will desc ibe he main
poin s o in e es necessa y o implemen p e iously
de ined seman ics by means o ac i e da abases [6], a
new esea ch a ea ha inc eases he unc ionali y o a-
di ional da abases wi h ac i e ules, p o iding an e i-
cien and uni o m mechanism o de eloping some
asks wi hin he ke nel o a da abase.
5. I. An O e iew o Ac i e Da abases
Mos o da abase sys ems a e passi e; i.e., da a can
be inse ed, modi ied o dele ed as a esul o eques s
om ei he use s o applica ions. A ecen esea ch a ea
aims o ex end he unc ionali y o da abase sys ems by
including ce ain ype o ac i e beha io in he da a-
base. In his way, da abase sys ems can execu e some
p ocesses au oma ically in esponse o he occu ence
o sa is ac ion o e en s o condi ions [5, 18].
O he e ms, synonyms o ac i e ules, a e p oduc-
ion ule-s, e en -condi ion-ac ion o
ECA
ules, ig-
ge s, moni o s, and so on. Al hough se e al implemen-
a ions o ac i e ules exis in da abase sys ems, he e
a e h ee main componen s:
E en is he di ec cause o he ac i e ule o be ig-
ge ed.
Condi ion mus be sa is ied so ha he ac i e ule
can be igge ed.
Ac ion is he p ocedu e o be execu ed when he
co esponding e en occu s and he condi ion is sa is-
ied.
Se e al a eas exis whe e ac i e ule se s can be used
wi h he pu pose o imp o ing he e iciency o he sys-
em. The mos impo an ac i i ies a e:
9 In e nal asks,
such as main aining all kinds o
cons ain s and de i ed da a. One o hem is he main-
enance ela ed o associa ions, which is he objec i e
o ou wo k.
9 Ex ended asks,
such as eplica ion, e sioning and
wo k low managemen .
9 Ex e nal asks,
such as he business ules o any
applica ion.
These ules can be sha ed by all applica ions access-
ing he da abase, gua an eeing knowledge indepen-
dence because he pa o beha io ha is adi ionally
accomplished by applica ions is mo ed in o da abase
sys ems.
Un o una ely, i he design o ac i e ules was no
app op ia e, we could be in ouble because o hei col-
lec i e beha io , in e ac ions and mu ual in luences,
mainly due o he abili y o ules o igge each o he .
To ensu e he global co ec ness o ac i e ules a la ge,
we should design an ac i e ule se ha accomplishes
he e mina ion p ope y. Some imes, o he p ope ies
also mus be aken in o accoun , such as con luence and
obse able de e minism [1]. Following, we de ine hese
e ms:
9 Te mina ion.
A se o ac i e ules is said o possess
he e mina ion p ope y when he ule p ocessing ig-
ge ed by e e y use -de ined ansac ion is e en ually
e mina ed, p oducing a inal s a e.
9 Con luence.
A se o ac i e ules is said o gua an-
ee he con luence p ope y when such p ocessing
e en ually e mina es, and always p oduces an unique
inal s a e ha is independen o he execu ion o de o
he ules.
9 Obse able de e minism.
A se o ac i e ules is
said o gua an ee an obse able de e minism when, in
addi ion o con luence, o each use -de ined ansac-
ion, all isible ac ions pe o med by he ules a e he
same.
Ano he impo an cha ac e is ic o an ac i e ule is
he ime when i s ac ion will be execu ed wi h espec
o he e en ime and in ela ion o he cu en ansac-
ion. An ac i e ule is said o be
immedia e
i he ac ion
is execu ed immedia ely a e he e en occu s (i con-
di ion we e sa is ied), and i is said o be
de e ed
i he
ac ion is execu ed a he end o cu en ansac ion.
The la es e sions o DBMSs, bo h ela ional and
objec - ela ional, include igge s (which is he e m
no mally used in p ac ice). Un o una ely, a p oblem
ela ed o hei implemen a ion is he ac ha igge s
implemen ed in comme cial da abase sys ems (such as
O acle, DB2, Sybase, In e base, among o he s) a e no
powe ul enough. This is he case because no comple e
s anda iza ion abou igge s in SQL exis s, and none
o hem o e s de e ed igge s a all. The cu en
SQL3 speci ica ion o igge s is a he long and di i-
cul o unde s and, and di e ences be ween p oposals
conside ed by s anda diza ion commi ees (bo h ANSI
and ISO) [10] a e an addi ional sou ce o con usion.
The e a e o he p oblems associa ed wi h ules. One
o hem is known as
mu a ing ables,
and i is ela ed o
p oblems ha may a ise because o ansac ion man-
agemen : we can nei he modi y no ead ows o ables
al eady upda ed du ing he ansac ion. Ano he poin
o in e es is he incompa ibili y be ween decla a i e
e e en ial in eg i y and igge s. Al hough mos da a-
base sys ems o e acili ies, when we ha e o imple-
men mo e complex ela ionships, we need o use ig-
ge s and such acili ies should no be used.
[5] o e s a pa ial solu ion o hose p oblems.
Me a-
igge ing
consis s in a mapping om e e y ac i e ule
o a conc e e s o ed p ocedu e ha codes bo h i s con-
di ion and i s ac ion. When an e en is igge ed, a lag
is upda ed in a empo al able o each ac i e ule ha
is igge ed by ha e en , and immedia e ules a e p o-
cessed a e wa ds. A he end o he ansac ion, all
de e ed ules will be p ocessed. When implemen ing
i , we ha e ealized some ex ensions o he me hod, so
ha any numbe o he same igge ins ances could be
PROGRAMMING AND COMPUTER SOFTWARE Vol. 26 No. 4 2000
IMPLEMENTING ASSOCIATIONS AMONG CLASSES 213
p ocessed, and also allowing pass o objec iden i ie s
being a ec ed by ope a ions om igge s o s o ed
p ocedu es (all by means o ime s amps).
5.2. Ac i e Rules o Associa ions
As men ioned abo e, e e y class can be imple-
men ed by means o a able in a ela ional da abase,
whe e each objec will be s o ed in a ow. Associa ions,
like any class, can also be implemen ed by means o a
able, whe e links a e s o ed in such a able by means o
e e ences o each pa icipan objec .
Channels o e en s can be implemen ed by means o
igge s eac ing o he c ea ion and dele ion o objec s.
So, e iciency is imp o ed because he explici ea -
men o channels o e en s, o he wise e y expensi e,
is a oided.
Al hough c ea ion is implici ly o malized in
seman ics, he execu ion o a igge a e he c ea ion
o e e y objec is necessa y o es he cons ain s, such
as e e en ial in eg i y, mul iplici y and exclusi i y.
A e an objec is dele ed, a igge will be execu ed,
and all links whe e ha objec pa icipa es should be
dele ed. Like e e y ule, he dele ion ule has h ee
componen s: e en , condi ion and ac ion. The o me is
easy and has a di ec sc ip . The condi ion o he ule is
mo e complex: i is necessa y o e i y ha , o each
link whe e an objec pa icipa es, cons ain s o co e-
sponding oles a e ul illed a e ha objec has been
dele ed. The ac ion will be o p opaga e dele ion o all
links o e e y link whe e he objec pa icipa es.
C ea ion and dele ion o a link a e simila . A e a
new link is c ea ed, pa icipan objec s mus exis , and
mul iplici y and exclusi i y mus be sa is ied immedi-
a ely a e wa ds. A e an exis ing link is dele ed, he
unique cons ain ha should be sa is ied is he mul i-
plici y.
5.3. An Example o a T igge Se
In his sec ion we show, using O acle syn ax [13],
de ini ion o he example in Fig. 3. Now,
Pe son, Uni-
e si~.,
and
Teachesln
classes will be ables s o ing
objec s and links o he espec i e classes. No addi-
ional p ope ies a e isible. De ini ions o ables a e as
ollows:
CREATE TABLE Pe son
(Oid INTEGER PRIMARY KEY);
CREATE TABLE Uni e si y
(Oid INTEGER PRIMARY KEY);
CREATE TABLE TeachesIn
(P o esso INTEGER, Cen e INTEGER, PRIMARY KEY(P o esso , Cen e ) ) ;
T igge s de ined o he c ea ion and dele ion o
Pe son
objec s a e as ollows:
CREATE TRIGGER C ea ePe son
AFTER INSERT ON Pe son
FOR EACH ROW
-- WITH DEFERRED EXECUTION
BEGIN
IF NOT (Re In eg i yACP(New. Oid)
AND Mul iplici yACP(New. Oid)
AND Exclusi i yACP(New. Oid)) THEN
RAISE_APPLICATION_ERROR(-20000, "Cons ain s a e no ul illed');
END IF;
END;
CREATE TRIGGER Dele ePe son
AFTER DELETE ON Pe son
FOR EACH ROW
-- WITH DEFERRED EXECUTION
BEGIN
IF NOT Mul iplici yADP(Old. Oid) THEN
RAISE_APPLICATION_ERROR(-20000, "Cons ain s a e no
END IF;
DELETE FROM TeachesIn WHERE P o esso =Old. Oid;
END;
ul illed') ;
PROGRAMMING AND COMPUTER SOFTWARE Vol. 26 No. 4 2000
214 TORRES
e al.
T igge s o he
Uni e si y
class a e simila . T ig-
ge s
C ea ePe son
and
Dele ePe son
will aise an
excep ion when any o he p edica es e u ns
FALSE.
Fo b e i y, s o ed p ocedu es implemen ing he p edi-
ca es a e no shown. Following is a sho desc ip ion:
Re ln eg i yACP
ecei es he iden i ie o a new
objec and e u ns
TRUE
i he e e en ial in eg i y is
sa is ied o his objec , o
FALSE
o he wise.
Mul iplici yACP
ecei es he iden i ie o a new
objec and e u ns
TRUE
i he mul iplici y cons ain s
a e sa is ied o he associa ions in which his objec
pa icipa es, o
FALSE
o he wise.
Exclusi i yACP
ecei es he iden i ie o a new
objec and e u ns
TRUE
i he exclusi i y cons ain s
a e sa is ied o he agg ega ions in which an objec
pa icipa es, o
FALSE
o he wise.
Mul iplici yADP
ecei es he iden i ie o an old
objec and e u ns
TRUE
i he mul iplici y cons ain s
a e sa is ied o he associa ions in which his objec
pa icipa es a e his objec has been dele ed, o
FALSE
o he wise.
Finally, igge s o he c ea ion and dele ion o
Teachesln
links a e simila . A link can be c ea ed i he
e e en ial in eg i y, mul iplici y and exclusi i y con-
s ain s a e sa is ied by he pa icipan objec s. O he -
wise, an excep ion will be aised and no link will be
c ea ed. On he o he hand, a link can be dele ed i he
mul iplici y cons ain s a e sa is ied a e such an e en
Occu s.
5.4. Final Rema ks on he Implemen a ion
Each o hese ules should be de e ed execu ion,
allowing in e media e s a es ha could empo ally io-
la e he cons ain s, bu ha a e necessa y when a ela-
ionship is c ea ed o dele ed. As an example, we could
c ea e an objec and all links whe e such objec pa ic-
ipa es a e wa ds. I he ules a e no de e ed when he
objec is c ea ed, an excep ion could be aised because
some o he cons ain s we e no sa is ied, despi e links
c ea ed ollowing he c ea ion o such objec .
Many o he combina ions can be ound, meaning
ha all ela ed ope a ions should be g ouped in o ans-
ac ions. On commi , when hese ules a e p ocessed, i
any p edica e is no ue, hen he ope a ion mus be
canceled. This is implemen ed by aising a use -excep-
ion ha ollbacks he cu en ansac ion, and he e-
o e, undoing all hose changes ha we e pending o
being commi ed. As men ioned abo e, some addi ional
echniques, such as me a- igge ing, will be necessa y
o implemen hem because o he aul s d awbacks
inhe en in cu en ac i e da abases.
Gene ally, he use o ac i e ules has a be e pe o -
mance, because many ac i i ies, o he wise execu ed by
an applica ion, a e unning wi hin a da abase, and so
communica ions be ween applica ions and da abases
ha e a majo e iciency.
Un o una ely, his se o ules gua an ees e mina-
ion, bu no con luence no obse able de e minism.
So, non-de e minism could a ise and hese si ua ions
a e no ecommended in many sys ems. Solu ions
could lie in applying se e al echniques o a oid i , such
as assigning p io i ies and edesigning ule se s, among
o he s.
6. CONCLUSIONS
We ha e p esen ed in his pape a o maliza ion o
seman ics o one o he mo e common ope a o s in he
OO concep ual modelling, associa ions among classes
o objec s.
Fi s , we ha e p esen ed he mos impo an cha ac-
e is ics in ou OO model. A speci ica ion is ca ied ou
by means o cons ain s o di e en kinds ha can be
imposed a h ee di e en le els: objec , class and glo-
bal.
A e wa ds we ha e de ined some p ope ies o
associa ions o classes, inspi ed undamen ally in he
mo e popula OO me hodologies. Nex , we ha e
de ined he seman ics o associa ions by means o
classes and cons ain s allowed in ou model. This way,
o change p ope ies o any associa ion, i will simply
be necessa y o add new cons ain s o o elimina e
some o hem.
Finally, we ha e shown some ema ks on ou imple-
men a ion by means o ac i e da abases. We a e ac u-
ally wo king ha d o au oma ically gene a e a se o
ac i e ules om he o malized de ini ions o a sys em.
Fu he mo e, we ha e planned o s udy o he de ined
ela ionships among objec s, oge he wi h hei imple-
men a ion, such as agg ega ions o inhe i ance.
ACKNOWLEDGMENTS
This wo k was suppo ed by he In e -minis e ial
Commission o Science and Technology (CICYT) o
Spain, p ojec no. TIC97-0593-C05-03.
REFERENCES
1. Aiken, A., Widom, J., and Helle s ein, J.M., Beha iou
o Da abase P oduc ion Rules: Te mina ion, Con luence,
and Obse able De e minism,
P oc. ACM SIGMOD In .
Con . on Managemen o Da a,
1992, pp. 59-68.
2. Bock, C. and Odell, J.,A mo e Comple e Model o Rela-
ions and Thei Implemen a ion., J.
Objec -O ien ed
P og amming,
1997, June, pp. 38---47.
3. Booch, G., Jacobson, I., and Rumbaugh, J.,
The Uni ied
Modeling Language Use Guide,
Addison-Wesley,
1999.
4. Bou deau, R.H. and Cheng, B.H.C., A Fo mal Seman ic
o Objec Model Diag ams,
IEEE T ans. So wa e Eng.,
1995, Oc obe .
5. Ce i, S. and F a e nali, P.,
Designing Da abase Applica-
ions wi h Objec Rules,
Addison-Wesley, 1997.
PROGRAMMING AND COMPUTER SOFTWARE Vol. 26 No. 4 2000
IMPLEMENTING ASSOCIATIONS AMONG CLASSES 215
6. Di ich, K., Ga ziu, S., and Geppe , A., The Ac i e
Da abase Managemen Sys em Mani es o: A Rulebase
o a ADBMS Fea u es, J. SIGMOD Reco d, 1996,
ol. 25, no. 3, pp. 40-49.
7. Ehlmann, B.K. and Ricca di, G.A., An In eg a ed and
Enhanced Me hodology o Modeling and Implemen ing
Objec Rela ionships, J. Objec -O ien ed P og amming,
1997, May, pp. 47-55.
8. G aham, I., Bischo , J., and Hende son-Selle s, B.,
Associa ions Conside ed a Bad Thing, J. Objec -O i-
en ed P og amming, 1997, Feb ua y, pp. 41--48.
9. Hammond, J., P oducing Z Speci ica ions om Objec -
O ien ed Analysis, in Z Use Wo kshop 1994. Wo kshops
in Compu ing, Nicholls, J.E., Ed., Sp inge , 1995,
pp. 316-336.
10. ISO-ANSI. Da abase Language SQL3, wo king d a ,
1994.
II. Khosha ian, S.N. and Copeland, C.P., Objec Iden i y,
Objec -O ien ed P og amming Sys ems, Languages and
Applica ions, SIGPLAN No ices, 1986, ol. 22, no. 12,
pp. 406--416.
12. Lano, K., Fo mal Objec -O ien ed De elopmen ,
Sp inge , 1995.
13. PL/SQL Use 's Guide and Re e ence, Release 8.0, O a-
cle Co po a ion, 1997.
14. Rumbaugh, J., Blaha, M., P eme lani, W., Eddy, F., and
Lo cnsen, W., Objec -O ien ed Modelling and Design,
P en ice Hall, 199 !.
15. Shlae , S. and Mello , S., Objec Li ecycles: Modelling
he Wo ld in S a es, You don P ess Compu ing Se ies,
1992.
16. To es, J., T oyano, J.A., and To o, M., Ope a o s o
Associa ion and Agg ega ion in an Objec O ien ed
Speci ica ion Language, H Wo kshop on Compu e Sci-
ence, G anada (Spain), 1996, pp. 11-21.
i 7. To es, J., Objec O ien ed Speci ica ions Based on Con-
s ain s, PhD Thesis, Depa men o Languages and
Compu e Sys ems, Uni e si y o Se ille, i 997.
18. Widom, J. and Ce i, S., Ac i e Da abase Sys ems: T ig-
ge s and Rules o Ad anced Dababase P ocessing, San
F ancisco: Kau mann, 1996.
PROGRAMMING AND COMPUTER SOFTWARE Vol. 26 No. 4 2000