TerminusDB Data Types

Open inAnthropic

TerminusDB supports a comprehensive set of data types for schema definitions. This reference covers all supported types organized by namespace, including type hierarchy, storage details, and typecasting rules.

For schema definition syntax, see the Schema Reference Guide.


Quick Reference

NamespaceTypesDescription
XSD Corexsd:string, xsd:boolean, xsd:decimal, xsd:double, xsd:floatFundamental data types
XSD Integersxsd:integer, xsd:byte, xsd:short, xsd:int, xsd:long, unsigned variantsSigned and unsigned integer types with range constraints
XSD Date/Timexsd:dateTime, xsd:date, xsd:time, xsd:duration, and Gregorian typesTemporal data types with timezone support
XSD Stringsxsd:normalizedString, xsd:token, xsd:language, xsd:Name, xsd:NCName, xsd:NMTOKENConstrained string types
XSD Binaryxsd:base64Binary, xsd:hexBinaryBinary data encoding
RDFrdf:langString, rdf:PlainLiteral, rdf:XMLLiteralRDF-specific literal types
XDD Extensionsxdd:coordinate, xdd:coordinatePolygon, xdd:json, xdd:url, xdd:email, xdd:html, range types, xdd:dateTimeIntervalTerminusDB extension types for specialized data
Systemsys:JSON, sys:JSONDocument, sys:DictionarySystem types for JSON and document handling

Type Hierarchy

TerminusDB implements a type hierarchy where child types inherit from parent types. This enables type subsumption—a value of a child type can be used where a parent type is expected.

Example: Text
xsd:anySimpleType
├── xsd:string
│   ├── xsd:normalizedString
│   │   └── xsd:token
│   │       ├── xsd:language
│   │       ├── xsd:NMTOKEN
│   │       └── xsd:Name
│   │           └── xsd:NCName
│   ├── xdd:url
│   ├── xdd:email
│   └── xdd:html
├── xsd:boolean
├── xsd:decimal
│   ├── xsd:integer
│   │   ├── xsd:long
│   │   │   └── xsd:int
│   │   │       └── xsd:short
│   │   │           └── xsd:byte
│   │   ├── xsd:nonNegativeInteger
│   │   │   ├── xsd:positiveInteger
│   │   │   └── xsd:unsignedLong
│   │   │       └── xsd:unsignedInt
│   │   │           └── xsd:unsignedShort
│   │   │               └── xsd:unsignedByte
│   │   ├── xsd:nonPositiveInteger
│   │   │   └── xsd:negativeInteger
│   │   └── xdd:integerRange
│   └── xdd:decimalRange
├── xsd:double
├── xsd:float
├── xsd:dateTime
│   └── xsd:dateTimeStamp
├── xsd:date
│   └── xdd:dateRange
├── xsd:time
├── xsd:duration
│   ├── xsd:yearMonthDuration
│   ├── xsd:dayTimeDuration
│   └── xdd:dateTimeInterval
├── xsd:gYear
│   └── xdd:gYearRange
├── xsd:gMonth
├── xsd:gDay
├── xsd:gYearMonth
├── xsd:gMonthDay
├── xsd:base64Binary
├── xsd:hexBinary
└── xsd:anyURI

rdfs:Literal
└── rdf:langString
    └── rdf:PlainLiteral

xdd:json (standalone)
xdd:coordinate (standalone)
xdd:coordinatePolygon (standalone)
xdd:coordinatePolyline (standalone)

sys:JSON (system type)
sys:JSONDocument (system type)
sys:Dictionary (system type)

XSD Core Types

xsd:string

The fundamental string type. All string-derived types can be cast to and from xsd:string.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#string
Parentxsd:anySimpleType
JSON RepresentationJSON string
Example"Hello, World!"

xsd:boolean

Boolean true/false values.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#boolean
Parentxsd:anySimpleType
Valid Valuestrue, false, 1, 0
JSON RepresentationJSON boolean (true or false)
TypecastingString "true" or "1"true; "false" or "0"false

xsd:decimal

Arbitrary-precision decimal numbers. TerminusDB stores these internally as rational numbers to preserve exact precision.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#decimal
Parentxsd:anySimpleType
Internal StorageArbitrary-precision rationals
JSON SerializationJSON number (20 significant digits)
String SerializationMinimal form without trailing zeros (e.g., 33"33")

Precision Notes:

  • Input values are parsed as exact rationals (e.g., 0.56795679/10000)
  • JSON output uses 20 significant digits for decimal representation
  • Round-trip conversion preserves exactness within precision limits

xsd:double

IEEE 754 double-precision (64-bit) floating-point numbers.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#double
Parentxsd:anySimpleType
Internal StorageIEEE 754 binary64
Special ValuesINF, -INF, NaN
String SerializationAlways includes decimal point (e.g., 33"33.0")

Important: xsd:double is not a subtype of xsd:decimal. They use different numeric representations.

xsd:float

IEEE 754 single-precision (32-bit) floating-point numbers.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#float
Parentxsd:anySimpleType
Internal StorageIEEE 754 binary32
Special ValuesINF, -INF, NaN
String SerializationAlways includes decimal point (e.g., 33"33.0")

Important: xsd:float is not a subtype of xsd:decimal. Like xsd:double, it uses IEEE 754 representation.


XSD Integer Types

All integer types derive from xsd:decimalxsd:integer and use arbitrary-precision integers (GMP integers in Prolog).

xsd:integer

Arbitrary-precision signed integer with no range limits.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#integer
Parentxsd:decimal
RangeUnlimited (arbitrary precision)
String SerializationNo decimal point (e.g., 33"33")

Signed Integer Types

TypeRangeParent
xsd:long−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (64-bit)xsd:integer
xsd:int−2,147,483,648 to 2,147,483,647 (32-bit)xsd:long
xsd:short−32,768 to 32,767 (16-bit)xsd:int
xsd:byte−128 to 127 (8-bit)xsd:short

Unsigned Integer Types

TypeRangeParent
xsd:unsignedLong0 to 18,446,744,073,709,551,615 (64-bit)xsd:nonNegativeInteger
xsd:unsignedInt0 to 4,294,967,295 (32-bit)xsd:unsignedLong
xsd:unsignedShort0 to 65,535 (16-bit)xsd:unsignedInt
xsd:unsignedByte0 to 255 (8-bit)xsd:unsignedShort

Constrained Integer Types

TypeConstraintParent
xsd:positiveInteger

0

xsd:nonNegativeInteger
xsd:nonNegativeInteger≥ 0xsd:integer
xsd:negativeInteger< 0xsd:nonPositiveInteger
xsd:nonPositiveInteger≤ 0xsd:integer

Typecasting: Integer types validate range constraints during casting. Attempting to cast -1 to xsd:nonNegativeInteger throws a casting error.


XSD Date and Time Types

xsd:dateTime

Combined date and time with optional timezone.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#dateTime
FormatYYYY-MM-DDTHH:MM:SS[.sss][Z|±HH:MM]
Example"2012-10-09T00:00:00Z"
Internaldate_time(Year, Month, Day, Hour, Minute, Second, Offset)

xsd:dateTimeStamp

DateTime that requires a timezone. Interchangeable with xsd:dateTime in practice.

xsd:date

Calendar date without time component.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#date
FormatYYYY-MM-DD[Z|±HH:MM]
Example"2023-12-25"

xsd:time

Time of day without date component.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#time
FormatHH:MM:SS[.sss][Z|±HH:MM]
Example"14:30:00Z"

Duration Types

TypeFormatExample
xsd:durationPnYnMnDTnHnMnS"P1Y2M3DT4H5M6S"
xsd:yearMonthDurationPnYnM"P1Y6M"
xsd:dayTimeDurationPnDTnHnMnS"P5DT3H"

Gregorian Types

