Software Engineer (SDE)fastapiintermediate3 interactive MCQs in app
SQLAlchemy ORM with FastAPI
N+1 lazy loading vs selectinload/joinedloadSQLAlchemy 2.0 parameterized select().where()explicit transaction commit/rollback
Core Concept
SQLAlchemy 2.0 separates `select(Model).where(...)` queries, explicit transaction commits (`db.commit()` / `with db.begin():`), and eager loading (`selectinload` / `joinedload`) to prevent N+1 query storms when loading parent missions + child events! Never interpolate raw strings inside `text(f"... {user_input}")`; bind parameters cleanly with `.where(User.id == uid)` or `:param`.
Worked Example
`select(Mission).options(selectinload(Mission.events))` loads 50 missions + events in 2 batched queries instead of 51 round-trips!
Common Pitfall
(N+1 queries!) iterating 50 missions and accessing `mission.events` triggers **51 separate SQL queries** instead of 2 queries via `selectinload(Mission.events)`!
Recommended Readings & Practice
Practice SQLAlchemy ORM with FastAPI with 3 graded MCQs & written feedback.
Take SOARDO’s free 12-question diagnostic to see how strong you are across your target role and unlock adaptive daily missions.