Drupal field that get db content
This sounds like something you can handle pretty easily with a couple of contrib modules:


If you don't already have them install Views and Entity Reference.
Add a View of type "Content", filtered by content type B. Call it something like "All type B content".
Add an "Entity Reference" display to the new View.
Add any sorting/filtering options and change the display field if required.
Repeat steps 2-4 for a new view called "All type A content", and filter by content type A instead.
Add a new field to content type A of type "Entity Reference".
On the field settings page under "Entity Selection" choose Views: filter by an entity reference view for the mode, choose the "All type B content" View, and save the rest of the field config as normal.
Repeat steps 6-8 for content type B, choosing the "All type A content" View instead.


That should get you exactly what you're looking for, with the added benefit of being able to customise the results easily with Views.