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 > DB2 > deleting a foreign key

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-01-09, 15:48
emmapat emmapat is offline
Registered User
 
Join Date: Mar 2009
Posts: 8
deleting a foreign key

i have to delete a record from a table with ids and names but on this is is a foreign key to another table how can i remove that record but still exist for a future use??

actualy i have to delete a customer record this record include customer id and customer name but on this customerid (which is a foreign key to a flightbooking table) are reserved some bookings. the flightbooking include flightid , customerid , bookingid ,number of reserved seats and the status of the booking reserved , cancel or held

any help????
Reply With Quote
  #2 (permalink)  
Old 04-01-09, 22:39
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
Quote:
Originally Posted by emmapat
i have to delete a customer record
Is it that you want to delete the customer record but not his flight booking details???? Are you sure this would not introduce any inconsistency into the system bcoz in the future you wont have any customer details against that flight booking???? From what i get the db has not been defined for that....

Not a solution
Be sure you really really really really know what you are doing before you try this -
Try the other way round... delete the records from flightbooking for that cust id and then delete the customer id.... coz the way i see it you cannot just delete the customer id without cleaning up all his details in flightbooking table...
__________________
IBM Certified Database Associate, DB2 9 for LUW
Reply With Quote
  #3 (permalink)  
Old 04-02-09, 16:58
rdutton rdutton is offline
Registered User
 
Join Date: Dec 2008
Posts: 76
I agree with Nick that your description seems to leave orphaned flightbooking details.

If you want to keep this information because it should be connected to a different customer: Insert the new customer info into the parent table, update foreign key in the flightbooking table to point to the new customer, then delete the original customer.

Or just export the flightbooking info to a file to save it, delete the row in the flightbooking table, then delete the parent row. You will still have the info for future use.

Hope one of the suggestions is useful to you.
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