I'd like to point out that a third table is only needed for a N-M
(many-to-many) relationship.
In the case of a 1-N relationship, simply have a foreign key to the
master table.
For example :
Customer object refers to a Country object
you a Customer will only have one Country object. you do NOT need a
third table to map this.
Simply add a field in Customer that contains the foreign key to the
Country object.
The EJB 2.0 mapping is Simple
Customer ...
public abstract Country getCountry();
public abstract void setCountry(Country aCountry);
and in Country
public abstract Collection getCustomers();
public abstract void setCustomer(Collection customers);
This is fully supported by Orion, which will populate the collection
object automatically.
Cheers,
Daniel
-----Message d'origine-----
De : Tony J Brooks [mailto:[EMAIL PROTECTED]]
Envoyé : 22 janvier, 2001 11:27
À : Orion-Interest
Objet : RE: O/R mapping
Hi Theis,
As much as I can remember, there *is* - definitely - a need for an
intermediate third table to contain the mapping information. By using
this
third table, you eliminate data replication/redundancy in the other two
tables.
To my knowledge this is a common technique. ER tools typically create
such
an intermediate table for you when you select a relationship to be
'zero/one/many to many'. Whether you see that on your diagram is
another
matter, but you will definitely see it in your DB ;)
Apologies if I have misunderstood your question.
Bye for now,
Tony.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
[EMAIL PROTECTED]
Sent: 22 January 2001 15:10
To: Orion-Interest
Subject: O/R mapping
Hi!
I have been reading the complex-or example and ploughed through the atm
example. In the complex-or example it is stated that collections are
mapped
to an another table and that the reason for this is normalization. The
Atm
example is also following this principle.
Is this really correct? I have never seen the necessity for mapping
anone
to many relation to a third table (even though it was a long time ago I
read the rules of normalization I'm very doubtful that this is correct).
Could someone tell me the rational behind this.
If this not true, how does the xml look like (in the orion-ejb-jar.xml)
when you only map the relation as a foreign key?
Regards
/Theis