SQLA One To Many Relationship (Painters Painting)

Опубликовано: 30 Октябрь 2023
на канале: Thomas Blum
48
1

In this video we look at SQLAlchemy (SQLA) code to to define a simple two-table database that demonstrates a One-to-Many relationship between two entities. The example will have two entities: Painters and Paintings. Since

A Painter creates MANY Paintings
A Painting is made by ONE Painter

The relationship is a ONE-To-MANY relationship realized by having a Foreign Key in the Painting table which establishes which Painter made it. SQLA also allows us to express in code the other direction. So we denote in the Painter class that it has a relationship to the Painting entity.

We inset some data into each table and query each table individually.


Смотрите видео SQLA One To Many Relationship (Painters Painting) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Thomas Blum 30 Октябрь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 48 раз и оно понравилось 1 людям.