Deleting Related Records

The delete operation supports cascading deletions. If you delete a parent object, you delete its children automatically, as long as each child record can be deleted.

For example, deleting the account you created earlier (SFDC Account) will delete its related contact too.
Execute this snippet in the Anonymous Apex window of the Developer Console.

Account[] queriedAccounts = [
SELECT Id
FROM Account 
WHERE Name='SFDC Account'
];
delete queriedAccounts;

Check the accounts and contacts in your org.
You’ll see that both the account and its related contact were deleted.

Yeshas K