It would depend on whether you'll ever really need a CardType object in your
application.  If you will never need one, then there's no real reason to
create the object - just store the key.

If you do have CardType objects already build for your app, then it depends
on the needs of the application.  Again, if you'll never need to reference
and object's CardType property object or you'll only need to reference it by
key, then there's no reason to create an instance of the object.

It'll come down to balancing data abstraction vs. performance.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Douglas Humphris
Sent: Monday, March 15, 2004 10:00 AM
To: [EMAIL PROTECTED]
Subject: [CFCDev] MVC Architecture

I have a question regarding the architecture of my cfc objects in an MVC
environment. I'm using Mach-ii, but I guess this can be applied to any
MVC architecture.

After creating the database schema, I create a cfc object for each table
in the database. The object (or "bean") will be used by my CRUD and
Listener components. The question is: what should I do about foreign
keys in my bean objects? Should I store them as integer values, or
should I give access to the object that the foreign key is referencing?

i.e.

I have a table called "Cards" with fields:
CardID [Primary Key],
CardTypeID [Foreign Key],
Name,
Number,
CV2Number,
StartDate,
ExpiryDate

In my bean, should I have:

<cfcomponent displayname="Cards" hint="Card Object">

        <!--- PROPERTIES --->
        <cfset variables.CardID = 0 /><!--- primary key --->
        <cfset variables.CardTypeID = 0 /><!--- foreign key --->
        <cfset variables.Name = "" />
        <cfset variables.Number = "" />
        <cfset variables.CV2Number = "" />
        <cfset variables.StartDate = "" />
        <cfset variables.ExpiryDate = "" />
        
        ...

Or should I have:
        <cfset variables.CardType = CreateObject("component","cardtype")
/>


There are many tables which have several foreign keys, and the "foreign"
tables have further foreign keys, so it gets quite complicated. I like
the idea of using objects instead of foreign keys in the beans, but have
never done either before.

What do people on this list do? What are the pros and cons?

Many thanks,

Douglas

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

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' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

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

Reply via email to