Association Definition

An Association Definition describes the schema of a relationship between two nodes. Fundamentally, association
instances are JSON objects that conform to the JSON schema of their association definitions. Association definitions
allow you to specify the schema of your associations so as to store properties on them.

There are primarily two families of associations - a:linked and a:owned, describing linked
and owned associations, respectively.

  • A linked association is one in which the relationship between the two nodes is optional. Deleting one of the nodes
    does not delete the other. The relationship between the nodes is descriptive but implies no ownership or containment.
    A linked relationship is such that deleting one of the nodes in the relationship has no impact on the other node.

  • An owned association is one in which a parent node "owns" a related node. Deleting the parent node implies required
    deletion of the owned node. And an attempt to delete the owned node should block since it is an owned or required
    element of the parent. A node can only have one parent node, and thus can only have one outgoing a:owned association.

An example of an owned relationship might be a book with chapters. Deleting the book should delete all of the chapters.
And an attempt to delete a chapter should throw an exception since the book requires the chapters for object model
consistency.

Here is an example of an association that connects Pages to Articles. It stores order information on it
as a number. This order information can then be used by the web site to order the display of articles on a page.
Since the association derives from a:linked, the design is such that Articles can be reused across
many pages:

{
    "title": "Page has Article",
    "type": "object",
    "properties": {
        "order": {
            "type": "number",
            "title": "Order"
        }
    },
    "_qname": "my:page-has-article",
    "_type": "d:association",
    "_parent": "a:linked"
}

Note that this association definition claims the QName my:page-has-article.