title: how do simple SQLAlchemy relationships work?
body: <p>I'm no database expert -- I just know the basics, really. I've picked up SQLAlchemy for a small project, and I'm using the declarative base configuration rather than the "normal" way. This way seems a lot simpler.</p>
  
  <p>However, while setting up my database schema, I realized I don't understand some database relationship concepts.</p>
  
  <p>If I had a many-to-one relationship before, for example, articles by authors (where each article could be written by only a single author), I would put an <code>author_id</code> field in my <code>articles</code> column. But SQLAlchemy has this ForeignKey object, and a relationship function with a backref kwarg, and I have no idea what any of it MEANS.</p>
  
  <p>I'm scared to find out what a many-to-many relationship with an intermediate table looks like (when I need additional data about each relationship).</p>
  
  <p>Can someone demystify this for me? Right now I'm setting up to allow openID auth for my application. So I've got this:</p>
  
  <pre><code>from __init__ import Base
  from sqlalchemy.schema import Column
  from sqlalchemy.types import Integer, String
  
  class Users(Base):
      __tablename__ = 'users'
      id = Column(Integer, primary_key=True)
      username = Column(String, unique=True)
      email = Column(String)
      password = Column(String)
      salt = Column(String)
  
  
  class OpenID(Base):
      __tablename__ = 'openid'
      url = Column(String, primary_key=True)
      user_id = #?
  </code></pre>
  
  <p>I think the <code>?</code> should be replaced by <code>Column(Integer, ForeignKey('users.id'))</code>, but I'm not sure -- and do I need to put <code>openids = relationship("OpenID", backref="users")</code> in the Users class? Why? What does it do? What is a backref?</p>