[Dbix-class] Bidirectional many-to-many on a single table?
Alex Peters
dbix at alexpeters.net
Tue Mar 25 08:55:57 GMT 2008
Hi,
I'm struggling to convey a many-to-many relationship on the
same table with DBIx::Class. I've read over all of the
relevant documentation on CPAN and I've read past posts to this
list that seemed closely relevant by subject[1].
I have a database table called CriterionConflict with two
columns, criterionA and criterionB. This table intends to
document instances of Criterion records that cannot coexist.
The conflicts are bidirectional; there is no meaning to the
ordering of a pair of IDs in a CriterionConflict record.
I think a 'conflicts' accessor/mutator method in the Criterion
ResultSource class would be ideal, but I don't know how I might
go about this. For the accessor side of things I imagine I'd
need to construct a ResultSet searching across both columns;
for the mutator I'd probably start out with something similar.
I'm also unsure as to whether I need a CriterionConflict
ResultSet class, since I can't see any value to making this
instantiable.
How lost am I? ;)
If anyone could provide some example relationship code to
achieve this (or any other assistance), I'll gladly accept it.
Regards,
Alex
[1] many to many self join?
http://lists.scsys.co.uk/pipermail/dbix-class/2005-October/000199.html
Many To Many on the same table trouble
http://lists.scsys.co.uk/pipermail/dbix-class/2007-May/003809.html
More information about the DBIx-Class
mailing list