Jump to content

ATK Relations: Difference between revisions

From NusaATK
No edit summary
No edit summary
Line 4: Line 4:
* [[atkOneToManyRelation]] - 'A department has many employees'
* [[atkOneToManyRelation]] - 'A department has many employees'
* [[atkManyToOneRelation]] - 'A project has a projectleader (that can lead multiple projects)'
* [[atkManyToOneRelation]] - 'A project has a projectleader (that can lead multiple projects)'
 
* [[atkManyToManyRelation]] - 'A shopper buys multiple products, a product can be bought by multiple shoppers'
 
 
 
== atkManyToManyRelation ==
 
This relation can be created with an intermediate table to store the relations.
 
A Many-To-Many-Relation basically consist of a atkOneToMany relation to the intermediate table. The intermediate node has two atkManyToOne relations defined.
 
 
'''Example'''
 
One person (node A) can have several skills (node B) and the same skill applies to more than one person.
 
[[image:atkManyToMany.jpg|center]]
 
 
If, in the example above, a skill is removed, this skill must be removed for all employees. This can be achieved by adding the AF_CASCADE_DELETE flag to the atkOneToManyRelation in node B:
 
atkOneToMany(“unique dummy”,
              “mymod.A_B”,
              “b_id”,
              AF_HIDE|AF_CASCADE_DELETE);
 
Normally you assign skills to a person (an not the other way round), so the atkOneToManyRelation in this node must be hidden.
 
 
And on the other hand, if an employee is deleted, the correspoding record(s) in the intermediate table must be removed as well.
 
atkOneToMany(“unique dummy”,
              “mymod.A_B”,
              “a_id”,
              AF_CASCADE_DELETE);
 
'''Be careful''' when using the AF_HIDE flag in the itermediate (A_B) node for the atkManyToOneRelation, in combination with multilanguage fields. When a relation is hidden, the key (a_id) will not be processed and no check on the language is done. This causes the added record to appear multiple times (once for every language), since a_id is not unique in the intermediate table.


==atkManyBoolRelation==
==atkManyBoolRelation==

Revision as of 10:10, 28 December 2006

A relation defines a relation between two tables. One or more records in the first table belong to one or more records in the second table. A one to many relation would be '1 library has N books'. Below is a list of the relations that are currently available in ATK.

atkManyBoolRelation

Document me!

atkManyToOneTreeRelation

The atkManyToOneTree relation will build a dropdown that looks like:

Record A
  Record B
  Record C
     Record D
     Record E
Record F

It could be used together with atkTreeNode with AF_PARENT.

atkMatrixRelation

The atkMatrixRelation is no longer maintained and probably does not work. Over the years that ATK has existed, there haven't been many uses for the atkMatrixRelation.

atkSecureRelation

Document me!

atkShuttleRelation

Document me!