Here is some sample code that we usually use in triggers:
Set<Id> accountIds=new Set<Id> ();
//Prepare a set of all related account that are coming to key trigger
// Prepare a map that maps account id to Account Record. In SOQL put all fields that you may require for your logic
Map<Id,Account> accountMap=new Map<Id,Account> ([Select id,name from Account where id in :accountIds]);
// here onwards you have key and it's related record. So put your trigger logic here
I hope that helps.Please note that this is just one way of doing things, there could be alternative approaches as well.