get_inbound_relation_opts = async (source, viewname, cache) => {
  const { tableIdCache, fieldCache } = cache ? cache : await tableFieldCache();
  const allTables = await Table.find({}, { cached: true });
  const result = [];
  const search = async (table, path, rootTable, visited) => {
    const visitedCopy = new Set(visited);
    const suffixes = await get_inbound_path_suffixes(
      table,
      source,
      path,
      tableIdCache,
      fieldCache
    );
    if (suffixes.length > 0) {
      const views = await View.find_table_views_where(
        rootTable.id,
        ({ state_fields, viewrow }) =>
          viewrow.name !== viewname &&
          !state_fields.some((sf) => sf.name === "id")
      );
      for (const suffix of suffixes) {
        result.push({ path: suffix, views });
      }
    }
    if (!visitedCopy.has(table.name)) {
      visitedCopy.add(table.name);
      for (const inboundFk of fieldCache[table.name] || []) {
        if (inboundFk.table_id === table.id) continue;
        const inboundTbl = tableIdCache[inboundFk.table_id];
        await search(
          inboundTbl,
          [{ tbl: inboundTbl.name, fk: inboundFk.name }, ...path],
          rootTable,
          visitedCopy
        );
      }
    }
  };
  // search in reverse,
  // start with the target (table of the subview) to the relation source
  for (const table of allTables) {
    const visited = new Set();
    await search(table, [], table, visited);
  }
  return result;
}
search for relations where an in select to source is possible
@param {Table} source
@param {string} viewname
@returns