Re: Parent-Child relationship

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: james (nospam_at_hypercon.net)
Date: 02/15/05


Date: Tue, 15 Feb 2005 12:44:26 -0600

Only use cascade delete when you are always sure that it never makes sense
to have a child when the parent is deleted. There are cases where it makes
sense for a child to have a null in the FK column, usually this is when
there are multiple Fk's in the child table, BUT, the is usually always ONE
Master table, as in Invoice and InvoiceItem when you must decide to either
cascade delete the InvoiceItem when and Invoice is deleted or to DENY
deleting and Invoice if it has InvoiceItems. This is a business rule that
you must decide on.

JIM

"PH" <PH@discussions.microsoft.com> wrote in message
news:AE79F794-3984-4DE6-949B-C395B817E144@microsoft.com...
>I have a field which is the primary key in table A, and in table B i have
>the
> same field which is the foreign key.When it comes to deleting a record I
> should kill the child first.If i try to delete the parent then i get an
> error, which is expected. But if i turn the delete cascade option on, it
> lets
> me delete the parent first without giving an error.Why?
> Thanks in advance.



Relevant Pages

  • Re: AddNew on empty dataset with relations sets wrong child key.
    ... I just tried the cascade at the typed dataset level but it had no affect. ... The parent or the child? ... do I need to do an AcceptChanges at the parent level before processing ... > then get pushed down to the child row. ...
    (microsoft.public.dotnet.framework)
  • Re: cascade update explanation
    ... to one), I want to delete the child when the parent is deleted, so I ... When would I use cascade update and why would I ...
    (microsoft.public.access.gettingstarted)
  • Re: deleting a row potentially referenced by many rows in another table
    ... you would use ON DELETE CASCADE on a foreign key in a child table to ... FOREIGN KEY REFERENCES Parent ... row in the child table referencing that (parent) row is deleted (N:1 ...
    (comp.databases.theory)
  • Re: Parent-Child relationship
    ... > to have a child when the parent is deleted. ... > cascade delete the InvoiceItem when and Invoice is deleted or to DENY ... >> same field which is the foreign key.When it comes to deleting a record I ...
    (microsoft.public.sqlserver.programming)
  • RE: Form/Subform
    ... in the child table for each record in the parent table. ... As far as getting the proper FK value into the child table, ... and on the subform, a set of data that would be unique to each record. ... I was using the invoice number, ...
    (microsoft.public.access.forms)