Hello,
A quick question about cascading deletions...
Say I have two tables with the following data
Table A
index data
1 "some data"
2 "some other data"
Table B
index A-index data
1 2 "something"
2 1 "something else"
3 1 "out of this world"
These tables set up to perform cascading deletions when
records are removed.
My question is this: If I remove index 3 from table B,
will index 1 from table A be removed?
If not, how do you get cascading deletion to work?
Thanks
MeNo, cascade delete works "top-to-bottom", not "bottom-to-top" meaning a
foreign key with "on delete cascade", will only fire when A-index "1" is
removed from Table A. What you are seeking would cause a violation of the
foreign key because Index 2 in Table B still has reference to A-Index "2".
If you need to remove reference to all records in Table B with A-Index "1",
you need to write a trigger for the Delete event.
HTH,
Morgan
"Me" <anonymous@.discussions.microsoft.com> wrote in message
news:03f001c3c9a7$952dbd30$a101280a@.phx.gbl...
> Hello,
> A quick question about cascading deletions...
> Say I have two tables with the following data
> Table A
> index data
> 1 "some data"
> 2 "some other data"
> Table B
> index A-index data
> 1 2 "something"
> 2 1 "something else"
> 3 1 "out of this world"
>
> These tables set up to perform cascading deletions when
> records are removed.
> My question is this: If I remove index 3 from table B,
> will index 1 from table A be removed?
> If not, how do you get cascading deletion to work?
> Thanks
> Me|||Sorry this should have read..
If you need to remove the record(s) in Table A with A-Index "1" when a
record from Table B is removed, you will need to write a trigger for the
Delete event on Table B.
"Morgan" <zakirmahmood@.primposta.com> wrote in message
news:euEQE2ayDHA.2064@.TK2MSFTNGP10.phx.gbl...
> No, cascade delete works "top-to-bottom", not "bottom-to-top" meaning a
> foreign key with "on delete cascade", will only fire when A-index "1" is
> removed from Table A. What you are seeking would cause a violation of the
> foreign key because Index 2 in Table B still has reference to A-Index "2".
> If you need to remove reference to all records in Table B with A-Index
"1",
> you need to write a trigger for the Delete event.
> HTH,
> Morgan
> "Me" <anonymous@.discussions.microsoft.com> wrote in message
> news:03f001c3c9a7$952dbd30$a101280a@.phx.gbl...
> > Hello,
> >
> > A quick question about cascading deletions...
> >
> > Say I have two tables with the following data
> >
> > Table A
> > index data
> > 1 "some data"
> > 2 "some other data"
> >
> > Table B
> > index A-index data
> > 1 2 "something"
> > 2 1 "something else"
> > 3 1 "out of this world"
> >
> >
> > These tables set up to perform cascading deletions when
> > records are removed.
> >
> > My question is this: If I remove index 3 from table B,
> > will index 1 from table A be removed?
> >
> > If not, how do you get cascading deletion to work?
> >
> > Thanks
> > Me
>|||Thanks for the info !!
>--Original Message--
>Sorry this should have read..
> If you need to remove the record(s) in Table A with A-
Index "1" when a
>record from Table B is removed, you will need to write a
trigger for the
>Delete event on Table B.
>"Morgan" <zakirmahmood@.primposta.com> wrote in message
>news:euEQE2ayDHA.2064@.TK2MSFTNGP10.phx.gbl...
>> No, cascade delete works "top-to-bottom", not "bottom-
to-top" meaning a
>> foreign key with "on delete cascade", will only fire
when A-index "1" is
>> removed from Table A. What you are seeking would cause
a violation of the
>> foreign key because Index 2 in Table B still has
reference to A-Index "2".
>> If you need to remove reference to all records in Table
B with A-Index
>"1",
>> you need to write a trigger for the Delete event.
>> HTH,
>> Morgan
>> "Me" <anonymous@.discussions.microsoft.com> wrote in
message
>> news:03f001c3c9a7$952dbd30$a101280a@.phx.gbl...
>> > Hello,
>> >
>> > A quick question about cascading deletions...
>> >
>> > Say I have two tables with the following data
>> >
>> > Table A
>> > index data
>> > 1 "some data"
>> > 2 "some other data"
>> >
>> > Table B
>> > index A-index data
>> > 1 2 "something"
>> > 2 1 "something else"
>> > 3 1 "out of this world"
>> >
>> >
>> > These tables set up to perform cascading deletions
when
>> > records are removed.
>> >
>> > My question is this: If I remove index 3 from table
B,
>> > will index 1 from table A be removed?
>> >
>> > If not, how do you get cascading deletion to work?
>> >
>> > Thanks
>> > Me
>>
>
>.
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment