Data Types
Introduction
A Data Type is the constraint on a column or a simple type in an xsd or a set of enumerations in a form etc.
Every data element should be constrained by a data type.
There are a number of different types, which will be explained in more detail below.
Data Types
Primitives
These include types such as an integer, long, string, varchar etc.
- They can include additional validation such as a regular expression or custom java / groovy code
- They do not have a measurement unit
The following types are primitive types (taken from wc3 xsd spec) and should come preloaded in the catalogue.
- string
- boolean
- decimal
- float
- double
- duration
- dateTime
- time
- date
- gYearMonth
- gYear
- gDay
- gMonth
- hexBinary
- base64Binary
- anyURI
For Example:
Note:
1) Name, ID, Version and Description
2) Rule used as a constraint, this can be written as a regular expression or a java/groovy rule.
3) Data Elements that use this data type
4) Other data types that use this as a base i.e. a data type such as Age
Simple
Simple types are derived from primitive types but they usually have additional
- condtrained range.
- upper and lower range (normal range)
- Can have a unit of measure.
- Can have a regular expression as a constraint.
- Or a complex rule constraint i.e. checksum written in groovy or java
Can be a:
- Range
- Quantity
- i.e. age, distance, duration, currency
- Result
- Timing
- Ratio
- Regular expressions or Measurement Units etc.
For Example:
Note:
1) There is regular expression applied to all Age data types
2) Age is based on xs:nonNegativeInteger so it inherits the rules listed here
3) Age is measured in years i.e. it uses the Year measurement unit
Enumerated
Enumerated types are ordered collections of individuals or codes
i.e. M:Male, F:Female, U:Unknown
For Example:
Note:
1) Enumerations codes and descriptions
2) Some enumerations may be deprecated and these are shown in red and marked as deprecated
3) Enumerations may inherit additional rules such as regular expressions that apply to any new enumerations i.e. in this case the code should be between 1 and 2 alpha numeric characters.
*in addition you can create subsets of enumerations
Complex / Reference Types
In some cases it is useful to model data types that are reference type. These use a class as the reference type.
i.e. a data type address could have a Type of Address which includes first line, postcode, country etc.