How should I get data from the node table?
I don't think you need an execute on a regular query like that. But the way to get any node data would be loading the node with the entityTypeManager service, and getting the field values with $node-&gt;get('field_advertiser_id')-&gt;getValue(). Its rare to have to get a value that way from the database.
The same goes for the insert or update - you definitely should be using the API for this and not direct database writes.
On top of that you don't need to do anything with the database at all in this example, because the node being deleted is already passed to this hook. Just look at its field values. https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_entity_delete/9.1.x
But in a case like this, hook_entity_delete may be too late to get values depending on what you need to do. Instead, you probably want to use hook_entity_predelete: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_entity_predelete/9.1.x
Example:
function mymodule_entity_predelete(Drupal\Core\Entity\EntityInterface $entity) {
  if ($entity instanceof NodeInterface &amp;&amp; $entity-&gt;getType() == 'your_content_type') {
    $advertiser_id = $entity-&gt;get('field_advertiser_id')-&gt;first()-&gt;getValue();
    
    // do something with id, like load that node
    if (isset($advertiser_id)) {
      $entityTypeManager = \Drupal::entityTypeManager();
      $advertiser = $entityTypeManager-&gt;getStorage('node')-&gt;load($advertiser_id);
      
      if ($advertiser instanceof NodeInterface &amp;&amp; $entity-&gt;getType() == 'advertiser_content_type') {
        // Delete this other node.
        $advertiser-&gt;delete();
      }
    }
  }
}

You have to be careful with these hooks though, because it can trigger an infinite loop since these hooks are fired every time the actions are performed. Meaning, if you wanted to delete the advertiser node here for example, this hook would get called on that action too. So you need to be specific with your conditions check each value and logic. People get caught in presave hooks all the time.