def referenced_tables(tables)
rows = self.select_all("select distinct table_name as referencing_table, referenced_table_name as referenced_table\nfrom information_schema.key_column_usage\nwhere table_schema = database()\nand table_name in ('\#{tables.join(\"', '\")}')\n")
result = {}
rows.each do |row|
unless result.include? row['referencing_table']
result[row['referencing_table']] = []
end
if row['referenced_table'] != nil
result[row['referencing_table']] << row['referenced_table']
end
end
tables.each do |table|
result[table] = [] unless result.include? table
end
result
end