How to restrict a page to a group of people?
You can add the secondary database to Drupal by following this tutorial: https://www.drupal.org/node/18429

I would probably run a hook_node_view so that it's called before rendering the node and adding your custom logic there.