TypeFormatExample
xsd:gYearYYYY[Z|±HH:MM]"1990"
xsd:gMonth--MM[Z|±HH:MM]"--12"
xsd:gDay---DD[Z|±HH:MM]"---25"
xsd:gYearMonthYYYY-MM[Z|±HH:MM]"2023-12"
xsd:gMonthDay--MM-DD[Z|±HH:MM]"--12-25"

Typecasting: xsd:dateTime can be cast to xsd:decimal to obtain a Unix timestamp.


XSD String-Derived Types

xsd:normalizedString

String with no carriage returns, line feeds, or tabs.

xsd:token

Normalized string with no leading/trailing whitespace and no consecutive spaces.

xsd:language

BCP 47 language tag (e.g., "en", "en-US", "fr-CA").

xsd:NMTOKEN

XML name token—letters, digits, hyphens, underscores, colons, and periods only.

xsd:Name

XML Name—must start with a letter or underscore.

xsd:NCName

Non-colonized Name—XML Name without colons.


XSD Binary Types

xsd:base64Binary

Base64-encoded binary data.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#base64Binary
Example"SGVsbG8gV29ybGQ="

xsd:hexBinary

Hexadecimal-encoded binary data.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#hexBinary
Example"48656C6C6F"

XSD URI Type

xsd:anyURI

URI reference (absolute or relative). Per XSD 1.1 spec and RFC 3987, accepts both absolute and relative URI references.

PropertyValue
IRIhttp://www.w3.org/2001/XMLSchema#anyURI
Valid Examples"http://example.com", "../path/file.txt", "#section", "rdf:type"

RDF Types

rdf:langString

String with an associated language tag.

PropertyValue
IRIhttp://www.w3.org/1999/02/22-rdf-syntax-ns#langString
Parentrdfs:Literal
Example"Hello"@en, "Bonjour"@fr

rdf:PlainLiteral

Plain literal that can be cast from xsd:string. Represented with an empty language tag internally.

rdf:XMLLiteral

XML content as a literal. Note: Not fully implemented.


XDD Extension Types

