What hook to use to update history table
You are looking for the node_tag_new() core function.

function node_tag_new($node) {
  global $user;
  if ($user-&gt;uid) {
    db_merge('history')-&gt;key(array(
      'uid' =&gt; $user-&gt;uid,
      'nid' =&gt; $node-&gt;nid,
    ))-&gt;fields(array('timestamp' =&gt; REQUEST_TIME))-&gt;execute();
  }
}


Normally you'd just pass the full node object to the function, but if you only have the nid, you can just pass a dummy object.

$node = new stdClass();
$node-&gt;nide = 1234;
node_tag_new($node);


Modifying the OP's own answer, this would be:

function answers_exit() {
  $router_item  = menu_get_object();
  if (isset($router_item) &amp;&amp; $router_item-&gt;type == "answers_question") {
    if ($user-&gt;uid) {
      $results = db_select('field_data_answers_related_question', 'rq')
        -&gt;fields('rq', array('entity_id'))
        -&gt;condition('answers_related_question_target_id', $router_item-&gt;nid)
        -&gt;execute();
      foreach($results as $row) {
        $node = new stdClass();
        $node-&gt;nid = $row-&gt;entity_id;
        node_tag_new($node);
      }
    }
  }
}


However you should probably be using EntityFieldQuery since it will handle all all the specifics about which tables/columns to use:

function answers_exit() {
  $router_item  = menu_get_object();
  if (isset($router_item) &amp;&amp; $router_item-&gt;type == "answers_question") {
    $query = new EntityFieldQuery();
    $query-&gt;entityCondition('entity_type', 'node')
          -&gt;entityCondition('bundle', 'answers')
          -&gt;fieldCondition('answers_related_question', 'target_id', $router_item-&gt;nid);
    $result = $query-&gt;execute();
    if (isset($result['node'])) {
      foreach ($result['node'] as $answer) {
        node_tag_new($answer);
      }
    }
}