Is there a good way to determine which database table are associated with each module? I have been installing and uninstalling modules on my site and I am starting to run into problems involving re installing previously disabled modules.  The install script is finding old database tables from previous module installations and is refusing to install.  For some of these modules, there is no 'uninstall' option.  Is there a good way to determine which database table are associated with each module?  I'm looking for a method of discovery or an online list.
I am unaware of an automated way to check for orphaned tables.  Before the Schema API was rolled out in Drupal 7, people would use the Schema module.  This had a hook_requirements() in it that would do this check and list orphaned tables on the status report.

You could make your own automated test.  The procedure would be something like


Do a SHOW TABLES query to get the list of all of the tables.
Query the {system} table to get a list of all modules, both enabled and disabled
Loop through the modules, and then use drupal_get_schema_unprocessed() to get the module's schema.  From this, build up a list of tables.
Do an array difference between the list you just built and the list from SHOW TABLES.  This should be all tables that aren't owned by a module that is enabled or disabled.


Something like this:

$alltables = db_query('SHOW TABLES')-&gt;fetchCol();

$modules = db_query("SELECT name FROM {system} WHERE type = 'module'")-&gt;fetchCol();

$accountedfor = array();

foreach ($modules as $module) {
  $schema = drupal_get_schema_unprocessed($module);

  if (!empty($schema)) {
    $accountedfor = array_merge($accountedfor, array_keys($schema));
  }
}

// tables not accounted for by hook_schema() from enabled and disabled modules

$orphaned = array_diff($alltables, $accountedfor);


This ignore the intricacies of table prefixes, multiple catalogs, and sharing catalogs between applications.

Use at your own risk.