Skip navigation
crikos
Currently Being Moderated

Foreign Key Constraints

Dec 16, 2011 9:59 AM

Hi everybody,

does anybody have suggestions, for creating foreign keys in a MySQL DB using Coldfusion9. The traditional way is to define the constraints in MySQL. Beside that I have to define those relationships also in Coldfusion.

Should I define the constraints on both sides, or just in Coldfusion ? As I tried out it is working, if I do the definitions only in CF9.

 

Thanks for answering.

Regards

 
Replies
  • Dave Watts
    747 posts
    Mar 11, 2003
    Currently Being Moderated
    Dec 16, 2011 10:12 AM   in reply to crikos

    I'm not sure what you mean by "define those relationships also in ColdFusion". Do you mean within ORM? In any case, though, if you need constraints they should be defined within your relational database first and foremost.

     

    Dave Watts, CTO, Fig Leaf Software

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 16, 2011 11:01 AM   in reply to crikos

    You should always acknowledge the possibility that the db will be accessed without using ColdFusion.  Once you do so, do you think foreign key constraints will be useful at the database level?

     

    BTW, like Dave Watts, I don't know what you mean when you say you define relationships in ColdFusion.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 17, 2011 3:44 AM   in reply to Dave Watts

    I'm not sure what you mean by "define those relationships also in ColdFusion". Do you mean within ORM? In any case, though, if you need constraints they should be defined within your relational database first and foremost.

     

    I'm presuming the OP does indeed mean in the context of defining a mapping between a CF object and DB storage via Hibernate.

     

    One can use the CF ORM mappings in two different ways:

    1) start with nothing in the DB, and the ORM mapping also creates the DB requirements (tables, keys, constraints etc).  In which case the mappings in CF do reflect the constraints that will end up in the DB too.  That's what those settings are for.

     

    2) mapping already existing DB resources to a CF component.  In this situation I don't think CF will create new constraints if the tables already exist.  Although there's one very easy way to test that...

     

    Either way, the constraints ought to be present in the DB, yes.  If CF's ORM mapping doesn't do it itself, then it ought to be done by hand.

     

    --

    Adam

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points