B_10
Tera Contributor

This needs marked as the correct answer, to give this person some credit for a spot-on answer, since this solution could be used to dynamically decide the tables available for use by the document-id field, no matter what the use case.  Nice job, this was definitely a nuanced solution.  Thank you for sharing.