If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Delete query to delete records from multiple tables having many-to-one relation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-10-10, 02:42
vptayde vptayde is offline
Registered User
 
Join Date: May 2010
Posts: 6
Delete query to delete records from multiple tables having many-to-one relation

Hi,

I have 4 table,
1. t_Config - PK_Conf_id -> FK_Link_id, FK_int_id, FK_Coi_id
2. t_link - PK_Link_id -> FK_Conf_id
3. t_int_link - PK_int_id ->FK_Conf_id, FK_Link_id,
4. t_coi_link - PK_Coi_id -> FK_Conf_id, FK_int_id


PK - Primary Key
FK - Foreign Key

first table t_Config having foreign key from all other 3 tables
and other three tables have foreign key from first table
All foreign keys from above tables allow null value
t_Config table is main table, Its having atleast one foreign key value present.
From other three tables at least one should have record with FK_Conf_id value from t_Config table.

I am not able to delete it individualy, How I can delete records from above tables?

Please help.

Thanks,
Vikas Tayde
Reply With Quote
  #2 (permalink)  
Old 06-18-10, 08:17
agrawal.meet agrawal.meet is offline
Registered User
 
Join Date: Jun 2010
Posts: 51
1. Drop foreign key (FK_Conf_id) constraint first from the last 3 tables.
2. Delete rows from 1st table and then delete same rows from other 3 tables.

That should solve the problem

Thanks,
Meet
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On