Basics (types)
Practical use of types and consistency rules
A type describes a set of values with a compatible structure and compatible behaviour (e.g. equality test, ordering).
With types, you can define consistency rules for the structure and behaviour of the wiki pages your team manages if required and step-by-step.
After you create and every time you change a wiki page all the rules that apply to this wiki page and its attributes are checked. If a consistency rule is broken, the affected attribute is marked as an error with an error message and a reference to the broken rule. If you have marked the consistency rule strict, the change cannot be saved.
You and your employees can search for errors and then correct the errors step-by-step by changing the type definition, the assignment of the type tag or by changing the attribute values.
Consistently structured wiki pages not only lead to higher data quality, but also facilitate powerful automatic evaluations, search queries and graphic visualisations.
Tricia distinguishes between simple types, attribute types and structured types for wiki pages.
Simple types and simple values
A simple type describes a set of discrete values, which can be compared for equality and ordered.
You use simple types to constrain the allowed values for attributes of wiki pages if necessary.
Tricia’s predefined simple types are described in the following:
- A String is a sequence of characters (e.g. Peter Jones). The equality test for strings is case sensitive. Strings are ordered lexicographically.
- A Link refers to a content item on the Internet via a URL and has a name (enclosed in <a>...</a>) which often matches the name of the referenced content item (<a href="/wikis/help/france">France</a>). Link equality is determined by the equality of the URLs. Links are ordered lexicographically by the name of the link.
- An internal link (InternalLink) is a link referring to a content item or action within Tricia. The URL contains either no host name, e.g. <a href="/wikis/help/france">France</a>, or the host name is the current name of the Tricia server.
- All other links are external links (ExternalLink), e.g. <a href="www.google.com">Google Search</a>.
- An internal link can be typed. A typed link of the type InternalLink(city, country) refers to a wiki page with the type tag city and/or the type tag country.
- A Boolean is a string that describes a truth value. The truth values are the strings true and false. Both truth values must be written entirely in lowercase. Truth values are ordered lexicographically (i.e. false < true). Truth values can also be represented in icon format in HTML (green tick in a checkbox for true and empty checkbox for false).
- A Date is a string that describes a date using the Gregorian calendar. Date values are in the format YYYY/MM/DD (e.g. 2011/06/17 for 17 June 2011). The year, month and day must be preceded by a zero if necessary so that they are exactly 4, 2 and 2 digits in length respectively. The equality of date values and their ordering is determined by the lexicographical ordering of the strings. When inputting an attribute value, you can click the calendar icon beside the input field to conveniently enter date values on a calendar control element.
Furthermore, you can define an enumeration yourself as a user-defined simple type. An enumeration consists of an ordered list of strings and/or links. The equality and ordering of the enumeration values is determined by the sequence of their definition.
Examples of enumerations are
- Enumeration(1, 2, 3)
- Enumeration(high, medium, low)
- Enumeration(<a href="/wikis/help/france">France</a>, <a href="/wikis/help/germany">Germany</a>)
- Enumeration(Unknown, Other, <a href="/wikis/help/p1">P1</a>, <a href="/wikis/help/p2">P2</a>)
Subtyping
Subtyping enables you to define structures and consistency rules for certain aspects of the content you manage and nevertheless facilitate extensions and restrictions of the other aspects with a degree of flexibility.
The principle of subtyping refines the intuitive understanding of the compatibility of values and types:
Type S is a subtype of type T (in characters S <: T) if all values of type S can also be used as values of Type T.
The subtype relationship between types is therefore transitive
S <: T <: U => S <: U
If S is a subtype of T and T is a subtype of U then S is also a subtype of U.
The examples later will explain the practical use of subtyping.
Subtype rules for simple types
|
The following subtype rules apply to simple types Boolean <: String |
A Boolean can be used wherever a String is expected. |
|
Date <: String |
A Date can be used wherever a String is expected. |
|
InternalLink <: Link |
An internal link can be used wherever a link is expected. |
|
ExternalLink <: Link |
An external link can be used wherever a link is expected. |
|
InternalLink(T) <: InternalLink() |
A typed link can be used wherever an internal link is expected. |
|
InternalLink(T) <: InternalLink(T1, T2, ..., T, ..., Tn) |
A typed link with a reference to a wiki page with the type tag T can be used wherever a typed link to a wiki page with the type tag T with any other type tags is expected. This rule also applies more generally to typed links with more than one type tag. In this case, a subset relationship between the type tags of the subtype and the set of type tags of the supertype is required. |
|
Enumeration(a1, a2, ... an) <: Enumeration (b1, b2, ..., bm) if {a1,.a2, ...an} is a subset of {b1, b2, .., bm} |
An enumeration of n values is a subtype of another enumeration of m values if each of the values in the first enumeration is contained in the second. |
Structured types and structured wiki pages
A structured type is defined explicitly and locally for a wiki by a type definition. The type definition defines a type tag for the type (e.g. city). The values of the type are all wiki pages in this wiki that (also) have this type tag.
The type definition itself can have tags and a hypertext which explain the meaning of the type and support the organisation of numerous type definitions.
The (minimal) structure and consistency rules of the wiki pages of the type are specified by a set of attribute definitions.
A wiki page can have multiple type tags. In this case the wiki page must satisfy the consistency rules of all attribute definitions of all type tags.
An attribute definition belongs to a type definition which is defined locally for a wiki. It consists of the name of the attribute, a description which is shown as an input aid for users, and optional consistency rules:
- The multiplicity of an attribute restricts the number of values for the attribute:
- At most one value 0..1
- Exactly one value: 1
- At least one value 1..*
- -: 0..*
- The type of an attribute is a simple type (Enumeration, Boolean, Date, Link) and restricts the allowed values for the attribute.
These consistency rules can be marked strict. Then users cannot create any new wiki pages or change existing wiki pages which break these rules.
Subtype rules for multiplicities
The following subtype relationships apply to multiplicities:
- Exactly one value <: At most one value <: -
- Exactly one value <: At least one value <: -
Subtype rules for attribute definitions
An attribute definition with the name A and the multiplicity K1 and the (scalar) attribute type T1 is a subtype of an attribute definition with the same name A, a multiplicity K2 <: K1 and an attribute type T2 <: T1.
Subtype rules for structured types
A type definition for a type tag T1 with a list of attribute definitions A1, A2, ..., An is a subtype of a type definition for a type tag T2 with a list of attribute definitions B1, B2, ..., Bm, if for each attribute definition Bi there is a (same-named) attribute definition (Aj), so that Aj<:Bi.
|
Referenced by
(3)
|
0 Comments