On Fri, Jul 4, 2008 at 12:08 AM, Jad <[EMAIL PROTECTED]> wrote:
>
> Lets say we have Accounts that is referenced profile, group, interest
> tables.
>
> If I delete the account ID 1 would the related data to that account in
> profile, group and interest table be deleted in all cases of relation?
>  One to one, one to many, many to many? same question applies to
> update

Essentially, the question Django asks is "If I delete object A, will
that invalidate object B?". If B has a foreign key reference on A that
cannot be null, deleting A would leave B in an invalid state (B
pointing to nothing), so Django will delete B as well. If C has a
foreign Key reference on B, then the deletion of B will cascade on to
C, and so on.

OneToOne fields are just the degenerate case of Foreign Keys, so the
same rules apply.

Many to Many fields are unaffected (although any references to A
specific entry in m2m tables will be deleted).

This behaviour is the equivalent of 'ON DELETE CASCADE' at a database
level; however, SQLite (and, if I remember correctly, MySQL) doesn't
have support for ON DELETE CASCADE, so Django implements the
equivalent behaviour using DELETE calls.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to