In scenario 1, I will consider putting foreign keys in Order Table (pointing
to pk in address table)a relatively poor database design. If address is
dependent, it should contain any foreign keys and not the other way round.

In scenario 2, how will the persistence manager know the addressType in
OrderAddressLinkTable ?

In OR mapping, it is only OrderBean and Address which will be matched to
Order Table and Address Table respectively. In this scenario, how
Persistence Manager will provide implementation of lets say
getShippingAddress() and getBillingAddress() in the order bean.

Similarly for setShippingAddress, setBillingAddress, what value should
persistence manager put in the addressType column of the
OrderAddressLinkTable ?

Regards,

Hemant
www.pramati.com



----- Original Message -----
From: "Richard Monson-Haefel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 14, 2000 12:17 AM
Subject: Re: EJB2.0 questions


You have two options:  Use foreign keys directly in the Order table OR use a
join table (link table). Either will work, I would think, with a good
persistence manager, but the first scenario is more likely to work with all
O/R
persistence managers.

Using address foreign keys directly in the Order table (scenario 1) will be
more
performant (one less table to join). Using a link table (scenario 2) gives
you
more flexibility.

Also this all depends on support for cascading deletes, which changes the
organization considerably.  In that case you'll need an Address table with
foreign keys pointing back to the Order table.

Scenario 1: Using foreign keys directly in the Order table.
********************************************
Order Table
-------------
orderID (pk)
shippingAddress (fk to addressID in Address table)
billingAddress (fk to addressID in Address table)

Address Table
---------------
addressID (pk)
street,
city
state
zip

Scenario 2: Using a link table
***************************
Order Table
-----------
orderID (pk)
orderAddress (fk to ID in OrderAddressLink Table)

OrderAddressLink Table
-----------------------
ID (pk)
orderID (fk to orderID in Order Table)
addressID (fk to addressID in Address Table)
addressType (char [30] describes the type of address shipping or billing.)

Address Table
---------------
addressID
street,
city
state,
zip



--
Richard Monson-Haefel
Author of Enterprise JavaBeans, 2nd Edition  (O'Reilly 2000)
Co-Author of Java Message Service (O'Reilly 2000)
http://www.EjbNow.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to