Properly handle foreign keys in layers_user_tables relation