#35956: Add composite foreign keys
-------------------------------------+-------------------------------------
Reporter: Csirmaz Bendegúz | Owner: (none)
Type: New feature | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Clifford Gama):
Thinking about it further... sharing fields only work when the tenant in
both relationships is always the same — which might not always be true and
may possibly lead to data integrity issues. For example, a model might
have a direct FK to `Tenant`, and also reference another model with a
composite PK like (tenant_id, id). Even though both use tenant_id, they
could point to different tenants unless explicitly constrained. Pointing
to the same field here would actually introduce a bug
I suppose this weakens the case for shared fields. It can be useful, but
in very specific cases, like, say modeling tight tenant-scoped
relationships — i.e., when you know the tenant in both FKs is always the
same and want to enforce that via shared fields.
--
Ticket URL: <https://code.djangoproject.com/ticket/35956#comment:8>
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 view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070196598bb49f-43f94305-1409-438c-b9ab-408acf3767b2-000000%40eu-central-1.amazonses.com.