Firstly, I'll explain my database layout:
I have a User table, which it's layout is not that important to the problem at
hands;
A Bots Table:
bots = sqla.Table('bots', metadata,
sqla.Column('id', sqla.Integer, primary_key=True, autoincrement=True),
sqla.Column('nick', sqla.Unicode, nullable=False, unique=True),
sqla.Column('name', sqla.Unicode, nullable=True, unique=False),
sqla.Column('passwd', sqla.Unicode, nullable=True, unique=False),
sqla.Column('user_id', sqla.Integer, sqla.ForeignKey('users.id')),
)
Each user is allowed to have several bots.
A networks Table:
networks = sqla.Table('networks', metadata,
sqla.Column('id', sqla.Integer, primary_key=True, autoincrement=True),
sqla.Column('name', sqla.Unicode, nullable=False, unique=False),
sqla.Column('address', sqla.Unicode, nullable=False, unique=False),
sqla.Column('address', sqla.Unicode, nullable=False, unique=False),
sqla.Column('port', sqla.Integer, nullable=False, unique=False),
)
sqla.Index('networks_idx', networks.c.address, networks.c.port, unique=True)
networkbots_association = sqla.Table('networkbots_association', metadata,
sqla.Column('id', sqla.Integer, primary_key=True, autoincrement=True),
sqla.Column('network_id', sqla.Integer, sqla.ForeignKey('networks.id')),
sqla.Column('bot_id', sqla.Integer, sqla.ForeignKey('bots.id'))
)
sqla.Index('networkbots_association_idx',
networkbots_association.c.network_id,
networkbots_association.c.bot_id, unique=True)
Each bot is allowed to have a list of networks;
I do that by an association table because 2 bots might share the same network.
Then, here's where my problem starts, I have a channels table.
The same channel name might appear in 2 different networks, when such happens
there should
be 2 channels, one for each of the networks.
Apart from that, I can't have a networks.id foreign key for channels, then 2
bots sharing the same network would have the same channels.
So, the foreign keys to use on channels should be networkbots_association.id?
Any help would be wonderfull.
Regards,
--
Pedro Algarvio
__ ___ ___ _______ ___ __
| Y .' _| _ .-----.' _| |_ .-----.----.-----.
|. | | _| 1___| _ | _| _|__| _ | _| _ |
|. | |__| |____ |_____|__| |____|__|_____|__| |___ |
|: 1 | |: 1 | |_____|
|::.. . | |::.. . | ufs [AT] ufsoft [DOT] org
`-------' `-------' ufs [AT] sapo [DOT] pt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---