relating two card types


Suppose your Wagn site has Person cards and Company cards.  You have a Person named George who works for  a Company named Banana Computers, and you'd like to relate George and Banana Computers in such a way that each shows up on the other card.


The typical solution is a pointer-search relationship.  It can look something like this:

  • On each Person card there is a pointer card named +employer
  • George+employer is edited to point to Banana Computers
  • On each Company card there is a search card named +employees
  • Banana Computers+employees will find George!

The WQL for Banana Computers+employees will look something like this:

{"type":"Person","right_plus":["employer",{"refer_to":"Banana Computers"}]}

In English, this means "find all the cards whose type is Person that have a +employer card that points to Banana Computers.


Of course, you wouldn't want to have to write this WQL over and over again for every single Company card, so the common practice is to make the +employees searches into virtual cards.  To do this, you could go to Banana Computers+employees and then click on advanced and create a structure rule that applies to "all +employees cards on Company cards".  (This will create a card called "Company+employees+*type plus right+*structure").  The WQL for that card will look something like this: