Jump to content

ATK Relations: Difference between revisions

From NusaATK
No edit summary
No edit summary
 
(27 intermediate revisions by 5 users not shown)
Line 1: Line 1:
= atkOneToOneRelation =
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.
The atkOneToOneRelation supports two configurations: master mode and slave mode. The mode to use is detected automatically based on the value of the $refKey parameter.


  function atkOneToOneRelation($name, $destination, $refKey="", $flags=0)
{| border=1 cellpadding=5
|- style="background-color: #FFFACD;"
  ! Relation || Description || Screenshot
|-
| [[atkOneToOneRelation]] || 'A person has one address' ||
|-
| [[atkOneToManyRelation]] || 'A department has many employees' || [[Image:atkOneToManyRelation.png]]
|-
| [[atkManyToOneRelation]] || 'A project has a projectleader (that can lead multiple projects)' || [[Image:atkManyToOneRelation.png]]
|-
| [[atkManyToManyRelation]] || 'A shopper buys multiple products, a product can be bought by multiple shoppers' ||
|-
| [[atkManyToManySelectRelation]] || 'A shopper buys multiple products, a product can be bought by multiple shoppers' ||
|-
| [[atkManyBoolRelation]] || 'An article has several categories, indicated with checkboxes' || [[Image:atkManyBoolRelation.png]]
|-
| [[atkManyToOneTreeRelation]] || 'A category has a parent category' || [[Image:atkManyToOneTreeRelation.png]]
|-
| [[atkMatrixRelation]] || 'In a project, phases x and y depend on phases a and b' ||
|-
| [[atkSecureRelation]] || 'A patient has personal information, that must be secured' ||
|-
| [[atkShuttleRelation]] || 'An operator operates in several countries, selected from a list' || [[Image:atkShuttleRelation.png]]
|-
| [[atkExtendableShuttleRelation]] || 'An operator operates in several countries, selected from a list which can be filtered' ||
|}


* $name: The unique name of the attribute.
Relations behave similar to [[Attributes]] (in fact, relationships are nothing more then special attributes).
* $destination: the destination node (in module.nodename notation)
* $refKey: foreign-key field (master mode) or empty (slave mode)
 
== Master mode example ==
The node in which the relation is implemented, is considered the master (code is in node A). And the referential key pointing to the master record (a_id) is in the destination node (node B).
 
[[image:atkOneToOne_master.jpg]]
 
Referential key a_id is in the other node, so this is the master-configuration.
 
== Slave mode ==
The node in which the relation is implemented (code is in node B), is considered the child. And the referential key pointing to the master record (a_id) is in the current node (node B).
 
[[image:atkOneToOne_slave.jpg]]
 
Referential key a_id is in the same node, so this is the slave-configuration.
 
= atkOneToManyRelation =
 
= atkManyToOneRelation =

Latest revision as of 10:44, 8 March 2010

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.

Relation Description Screenshot
atkOneToOneRelation 'A person has one address'
atkOneToManyRelation 'A department has many employees'
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'
atkManyToManySelectRelation 'A shopper buys multiple products, a product can be bought by multiple shoppers'
atkManyBoolRelation 'An article has several categories, indicated with checkboxes'
atkManyToOneTreeRelation 'A category has a parent category'
atkMatrixRelation 'In a project, phases x and y depend on phases a and b'
atkSecureRelation 'A patient has personal information, that must be secured'
atkShuttleRelation 'An operator operates in several countries, selected from a list'
atkExtendableShuttleRelation 'An operator operates in several countries, selected from a list which can be filtered'

Relations behave similar to Attributes (in fact, relationships are nothing more then special attributes).