Hello Better than a long speech, here are two files (eagerloading1.py, eagerloading2.py) which, I though, were supposed to do the same thing. Indeed, the difference is that in the first file, the polymorphic_identity is hard coded and in the second file, it is set dynamically afterward (like explained in http://stackoverflow.com/questions/15112340/how-can-i-set-polymorphic-identity-after-a-class-is-defined).
The result is that both files trigger the query to get all the taxa. However, the second file also triggers a new query each time there is an access to the referenced_taxon, which is supposed to be loaded already and of course, that query in a loop ruins the performances. So my question is, how can set the polymorphic_identity dynamically and still avoid the new queries in the loop? I also provided some the SLQ commands to quickly reproduce the results (test-data.sql). Tests have been performed with SQLAlchemy==0.8.2 -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.
# -*- coding: utf-8 -*- from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() _rank_table = Table('rank', Base.metadata, Column('id', Integer, primary_key=True), Column('label', String) ) _taxon_table = Table('taxon', Base.metadata, Column('id', Integer, primary_key=True), Column('refno', Integer, server_default=FetchedValue()), Column('rank_id', Integer), ForeignKeyConstraint(['rank_id'], ['rank.id']) ) _relationshiptype_table = Table('relationshiptype', Base.metadata, Column('id', Integer, primary_key=True), Column('label', String) ) _taxon_relationship_table = Table('taxon_relationship', Base.metadata, Column('taxon_id', Integer, primary_key=True), Column('referenced_taxon_id', Integer, primary_key=True), Column('relationshiptype_id', Integer, primary_key=True), ForeignKeyConstraint(['taxon_id'], ['taxon.id']), ForeignKeyConstraint(['referenced_taxon_id'], ['taxon.id']), ForeignKeyConstraint(['relationshiptype_id'], ['relationshiptype.id']) ) class Rank(Base): __table__ = _rank_table class Taxon(Base): __table__ = _taxon_table __mapper_args__ = { 'polymorphic_on': 'rank_id', } rank = relationship('Rank', innerjoin=True, backref=backref('taxa')) class Family(Taxon): __mapper_args__ = { 'polymorphic_identity':-2147483640, } class Genus(Taxon): __mapper_args__ = { 'polymorphic_identity':-2147483636, } class Species(Taxon): __mapper_args__ = { 'polymorphic_identity':-2147483630, } class Subspecies(Taxon): __mapper_args__ = { 'polymorphic_identity':-2147483629, } class Variety(Taxon): __mapper_args__ = { 'polymorphic_identity':-2147483628, } class Form(Taxon): __mapper_args__ = { 'polymorphic_identity':-2147483626, } class Cultivar(Taxon): __mapper_args__ = { 'polymorphic_identity':-2147483624, } class Group(Taxon): __mapper_args__ = { 'polymorphic_identity':-2147483623, } class Relationshiptype(Base): __table__ = _relationshiptype_table class TaxonRelationship(Base): __table__ = _taxon_relationship_table relationship_type = relationship('Relationshiptype', innerjoin=True, backref=backref('relationships')) taxon = relationship('Taxon', innerjoin=True, primaryjoin='Taxon.id==TaxonRelationship.taxon_id', backref=backref('relationships', cascade='all, delete-orphan', passive_deletes=True)) referenced_taxon = relationship('Taxon', innerjoin=True, primaryjoin='Taxon.id==TaxonRelationship.referenced_taxon_id', backref=backref('referenced_relationships')) if __name__ == '__main__': # Initialization engine = create_engine('postgresql://nurseryacme@localhost:5432/testdatabase') Session = sessionmaker(bind=engine) session = Session() # Load instances taxa = session.query(Taxon).\ options(joinedload(Taxon.relationships)).\ order_by(Taxon.refno).\ all() # Try to see if load has worked for taxon in taxa: print "Taxon (refno)=(%d)" % taxon.refno for relationship in taxon.relationships: # The below line does not fire any other query print "\tlinked taxon (refno)=(%d)" % relationship.referenced_taxon.refno
# -*- coding: utf-8 -*- from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() _rank_table = Table('rank', Base.metadata, Column('id', Integer, primary_key=True), Column('label', String) ) _taxon_table = Table('taxon', Base.metadata, Column('id', Integer, primary_key=True), Column('refno', Integer, server_default=FetchedValue()), Column('rank_id', Integer), ForeignKeyConstraint(['rank_id'], ['rank.id']) ) _relationshiptype_table = Table('relationshiptype', Base.metadata, Column('id', Integer, primary_key=True), Column('label', String) ) _taxon_relationship_table = Table('taxon_relationship', Base.metadata, Column('taxon_id', Integer, primary_key=True), Column('referenced_taxon_id', Integer, primary_key=True), Column('relationshiptype_id', Integer, primary_key=True), ForeignKeyConstraint(['taxon_id'], ['taxon.id']), ForeignKeyConstraint(['referenced_taxon_id'], ['taxon.id']), ForeignKeyConstraint(['relationshiptype_id'], ['relationshiptype.id']) ) class Rank(Base): __table__ = _rank_table class Taxon(Base): __table__ = _taxon_table __mapper_args__ = { 'polymorphic_on': 'rank_id', } rank = relationship('Rank', innerjoin=True, backref=backref('taxa')) class Family(Taxon): pass class Genus(Taxon): pass class Species(Taxon): pass class Subspecies(Taxon): pass class Variety(Taxon): pass class Form(Taxon): pass class Cultivar(Taxon): pass class Group(Taxon): pass class Relationshiptype(Base): __table__ = _relationshiptype_table class TaxonRelationship(Base): __table__ = _taxon_relationship_table relationship_type = relationship('Relationshiptype', innerjoin=True, backref=backref('relationships')) taxon = relationship('Taxon', innerjoin=True, primaryjoin='Taxon.id==TaxonRelationship.taxon_id', backref=backref('relationships', cascade='all, delete-orphan', passive_deletes=True)) referenced_taxon = relationship('Taxon', innerjoin=True, primaryjoin='Taxon.id==TaxonRelationship.referenced_taxon_id', backref=backref('referenced_relationships')) def _set_polymorphic_identity(subclass, identity): # http://stackoverflow.com/questions/15112340/how-can-i-set-polymorphic-identity-after-a-class-is-defined mapper = class_mapper(subclass) mapper.polymorphic_identity = identity mapper.polymorphic_map[identity] = mapper def initialize_polymorphic_identity(session): ranks = session.query(Rank).all() def get_rank_id(label): found_rank = None for rank in ranks: if rank.label == label: found_rank = rank break if not found_rank: raise Exception("No rank with label '" + label + "' has been found!") return found_rank.id def set_rank_identity(subclass, label): _set_polymorphic_identity(subclass, get_rank_id(label)) set_rank_identity(Family, 'family') set_rank_identity(Genus, 'genus') set_rank_identity(Species, 'species') set_rank_identity(Subspecies, 'subspecies') set_rank_identity(Variety, 'variety') set_rank_identity(Form, 'form') set_rank_identity(Cultivar, 'cultivar') set_rank_identity(Group, 'group') if __name__ == '__main__': # Initialization engine = create_engine('postgresql://nurseryacme@localhost:5432/testdatabase') Session = sessionmaker(bind=engine) session = Session() # Initialization polymorphic_identity initialize_polymorphic_identity(session) # Load instances taxa = session.query(Taxon).\ options(joinedload(Taxon.relationships)).\ order_by(Taxon.refno).\ all() # Try to see if load has worked for taxon in taxa: print "Taxon (refno)=(%d)" % taxon.refno for relationship in taxon.relationships: # The below line fires a query to retrieve a Taxon print "\tlinked taxon (refno)=(%d)" % relationship.referenced_taxon.refno
CREATE TABLE rank ( id int NOT NULL, label varchar(32) NOT NULL, CONSTRAINT pk_rank PRIMARY KEY (id), CONSTRAINT ak_rank_1 UNIQUE (label) ); CREATE TABLE taxon ( id int NOT NULL, refno int NOT NULL, rank_id int NOT NULL, CONSTRAINT pk_taxon PRIMARY KEY (id), CONSTRAINT ak_taxon_1 UNIQUE (refno), CONSTRAINT fk_taxon_rank_1 FOREIGN KEY (rank_id) REFERENCES rank (id) MATCH FULL ON UPDATE CASCADE ON DELETE RESTRICT ); CREATE TABLE relationshiptype ( id int NOT NULL, label varchar(32) NOT NULL, CONSTRAINT pk_relationshiptype PRIMARY KEY (id), CONSTRAINT ak_relationshiptype_1 UNIQUE (label) ); CREATE TABLE taxon_relationship ( taxon_id int NOT NULL, referenced_taxon_id int NOT NULL, relationshiptype_id int NOT NULL, CONSTRAINT pk_taxon_relationship PRIMARY KEY (taxon_id, referenced_taxon_id, relationshiptype_id), CONSTRAINT fk_taxon_relationship_taxon_1 FOREIGN KEY (taxon_id) REFERENCES taxon (id) MATCH FULL ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT fk_taxon_relationship_taxon_2 FOREIGN KEY (referenced_taxon_id) REFERENCES taxon (id) MATCH FULL ON UPDATE CASCADE ON DELETE RESTRICT, CONSTRAINT fk_taxon_relationship_relationshiptype_1 FOREIGN KEY (relationshiptype_id) REFERENCES relationshiptype (id) MATCH FULL ON UPDATE CASCADE ON DELETE RESTRICT ); INSERT INTO rank (id, label) VALUES (-2147483648, 'kingdom'); INSERT INTO rank (id, label) VALUES (-2147483647, 'subkingdom'); INSERT INTO rank (id, label) VALUES (-2147483646, 'division'); INSERT INTO rank (id, label) VALUES (-2147483645, 'subdivision'); INSERT INTO rank (id, label) VALUES (-2147483644, 'class'); INSERT INTO rank (id, label) VALUES (-2147483643, 'subclass'); INSERT INTO rank (id, label) VALUES (-2147483642, 'order'); INSERT INTO rank (id, label) VALUES (-2147483641, 'suborder'); INSERT INTO rank (id, label) VALUES (-2147483640, 'family'); INSERT INTO rank (id, label) VALUES (-2147483639, 'subfamily'); INSERT INTO rank (id, label) VALUES (-2147483638, 'tribe'); INSERT INTO rank (id, label) VALUES (-2147483637, 'subtribe'); INSERT INTO rank (id, label) VALUES (-2147483636, 'genus'); INSERT INTO rank (id, label) VALUES (-2147483635, 'subgenus'); INSERT INTO rank (id, label) VALUES (-2147483634, 'section'); INSERT INTO rank (id, label) VALUES (-2147483633, 'subsection'); INSERT INTO rank (id, label) VALUES (-2147483632, 'series'); INSERT INTO rank (id, label) VALUES (-2147483631, 'subseries'); INSERT INTO rank (id, label) VALUES (-2147483630, 'species'); INSERT INTO rank (id, label) VALUES (-2147483629, 'subspecies'); INSERT INTO rank (id, label) VALUES (-2147483628, 'variety'); INSERT INTO rank (id, label) VALUES (-2147483627, 'subvariety'); INSERT INTO rank (id, label) VALUES (-2147483626, 'form'); INSERT INTO rank (id, label) VALUES (-2147483625, 'subform'); INSERT INTO rank (id, label) VALUES (-2147483624, 'cultivar'); INSERT INTO rank (id, label) VALUES (-2147483623, 'group'); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483648, 1, -2147483640); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483647, 2, -2147483636); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483646, 3, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483645, 4, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483644, 5, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483643, 6, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483642, 7, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483641, 8, -2147483623); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483640, 9, -2147483636); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483639, 10, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483638, 11, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483637, 12, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483636, 13, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483635, 14, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483634, 15, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483633, 16, -2147483640); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483632, 17, -2147483636); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483631, 18, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483630, 19, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483629, 20, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483628, 21, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483627, 22, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483626, 23, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483625, 24, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483624, 25, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483623, 26, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483622, 27, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483621, 28, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483620, 29, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483619, 30, -2147483640); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483618, 31, -2147483636); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483617, 32, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483616, 33, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483615, 34, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483614, 35, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483613, 36, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483612, 37, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483611, 38, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483610, 39, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483609, 40, -2147483640); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483608, 41, -2147483636); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483607, 42, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483606, 43, -2147483628); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483605, 44, -2147483624); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483604, 45, -2147483623); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483603, 46, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483602, 47, -2147483628); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483601, 48, -2147483640); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483600, 49, -2147483636); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483599, 50, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483598, 51, -2147483629); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483597, 52, -2147483636); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483596, 53, -2147483630); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483595, 54, -2147483628); INSERT INTO taxon (id, refno, rank_id) VALUES (-2147483594, 55, -2147483626); INSERT INTO relationshiptype (id, label) VALUES (-2147483648, 'taxonomic_classification'); INSERT INTO relationshiptype (id, label) VALUES (-2147483647, 'group_inclusion'); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483647, -2147483648, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483646, -2147483647, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483645, -2147483646, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483644, -2147483646, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483643, -2147483646, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483642, -2147483646, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483641, -2147483646, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483640, -2147483648, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483639, -2147483640, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483638, -2147483640, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483637, -2147483640, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483636, -2147483640, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483635, -2147483640, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483634, -2147483640, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483632, -2147483633, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483631, -2147483632, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483630, -2147483631, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483629, -2147483631, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483628, -2147483631, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483627, -2147483631, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483626, -2147483632, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483625, -2147483632, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483624, -2147483625, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483623, -2147483625, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483622, -2147483632, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483621, -2147483622, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483620, -2147483622, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483618, -2147483619, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483617, -2147483618, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483616, -2147483617, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483615, -2147483617, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483614, -2147483617, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483613, -2147483618, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483612, -2147483613, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483611, -2147483618, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483610, -2147483618, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483608, -2147483609, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483607, -2147483608, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483606, -2147483607, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483605, -2147483606, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483604, -2147483646, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483603, -2147483608, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483602, -2147483646, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483600, -2147483601, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483599, -2147483600, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483598, -2147483599, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483597, -2147483648, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483596, -2147483597, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483595, -2147483596, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483594, -2147483595, -2147483648); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483645, -2147483641, -2147483647); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483644, -2147483641, -2147483647); INSERT INTO taxon_relationship (taxon_id, referenced_taxon_id, relationshiptype_id) VALUES (-2147483643, -2147483641, -2147483647);