+
+
+### Relations down here, to avoid ordering problems
+Encounter.pokemon = relation(Pokemon, backref='encounters')
+Encounter.version = relation(Version, backref='encounters')
+Encounter.location_area = relation(LocationArea, backref='encounters')
+Encounter.slot = relation(EncounterTypeSlot, backref='encounters')
+Encounter.condition = relation(EncounterCondition, backref='encounters')
+
+EncounterCondition.group = relation(EncounterConditionGroup,
+ backref='conditions')
+
+EncounterTypeSlot.type = relation(EncounterType, backref='slots')
+
+EvolutionChain.growth_rate = relation(GrowthRate, backref='evolution_chains')
+
+Generation.versions = relation(Version, secondary=VersionGroup.__table__)
+
+LocationArea.location = relation(Location, backref='areas')
+
+Machine.generation = relation(Generation)
+
+Move.damage_class = relation(MoveDamageClass, backref='moves')
+Move.flags = association_proxy('move_flags', 'flag')
+Move.foreign_names = relation(MoveName, backref='pokemon')
+Move.generation = relation(Generation, backref='moves')
+Move.machines = relation(Machine, backref='move')
+Move.move_effect = relation(MoveEffect, backref='moves')
+Move.move_flags = relation(MoveFlag, backref='move')
+Move.target = relation(MoveTarget, backref='moves')
+Move.type = relation(Type, backref='moves')
+
+Move.effect = rst.MoveEffectProperty('effect')
+Move.priority = association_proxy('move_effect', 'priority')
+Move.short_effect = rst.MoveEffectProperty('short_effect')
+
+MoveFlag.flag = relation(MoveFlagType)
+
+MoveName.language = relation(Language)
+
+Pokemon.abilities = relation(Ability, secondary=PokemonAbility.__table__,
+ order_by=PokemonAbility.slot,
+ backref='pokemon')
+Pokemon.formes = relation(Pokemon, primaryjoin=Pokemon.id==Pokemon.forme_base_pokemon_id,
+ backref=backref('forme_base_pokemon',
+ remote_side=[Pokemon.id]))
+Pokemon.dex_numbers = relation(PokemonDexNumber, backref='pokemon')
+Pokemon.egg_groups = relation(EggGroup, secondary=PokemonEggGroup.__table__,
+ order_by=PokemonEggGroup.egg_group_id,
+ backref='pokemon')
+Pokemon.evolution_chain = relation(EvolutionChain, backref='pokemon')
+Pokemon.evolution_method = relation(EvolutionMethod)
+Pokemon.evolution_children = relation(Pokemon, primaryjoin=Pokemon.id==Pokemon.evolution_parent_pokemon_id,
+ backref=backref('evolution_parent',
+ remote_side=[Pokemon.id]))
+Pokemon.flavor_text = relation(PokemonFlavorText, backref='pokemon')
+Pokemon.foreign_names = relation(PokemonName, backref='pokemon')
+Pokemon.items = relation(PokemonItem)
+Pokemon.generation = relation(Generation, backref='pokemon')
+Pokemon.shape = relation(PokemonShape, backref='pokemon')
+Pokemon.stats = relation(PokemonStat, backref='pokemon')
+Pokemon.types = relation(Type, secondary=PokemonType.__table__)
+
+PokemonDexNumber.generation = relation(Generation)
+
+PokemonFlavorText.version = relation(Version)
+
+PokemonItem.item = relation(Item, backref='pokemon')
+PokemonItem.version = relation(Version)
+
+PokemonFormGroup.pokemon = relation(Pokemon, backref=backref('form_group',
+ uselist=False))
+PokemonFormSprite.pokemon = relation(Pokemon, backref='form_sprites')
+
+PokemonMove.pokemon = relation(Pokemon, backref='pokemon_moves')
+PokemonMove.version_group = relation(VersionGroup)
+PokemonMove.move = relation(Move, backref='pokemon_moves')
+PokemonMove.method = relation(PokemonMoveMethod)
+
+PokemonName.language = relation(Language)
+
+PokemonStat.stat = relation(Stat)
+
+Type.damage_efficacies = relation(TypeEfficacy,
+ primaryjoin=Type.id
+ ==TypeEfficacy.damage_type_id,
+ backref='damage_type')
+Type.target_efficacies = relation(TypeEfficacy,
+ primaryjoin=Type.id
+ ==TypeEfficacy.target_type_id,
+ backref='target_type')
+
+Version.version_group = relation(VersionGroup, backref='versions')
+Version.generation = association_proxy('version_group', 'generation')
+
+VersionGroup.generation = relation(Generation, backref='version_groups')