I'm having fun trying to visualize this in my head, but I have 4 tables, 3
are basic relations, but the 4th table links to table 2.
Should I take the 4th table and have a relation join with all 3 tables or
can I just relate to table 2 and have table 2 relations do the rest?
Tables 1-3 are basic equipment relationships:
1 - manufacturer
2 - model (foreignkey manufaturer.id)
3 - sources (foreignkey model.id) (sources = inputs available)
manufacturers_table = Table(u'manufacturer', metadata,
Column(u'id', Integer, primary_key=True),
Column(u'name', String(50))
)
models_table = Table(u'model', metadata,
Column(u'id', Integer, primary_key=True),
Column(u'manufacturer_id', Integer, ForeignKey(u'manufacturer.id')),
Column(u'name', String(50))
)
sources_table = Table(u'source', metadata,
Column(u'id', Integer, primary_key=True),
Column(u'model_id', Integer, ForeignKey(u'model.id')),
Column(u'label', String(20)),
)
The 4th table keeps track of equipment installed at the premise.
4 - projector (foreignkey model.id)
projector_table = Table(u'projector', metadata,
Column(u'id', Integer, primary_key=True),
Column(u'model_id', Integer, ForeignKey(u'model.id')),
)
Tables 1-3 will be updated separately, the projector table will only join
with the other tables for reading.
The question(s) would be on the joins:
1 ) Use projector table with join to model table (and model table will take
care of the joins with manufacturer and sources)
2) Add table 1 and 3 to projector:
projector_table = Table(u'projector', metadata,
Column(u'id', Integer, primary_key=True),
Column(u'manufacturer_id', Integer, ForeignKey(u'manufacture.id')),
Column(u'model_id', Integer, ForeignKey(u'model.id')),
Column(u'sources_id', Integer, ForeighKey(u'sources.id'))
)
Hope I'm making myself understood - databases with multiple relations are
not my strong suit.
--
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.