Hi,

I'm a beginner reading the "Basic Relationship Patterns" documentation:

http://docs.sqlalchemy.org/en/latest/orm/basic_relationships.html

The examples are confusing to me because all of the examples use "Parent" 
and "Child," which in reality have a Many-to-Many relationship. It was 
unclear to me whether the "One To Many" example illustrates "one parent to 
many children" or "one child to many parents." Understanding from the code 
samples (which are all very similar) presupposes a certain level of 
familiarity with how relationships are constructed in SQLAlchemy.

I think I've understood the first two examples to be:

One To Many:
    - one Parent to many Children
    - Child has foreign key referencing Parent
    - Parent has relationship referencing a collection of Children

Many To One:
    - one Child to many Parents
    - Parent has foreign key referencing its Child
    - Parent has relationship referencing a single Child

The latter example is confusing because so many aspects are being swapped 
around. It would be clearer to instead use the same "one Parent to many 
Children" scenario: 

Many To One:
    - one Parent to many Children
    - Child has foreign key referencing its Parent
    - Child has relationship referencing a single Parent

This makes it clearer that only the third aspect---which side the 
relationship was declared on---has changed. 

The documentation would be improved by switching to more intuitive 
examples. How about

    One To Many, Many To One: Countries and Cities
    One To One: Capitals and Countries
    Many To Many: Organizations and Members

It would help to explicitly state the scenario that is being modeled in 
each case, even if it appears obvious. The descriptions of the current 
examples all immediately jump into technical details of foreign keys, 
scalars, and association tables.

Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to