The most simple way to do it:
in  class Table.A have 
       Property TableB as Table.B;
in  class Table.B have
                  Property TableA as Table.A;

in your code it may look like this:

set objA=##class(Table.A).%OpenId(212)
set objB=##class(Table.B).%OpenId(99)
set objA.TableB=objB
set objB.TableA=objA
do objA.%Save(), objB.%Save()

You are free to index properties TableA or TableB according to your needs
and you can also use Implicit JOIN between these tables.