TerminusDB provides custom extension types under the xdd: namespace (http://terminusdb.com/schema/xdd#).

xdd:coordinate

Geographic coordinate as [longitude, latitude].

PropertyValue
IRIhttp://terminusdb.com/schema/xdd#coordinate
Format[longitude, latitude]
Example[-122.4194, 37.7749]

xdd:coordinatePolygon

Polygon defined as an array of coordinate arrays.

PropertyValue
IRIhttp://terminusdb.com/schema/xdd#coordinatePolygon
Format[[[lng, lat], [lng, lat], ...], ...]
Example[[[-122.4, 37.7], [-122.5, 37.8], [-122.4, 37.8], [-122.4, 37.7]]]

xdd:coordinatePolyline

Polyline defined as an array of coordinates.

PropertyValue
IRIhttp://terminusdb.com/schema/xdd#coordinatePolyline
Format[[lng, lat], [lng, lat], ...]

xdd:json

Arbitrary JSON data stored as a dictionary/object.

PropertyValue
IRIhttp://terminusdb.com/schema/xdd#json
TypecastingString containing valid JSON → xdd:json dictionary
Example{"key": "value", "count": 42}

Typecasting from string: When casting from xsd:string, the string is parsed as JSON. Invalid JSON throws a casting error.

xdd:url

Validated URL (subtype of xsd:string). Can also be cast from xsd:anyURI.

PropertyValue
IRIhttp://terminusdb.com/schema/xdd#url
Parentxsd:string
Example"https://terminusdb.com"

xdd:email

Email address format validation.

PropertyValue
IRIhttp://terminusdb.com/schema/xdd#email
Parentxsd:string
Example"user@example.com"

xdd:html

HTML content as a string.

PropertyValue
IRIhttp://terminusdb.com/schema/xdd#html
Parentxsd:string
Example"<p>Hello <strong>World</strong></p>"

Range Types

Range types store a pair of values representing a range.

TypeBase TypeFormatExample
xdd:dateRangexsd:date[startDate, endDate]["2023-01-01", "2023-12-31"]
xdd:gYearRangexsd:gYear[startYear, endYear][1990, 2000]
xdd:integerRangexsd:integer[min, max][1, 100]
xdd:decimalRangexsd:decimal[min, max][0.0, 1.0]

xdd:dateTimeInterval

ISO 8601 time interval with half-open semantics [start, end]. Inherits from xsd:duration and supports all four ISO 8601 interval forms. Designed for temporal algebra (Allen's Interval Algebra) and clean interval partitioning.

PropertyValue
IRIhttp://terminusdb.com/schema/xdd#dateTimeInterval
Parentxsd:duration
SemanticsHalf-open interval [start, end] — start is included, end is excluded
FormsStart/end: 2025-01-01/2025-04-01, Start/duration: 2025-01-01/P3M, Duration/end: P3M/2025-04-01, Duration only: P3M
Example"2025-01-01/2025-04-01"

Typecasting:

DirectionBehavior
xsd:string → xdd:dateTimeIntervalParses ISO 8601 interval notation (all four forms)
xdd:dateTimeInterval → xsd:stringFormats to ISO 8601 interval notation
xdd:dateRange → xdd:dateTimeIntervalConverts inclusive end to exclusive by adding one day: [Jan 1, Mar 31]Jan 1/Apr 1
xdd:dateTimeInterval → xdd:dateRangeConverts exclusive end to inclusive by subtracting one day: Jan 1/Apr 1[Jan 1, Mar 31]
xsd:duration → xdd:dateTimeIntervalWraps duration as a form-4 (duration-only) interval
xdd:dateTimeInterval → xsd:durationExtracts the duration component from the interval

For detailed usage, see the Allen's Interval Algebra guide.


System Types

System types under the sys: namespace (http://terminusdb.com/schema/sys#) provide special handling for JSON and document data.

sys:JSON

Arbitrary JSON value that can be any JSON type (object, array, string, number, boolean, null).

PropertyValue
IRIhttp://terminusdb.com/schema/sys#JSON
UsageSchema property type for arbitrary JSON
Example{"any": "json", "values": [1, 2, 3]}

sys:JSONDocument

A complete JSON document stored as a top-level entity.

PropertyValue
IRIhttp://terminusdb.com/schema/sys#JSONDocument
UsageDocument class for JSON-only documents

sys:Dictionary

Internal dictionary/object type used for JSON handling.

PropertyValue
IRIhttp://terminusdb.com/schema/sys#Dictionary
UsageInternal type for Prolog dictionary representation

For detailed information on using sys:JSON and sys:JSONDocument in schemas, see sys:JSON Reference.


Typecasting Rules

TerminusDB supports explicit typecasting between compatible types. The general rules are:

String Conversions

All types can typically be cast to and from xsd:string:

DirectionBehavior
To stringValue is serialized to its canonical string representation
From stringString is parsed and validated according to type constraints

Numeric Type Conversions

SourceTargetRule
xsd:decimalxsd:integerSucceeds only if value is whole number
xsd:double/xsd:floatxsd:decimalConverts IEEE 754 float to rational
xsd:double/xsd:floatxsd:integerSucceeds only if value equals its floor
xsd:integer subtypesEach otherValidates range constraints

String Serialization of Numeric Types

When casting numeric types to xsd:string:

Source TypeString FormatExample
xsd:doubleAlways with decimal point33"33.0"
xsd:floatAlways with decimal point33"33.0"
xsd:decimalMinimal form33"33"
xsd:integerNo decimal point33"33"

Type Subsumption

Child types can be used where parent types are expected. For example:

  • xsd:int values are valid xsd:long values
  • xdd:url values are valid xsd:string values

Reserved/Unimplemented Types

The following XSD types are defined but not implemented:

TypeStatus
xsd:NOTATIONUnimplemented
xsd:QNameUnimplemented
xsd:IDUnimplemented
xsd:IDREFUnimplemented
xsd:ENTITYUnimplemented

See Also

Was this helpful?