trigger realtedaccounttrigger on Account (before delete){ if(Trigger.isbefore&&Trigger.Isdelete) { List<contact>lstcontacts=[select id,firstname,lastname,accountid from contact where accountid IN:Trigger.oldmap.keyset()]; if(!lstcontacts.isempty()) { for(contact con :lstcontacts) { con.accountid=null; } update lstcontacts; } }}this code is for deletion for the related contact record .if we want related contact record also can u give me that code