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]

Reply via email to