Table relationships

Does anybody know - is it possible to create relations between two tables from code (not from AOT)?

You could use TreeNode class to achieve this. Check in Dev Help for info on how to use the class.