title: SQLAlchemy one-to-one relation, primary as foreign key
body: <p>I am mapping classes to existed MySQL tables generated by Drupal. I need to relate to tables(one-to-one), but I've got  a problem. Two tables have the column nid. Both fields are primary keys. I can not define foreign key without a primary key. And relation map is not applied to a primary key. My version is below.</p>
  
  <pre><code>class Node(Base):
      __tablename__ = 'node'
      nid = Column(Integer, primary_key=True)
      vid = Column(Integer)
      uuid = Column(String(128))
      type = Column(String)
  
      field_data = relationship("NodeFieldData", order_by="NodeFieldData.nid", backref="node")
  
      def __repr__(self):
          return "&lt;User(nid='%s', vid='%s', uuid='%s', type='%s')&gt;" % (self.nid, self.vid, self.uuid, self.type)
  
  class NodeFieldData(Base):
      __tablename__ = 'node_field_data'
      nid = Column(Integer, primary_key=True)
      type = Column(String, nullable=False)
      title = Column(String, nullable=False)
      #nid = Column(Integer, ForeignKey('Node.nid'))
  
      def __repr__(self):
          return "&lt;User(nid='%s', vid='%s', uuid='%s', type='%s')&gt;" % (self.nid, self.vid, self.uuid, self.type)
  </code></pre>
  
  <p>Thank you.</p>