One to One ========== A one to one relationship associates one child with one parent and vice-versa. For example, the pay information for an employee may be stored in a different table than the employee. However, one employee can only be paid in one way and each employee must be paid separately. .. seealso:: :ref:`one-to-one` OpenAlchemy documentation for one to one relationships. `SQLAlchemy One to One `_ SQLAlchemy documentation for one to one relationships. The following example defines a one to one relationship between *Employee* and *PayInfo*: .. literalinclude:: ../../../../examples/relationship/one_to_one/example-spec.yml :language: yaml :linenos: The following file uses OpenAlchemy to generate the SQLAlchemy models: .. literalinclude:: ../../../../examples/relationship/one_to_one/models.py :language: python :linenos: The SQLAlchemy models generated by OpenAlchemy are equivalent to the following traditional models file: .. literalinclude:: ../../../../examples/relationship/one_to_one/models_traditional.py :language: python :linenos: OpenAlchemy will generate the following typed models: .. literalinclude:: ../../../../examples/relationship/one_to_one/models_auto.py :language: python :linenos: