delete related records
am 21.11.2005 19:04:00 von fmatosic
In my database i have a table that contains topics and it is related to
another table which contains subtopics. What i have to do is delete a record
in the topics but i allso have to delete the related records in the sub
topics (as they are related). Is there a easier way to do this then having
to first delete the subtopics and then delete the topics records?
Re: delete related records
am 21.11.2005 19:08:58 von The Mighty Chaffinch
polilop wrote:
> In my database i have a table that contains topics and it is related to
> another table which contains subtopics. What i have to do is delete a record
> in the topics but i allso have to delete the related records in the sub
> topics (as they are related). Is there a easier way to do this then having
> to first delete the subtopics and then delete the topics records?
Use foreign keys to enforce referential integrity, if your DBMS supports
this.
MC
Re: delete related records
am 21.11.2005 21:05:18 von fmatosic
They use foreign keys to enforce referential integrity, thats why i cannot
delete a record from table topics if it has a record in the table subtopic ,
becouse subtopic contains the foreign key topics. But what i have to do is
delete a record from topics table and allso if it has a subtopic, delete it
allso. Is there a way to delete them both without having to delete the
record from the subtopic and then delete the related topic record???
"Mighty Chaffinch" wrote in message
news:%232xejas7FHA.2384@TK2MSFTNGP12.phx.gbl...
> polilop wrote:
>> In my database i have a table that contains topics and it is related to
>> another table which contains subtopics. What i have to do is delete a
>> record in the topics but i allso have to delete the related records in
>> the sub topics (as they are related). Is there a easier way to do this
>> then having to first delete the subtopics and then delete the topics
>> records?
>
> Use foreign keys to enforce referential integrity, if your DBMS supports
> this.
>
> MC
Re: delete related records
am 22.11.2005 01:53:01 von Bob Lehmann
Set up the relationships to do Cascading Deletes. But, be careful.
Bob Lehmann
"polilop" wrote in message
news:ejkgmbt7FHA.1188@TK2MSFTNGP12.phx.gbl...
> They use foreign keys to enforce referential integrity, thats why i cannot
> delete a record from table topics if it has a record in the table subtopic
,
> becouse subtopic contains the foreign key topics. But what i have to do is
> delete a record from topics table and allso if it has a subtopic, delete
it
> allso. Is there a way to delete them both without having to delete the
> record from the subtopic and then delete the related topic record???
>
>
>
> "Mighty Chaffinch" wrote in message
> news:%232xejas7FHA.2384@TK2MSFTNGP12.phx.gbl...
> > polilop wrote:
> >> In my database i have a table that contains topics and it is related to
> >> another table which contains subtopics. What i have to do is delete a
> >> record in the topics but i allso have to delete the related records in
> >> the sub topics (as they are related). Is there a easier way to do this
> >> then having to first delete the subtopics and then delete the topics
> >> records?
> >
> > Use foreign keys to enforce referential integrity, if your DBMS supports
> > this.
> >
> > MC
>
>