473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Regarding Delete Restrict

Hi,
I am doing a purge process and trying to delete rows .Let me know how
efficiently I can handle the purge process because of the RI on the
tables.
TABLE A is a PARENT of TABLE B, TABLE C, TABLE D. I want to purge
rows from all the tables TABLE A (Parent), TABLE B (Child), TABLE C
(Child) and TABLE D (Child).
All these tables have DELETE RESTRICT . I dont want to have the orphans
in the table.
I dont want to have the child row exist without a parent. I thought of
purging the data starting by identifying what rows need to be purged
from the PARENT and delete from the CHILD.
Is this a good approach or Is there a better way so that Performance
will not be problem too.
Let me know
Thanks

Nov 12 '05 #1
3 3705
Actually it is like TABLE B is a CHILD of TABLE A, TABLE A1, TABLE A2.
(1 CHILD with Many PARENTS)
I need to purge rows from all the Parent and Child.

Nov 12 '05 #2
razheev wrote:
Hi,
I am doing a purge process and trying to delete rows .Let me know how
efficiently I can handle the purge process because of the RI on the
tables.
TABLE A is a PARENT of TABLE B, TABLE C, TABLE D. I want to purge
rows from all the tables TABLE A (Parent), TABLE B (Child), TABLE C
(Child) and TABLE D (Child).
All these tables have DELETE RESTRICT . I dont want to have the orphans
in the table.
I dont want to have the child row exist without a parent. I thought of
purging the data starting by identifying what rows need to be purged
from the PARENT and delete from the CHILD.
Is this a good approach or Is there a better way so that Performance
will not be problem too.


Do you want to delete all the rows from the tables you mentioned? If the
answer is yes, simply truncate all tables, possibly starting at D, which
has no further dependencies.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #3
Have you really thought this out? with A, A1, A2 as parents of a common
child, what happens to other children of the parents when you go to
delete a row from the parent? Foreign keys on B mean that each of the
A(n) tables is expected to have rows with values that don't match a row
in the B table.

If each of the A(n) tables can have at most one child, then you will
have to read to B table rows to get the A(n) table values to identify
rows to delete.

Your RESTRICT rule in the foreign key definitions of table B will
prevent deleting rows from the A(n) tables as long as there is an
existing B row. You'll have to delete the B table row first, then the
matching rows from the parents.

I'd try to use an updatable cursor to retrieve the B table rows, then
use a positioned delete to delete the B table row. Use the data values
from the retrieval to delete the other parent rows.

Phil Sherman
razheev wrote:
Actually it is like TABLE B is a CHILD of TABLE A, TABLE A1, TABLE A2.
(1 CHILD with Many PARENTS)
I need to purge rows from all the Parent and Child.


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mike & Dyan | last post by:
I was able to figure out how to insert new data into my database. But for some reason and a lot of reading I can't seem to figure out how to delete any data. My app is going to be used for...
10
by: D. Dante Lorenso | last post by:
I'd like to run a clean up command on my tables to eliminate rows that I'm no longer using in the database. I want to do something like this: DELETE FROM tablename WHERE...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
0
by: Robert Fitzpatrick | last post by:
I have tblhud74b that has a foreign key to tblhudunits with Restrict Updates. I have a function that DELETEs corresponding records before doing an UPDATE right after the DELETE statement and...
12
by: ravinderthakur | last post by:
hi experts, i have few questions regarding the delete operator in c++. why does c++ have to operators for deleting memeory viz delete and delete. why cannnot delete be used insted of...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
22
by: Michael Pradel | last post by:
Hi all, I just returned to C++ after programming in other languages, and find myself a bit puzzled about the following issue: (see attached code). How can I avoid the deletion of an object...
2
by: venkat | last post by:
Hi, i came across restrict qualifier while looking the code. I haven't able to understand what does this do?. Can some one help me how does this makes the things restrict to an specified...
3
allingame
by: allingame | last post by:
Need help with append and delete duplicates I have tables namely 1)emp, 2)time and 3)payroll TABLE emp ssn text U]PK name text
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.