Re: [SQLObject] Foreign Key + Constraints?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Sidnei da S. <si...@aw...> - 2003-12-03 21:02:21
|
So, I've got an improved version of the patch, which should work with the other databases as well, though I didn't tested yet (have to setup mysql at least). Let me summarize what I've understood, and what I implemented to make sure I got it right this time. I'm not a DB master, just a dirty little python hacker ;) 1. If you create a Foreign Key, it is possible in Postgres to create a constraint to 'enforce' that the foreign key exists in the foreign table. It is also possible to specify that you want to 'cascade delete'. This means that when one record is deleted from the foreign table, all records refering to this record in the local table are deleted as well. This is recursive. 2. In the same sense, you may also create a 'restrict delete' constraint, which prevents a record from being deleted from the foreign table until no more records on the local table reference it. 3. If you drop the foreign table, the local table is not affected, no matter how many records reference the foreign table. 4. It is impossible to work around the cascade delete unless you drop the constraint. Does that sound right? Here goes the new patch attached, and off I go, to test with MySQL. []'s -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher Not only Guinness - Linux is good for you, too. -- Banzai on IRC |