#24289: Is usage of many_to_one and one_to_many terms confusing for relation 
flags?
-------------------------------------+-------------------------------------
     Reporter:  akaariai             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  1.8alpha1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by akaariai):

 * status:  new => closed
 * resolution:   => invalid


Old description:

> It seems we have mixed up the naming of many_to_one and one_to_many. For
> example these references point out that ForeignKey is many_to_one:
> http://www-01.ibm.com/support/knowledgecenter/SSEPGG_8.2.0/com.ibm.db2.udb.doc/admin/c0004733.htm,
> https://docs.djangoproject.com/en/1.7/topics/db/examples/many_to_one/.
>
> But in Django, ForeignKey is one_to_many.
>
> I'm not going to mark this as accepted, as I always get confused with
> many-to-one and one-to-many. So, please do triage this carefully!
>
> If at all possible I think we should use something that is less easy to
> get mixed up. I never recall how these terms should be interpreted, and I
> guess I am not alone here. Some ideas:
>   - Just is_multivalued flag: Check if field is one to many: "not
> field.is_multivalued and field.rel.is_multivalued"
>   - local_multivalued and remote_multivalued flags
>
> My experience from ORM work is that the interesting thing to check is if
> the relation can have multiple values on the remote side. The local
> multi-valuedness isn't usually that interesting (although it might be in
> other contexts).

New description:

 EDIT: we haven't mixed the terms up, I did that myself. The docs might
 need an update though.

 It seems we have mixed up the naming of many_to_one and one_to_many. For
 example these references point out that ForeignKey is many_to_one:
 
http://www-01.ibm.com/support/knowledgecenter/SSEPGG_8.2.0/com.ibm.db2.udb.doc/admin/c0004733.htm,
 https://docs.djangoproject.com/en/1.7/topics/db/examples/many_to_one/.

 But in Django, ForeignKey is one_to_many.

 I'm not going to mark this as accepted, as I always get confused with
 many-to-one and one-to-many. So, please do triage this carefully!

 If at all possible I think we should use something that is less easy to
 get mixed up. I never recall how these terms should be interpreted, and I
 guess I am not alone here. Some ideas:
   - Just is_multivalued flag: Check if field is one to many: "not
 field.is_multivalued and field.rel.is_multivalued"
   - local_multivalued and remote_multivalued flags

 My experience from ORM work is that the interesting thing to check is if
 the relation can have multiple values on the remote side. The local multi-
 valuedness isn't usually that interesting (although it might be in other
 contexts).

--

Comment:

 It seems I did the mixup based on the first sentence of Django's docs
 (which I guess is technically correct, you use ForeignKey to add the
 automatically created many-to-one relation), and table 3 of IBM's docs,
 the first line in there seems to be many-to-one, although the meaning of
 the header is that the relationships are many-to-one, but the direction
 the terms appear in the table can actually be one-to-many (nice!).

 I'll mark this as invalid. I still do think the terms are confusing.

--
Ticket URL: <https://code.djangoproject.com/ticket/24289#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.c10ad915f511be4b9c7b8ab8324a81d1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to