Hi,
I have 3 tables and I'm concerned about possible issues with foreign key
relations and how they might impact my code and its behavior. Maybe there's a
circular reference issue or other concern I should know about with the tables
below?
A player and a song are both created separately and associated with a client.
class Client(Base):
__tablename__ = 'client'
id = Column(Integer, primary_key=True)
class Player(Base):
__tablename__ = 'player'
id = Column(Integer, primary_key=True)
clientid = Column(Integer, ForeignKey('client.id'), nullable=False,
index=True)
client = relationship('Client', lazy='select')
class Song(Base):
__tablename__ = 'song'
id = Column(Integer, primary_key=True)
clientid = Column(Integer, ForeignKey('client.id'), nullable=False,
index=True)
client = relationship('Client', lazy='select')
name = Column(Unicode(50), nullable=False, index=True)
I now need to modify the above tables/relations so I can assign one song to
each player.
To accomplish this, would it be ok to add the following to Player?
songid = Column(Integer, ForeignKey('song.id'))
song = relationship('Song', lazy='select')
Or maybe I should add an association table for Song and Player?
As a follow-up question, what should I do if need to be able to assign more
than one song to a player?
Thanks
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.