Skip to content

Add one-to-one relationship tutorial to docs #381

Description

@fkromer

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the SQLModel documentation, with the integrated search.
  • I already searched in Google "How to X in SQLModel" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to SQLModel but to Pydantic.
  • I already checked if it is not related to SQLModel but to SQLAlchemy.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

n.a.

Description

It would be great to have an "how to" about one-to-one relationships directly in the official docs. An adaption of the sqlalchemy docs example about one-to-on relationships (https://docs.sqlalchemy.org/en/14/orm/basic_relationships.html#one-to-one) should do the job.

Operating System

Linux

Operating System Details

No response

SQLModel Version

n.a.

Python Version

n.a.

Additional Context

No response

Activity

  1. Beafowl-Pull commented on Jul 21, 2022

    @Beafowl-Pull

    you just need to make a simple relation like here: https://sqlmodel.tiangolo.com/tutorial/relationship-attributes/

  2. m0wer commented on Apr 4, 2023

    @m0wer

    Not really. Since there's no option uselist=False for the relationship, you always get a list (so it's one-to-many) even if not possible (if you make the FK the PK).

  3. Kyu commented on Apr 12, 2024

    @Kyu

    "workaround" for future readers: #132

  4. locked and limited conversation to collaborators on May 18, 2026
  5. converted this issue into a discussion #1957 on May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions