This is very similar to the Customer/Invoice problem.  See Hal Helms'
newsletters for more information.

http://www.halhelms.com/index.cfm?fuseaction=newsletters.show&issue=011405_context

Jason Cronk
[EMAIL PROTECTED]




                                                                                
                                                       
                      "Dawson, Michael"                                         
                                                       
                      <[EMAIL PROTECTED]        To:       [email protected]    
                                                        
                      edu>                     cc:                              
                                                       
                      Sent by:                 Subject:  [CFCDev] Do Objects 
Contain Foreign Key IDs or Values?                        
                      [EMAIL PROTECTED]                                         
                                                       
                      one.org                                                   
                                                       
                                                                                
                                                       
                                                                                
                                                       
                      05/10/2005 11:08                                          
                                                       
                      AM                                                        
                                                       
                      Please respond to                                         
                                                       
                      CFCDev                                                    
                                                       
                                                                                
                                                       
                                                                                
                                                       




Let's say I have a simple object called Picture.  This picture can be
associated to multiple categories such as: "B&W", "Portrait", "Digital",
etc.

When modeling the database, I would have a table to store the picture
information as well as a related table for the picture categories.  I would
assume this to be a "has-a" relation.

When I create an object and init it with data, would I pull in only the
foreign key ID (1, 2, 3, etc) or do I pull in the value ("B&W", "Portrait",
"Digital") and store with the rest of the picture object properties?

Or, is there really not a need to do this?

I visualize a web-based form that displays picture information.  There are
also checkboxes that let me associate one or more categories with each
picture.

When I build the form, I query pictureDAO to retrieve the picture
information.  I would then pass the picture ID to the pictureCategoryGW and
get back a list of IDs for the associated categories.  This leads me to
believe I really don't need to init the picture object with the category
information, at all.  In this case, the controller (form page) will display
it as needed.

The only issue I see, by not putting the category information in the
picture object, would be extra database hits to later get that information.

Any suggestions or comments?  Will I ever understand OO?  ;-)

Thanks
M!ke
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of
the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]





----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to