On 22 August 2012 13:36, Uncle Cheese <
aaronc...@gmail.com> wrote:
>
> I suppose, but I'm not really sure why it matters. Those tables just map the ID of one object to the ID of another. If one gets deleted, the record is orphaned. There's a 0% chance that it would ever populate a new object with its data.
I'd have to agree with Matthias. Here are some reasons:
- because it allows you to do custom queries on the many_2_many table without getting false results - e.g.
- how many relationships are there
- custom queries that you need to speed up large applications
- e.g. because you may add a rule "only allow deletion of object A if there are no objects linking to object A" (e.g. only allow a product to be deleted if it . In order to speed up this rule you write something like: "DB::query("Select COUNT(ID) from ManyManyTable WHERE Relation.ID = objectAID")->value(); ... This will return false positives if there are relationships between A and deleted objects.
- faster
- cleaner
In the e-commerce application I had to add a number of hacks to clean-up the many_2_many tables as without the clean-up I was getting false results.
I am curious to hear what other people think about this.
Cheers
Nicolaas