EDIT: Is there a way or any methods/algorithms to find path of joins from one table to another?
Example:
I want to select first_name from person, name from country where country is Slovakia. User will only choose fields that he wants to select and I need some kind of algorithm that will find out that I need to join from person to city to country.