implement code for choosing the correct database according to the selectSubject filed