How to code custom entity to access more than one database table?
Entity API itself can only interact with one base table for joining to fields, querying with EntityFieldQuery, loading/saving revisions, etc, but you can use more than one table for storage if you implement your own storage controller which you can specify in your hook_entity_info().

You'll want to subclass DrupalDefaultEntityController and override the load() method and buildQuery() method if you want some EntityFieldQUery support.

If you are using Entity API module, you'll want to extend EntityAPIController and override the save(), load(), and delete() methods for full CRUD support.