anchor.diff:      | None -> ()
       ignore <| x.tables.Add tname
   
  -  member x.ResolveTable (t:string) =
  -    let t = normalizeTablename t
  -    if x.tables.Contains t then Some t
  -    else 
  -      let ok, v = x.aliasToTable.TryGetValue t
  -      if ok then Some(v) else None
  +  member x.ResolveTableForCol (col:string) =
  +    let tables = 
  +      [ for t in x.tables do
  +          if columnsByTable.Value.[t].Contains(col) then yield t ]
  +    match tables with
  +    | [t] -> Some(t)
  +    | xs -> None
  +
  +  member x.ResolveTable (t:string list) =
  +    match t with
  +    | [t; _] ->
  +      let t = normalizeTablename t
  +      if x.tables.Contains t then Some t
  +      else 
  +        let ok, v = x.aliasToTable.TryGetValue t
  +        if ok then Some(v) else None
  +    | [c] ->
  +      x.ResolveTableForCol c
  +    | xs ->
  +      printfn "Can't resolve table for %A" xs
  +      None
   
     member x.AddJoinedTablesOrAliases t1 t2 =
       match ((x.ResolveTable t1), (x.ResolveTable t2)) with
  -    | Some a, Some b -> ignore <| x.condConnections.Add (a, b)
  +    | Some a, Some b ->
  +      let t1 = [a; List.last t1]
  +      let t2 = [b; List.last t2]
  +      let lhs = String.concat "." t1
  +      let rhs = String.concat "." t2
  +      let (lhs, rhs) =
  +        if a < b then (lhs, rhs) else (rhs, lhs)
  +
  +      let (a, b) = if a < b then a, b else b, a
  +      printfn "CONNECT %A = %A" t1 t2
  +      ignore <| x.condConnections.Add (a, b, sprintf "%s = %s" lhs rhs)
       | _, _ -> ()
   
     member x.AddConditions(bexpr:BooleanExpression) =
  
positive.code: </html>
    """
  
  let visualize (rels:Set<string*string>) =
    let script =
      let mutable nextId = 0
      let ids = Dictionary<string, int>()
  
negative.code:   printfn "Result: %A" realTables
    let relationships = 
      relationships 
      |> Seq.filter (fun (a, b, _) -> (realTables.Contains a) && (realTables.Contains b))
      |> Set.ofSeq
    printfn "Result: %A" relationships
    visualize relationships
  
  
      
  do run()    
  
  
  