Relations capture the design intent.  Meaning, you will allow only
values from a parent table to be inserted into the child table.

By placing these constraints on the database, you can ensure that any,
and all, applications cannot bypass your intent by inserting values in
the child table that don't exist in the parent table.

Also, fk constraints can automate database actions.  For example, if you
remove a category from a parent table, the database constraint's ON
CASCADE DELETE "trigger" can remove all related records in the child
table.  You don't have to perform two DELETE operations.

As far as the design intent, and seeing it on paper, you can more-easily
see what relationships are optional/mandatory one-to-many, one-to-one,
or other options that are available per database platform.

You can also consider it to be database-based error prevention.

M!ke

-----Original Message-----
From: Matthew Small [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 02, 2005 1:53 PM
To: CF-Community
Subject: SQL relationships

For the past 8 years I've been working with SQL, I've never really
understood how to use the relational diagrams that use primary and
foreign keys.  I just recently found the diagram tool in SQL and I like
it for laying out my new databases.  However, even though I understand
the concepts, I don't really see the use of connecting the tables
together in these diagrams, of declaring the foreign and primary keys in
these things.
In my programming, I know which tables are related to other tables, but
why
is it good to tell the db what these relationships are?   

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:5:159468
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to