---
title: "SQLAlchemy 2 In Practice - Chapter 3 - One-To-Many Relationships"
url: https://daily.dev/posts/sqlalchemy-2-in-practice---chapter-3---one-to-many-relationships-duijuq7ab
source_url: https://blog.miguelgrinberg.com/post/sqlalchemy-2-in-practice---chapter-3---one-to-many-relationships
type: article
source: "Miguel Grinberg"
published: 2026-05-03T09:32:32.744Z
updated: 2026-05-03T09:33:18.791Z
tags: ["python", "backend"]
reading_time: 34
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# SQLAlchemy 2 In Practice - Chapter 3 - One-To-Many Relationships

**[Miguel Grinberg](https://daily.dev/sources/miguelgrinberg)** · 34 min read · 0 upvotes · 0 comments

## Summary

Chapter 3 of the SQLAlchemy 2 in Practice book covers implementing one-to-many relationships using SQLAlchemy ORM. It walks through creating a separate Manufacturer model, defining foreign keys, and adding relationship attributes with back_populates. The chapter explains lazy vs. eager loading strategies (select, joined, selectin, subquery, immediate, write_only, etc.) and their performance implications, including the N+1 query problem. It also covers cascade configurations ('save-update, merge' vs. 'all, delete-orphan') for handling deletion and detachment of related objects, with practical code examples throughout.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.miguelgrinberg.com/post/sqlalchemy-2-in-practice---chapter-3---one-to-many-relationships>

---

Tags: [#python](https://daily.dev/tags/python), [#backend](https://daily.dev/tags/backend)

[View this post on daily.dev](https://daily.dev/posts/sqlalchemy-2-in-practice---chapter-3---one-to-many-relationships-duijuq7ab)
