Reputation: 495
I have two Tables as bellow:
table series
:
+-------------+
| Field |
+-------------+
| series_id |
| title |
+-------------+
table season
:
+-------------+
| Field |
+-------------+
| season_id |
| title |
| version |
| duration |
| series_id |
+-------------+
In season
, series_id
as foreign key referees from series(series_id)
Now I want load these two table via sqlalchemy. Is that possible to build a one-to-many relationship between these two tables so that I can access all seasons object of one series?
Upvotes: 0
Views: 149
Reputation: 68
Yes you can! The series_id
field of the season
table will be a foreign key to the series
table. To get all seasons of a particular series, you will query the 'season' table for all entries which have a particular series_id.
Look at this: http://docs.sqlalchemy.org/en/latest/orm/tutorial.html#querying
Upvotes: 1