Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deleting rows with referential integrity

 
Judy Collins
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I need to delete specific records from database (e.g. those whose expirydate column has date greater than that of today). At least 10 other tables have reference to this master table and then each of the 10 tables are referenced by other tables. ( i guess you understand what i m trying to say :roll: )

Is there any option available except figuring out all of the tables and then deleting the records?

I am sure there must be some better way.

Any help in this regard is greatly appreciaed
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will recommend to have one additional column as enable/disable flag, and whenever you dont need record simple disable them(Soft delete)

otherwise you can delete them by cascading constraints, I do this in oracle somtimes but NOT recommended.



what about child record ? dont you want to delete them ?
 
Judy Collins
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shailesh Chandra
Thaks for your response. I modified schema and added constraint "on delete cascade" and it appears to be fine. Can you please tell me why don't you recommend cascade?

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic