🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Data types
This page was created by Lars.olofsson on 2023-04-06. Last edited by Wikiadmin on 2026-07-29.

You use data types in MDriven Designer to define which values an attribute can store and which operations you can perform on that value; this page helps modelers choose an appropriate type before they create data and user interfaces.

What a data type controls

A data type is the classification of an attribute value. It determines:

  • Which values the attribute can hold.
  • Which operations OCL and EAL can perform on the value.
  • How the value is persisted in the database.
  • How a ViewModel can present and edit the value.

For example, an attribute named IsPaid should be a Boolean, because it has two meaningful values: true and false. An attribute named Amount should be numeric, so that expressions can add, compare, and calculate with it.

Common attribute types

MDriven commonly uses the following native attribute types.

Type Use it for Example
String Text with a size limit in the database. A customer's Name can contain "Ava Nilsson".
Text Text that does not have a size limit in the database. An ArticleBody can contain several paragraphs.
Integer Whole numbers. Quantity can be 3.
Double Numeric values where a double-precision floating-point value is appropriate. Latitude can be 59.3293.
Decimal Decimal numeric values, commonly amounts and other values where you need decimal precision. UnitPrice can be 19.95.
Boolean A true/false state. IsActive can be true.
DateTime A date and time value; also use this type when the user edits a date. OrderDate can represent 2026-07-28.
TimeSpan A time value or time component edited independently. StartTime can represent 09:30.
Guid A globally unique identifier. An integration identifier can hold a GUID value.
Blob Binary data as a byte array. Attachment can hold uploaded binary content.

Choose the type from the meaning of the value

Choose a type based on what the value means, not only on how it looks on screen.

  1. Use Boolean for a yes/no condition. Do not store "Yes" and "No" in a string when the value is a state.
  2. Use Integer when fractions are not valid. For example, a number of attendees is 12, not 12.5.
  3. Use Decimal for an amount such as InvoiceTotal. Do not represent an amount as text, because text cannot participate directly in numeric calculations.
  4. Use DateTime for a date the user edits, even when only the date is relevant. Use TimeSpan when you need the time part in isolation. See Date vs Time.
  5. Use String for bounded text such as a name or code. Use Text for longer content such as notes or an article body.
  6. Use Blob only for binary content. Configure the blob's intended content through BlobType.

For a database-generated GUID in persistence mapping, see AutoGuid.

Text values

String and Text both represent text, but they have different persistence intent:

  • Choose String when the value has a database size limit. Examples include FirstName, CountryCode, and ExternalReference.
  • Choose Text when the content can be long or its length is not bounded. Examples include InternalNotes and Description.

The type determines the stored value; the rendered HTML input type is a separate concern. See Column.Texttype.

Numbers and numeric expressions

Numeric types include Integer, Double, and Decimal. They support arithmetic, but assignments between different numeric types may require conversion and may change precision or discard fractions.

For example, this assignment needs a conversion when the receiving attribute is Decimal and the source is Double:

self.PaymentMenuRequest.VatPercent:=vTypAvBiljett.BiljettPrisMoms.todouble

An explicit conversion documents the intended target type. Converting to a simpler type can lose the fractional part. For example, Decimal.create(5.4).ToInt32 creates a decimal value and converts it to a 32-bit integer, losing .4.

Use the numeric conversion operators described in Number conversions. When EAL needs a Decimal value that cannot be expressed as text, create it explicitly; see Creating numeric types.

Dates and times

A date and a time are not interchangeable values. Model the value that your application needs to edit and calculate with:

  • Use DateTime for a date entered by a user, such as a delivery date.
  • Use TimeSpan when the time part is edited independently, such as an opening time.

For example, use DeliveryDate : DateTime for a delivery date and OpeningTime : TimeSpan for a daily opening time. For the detailed choice and rationale, see Date vs Time.

Objects, collections, and custom structures

A class defines a custom business type. An object is an instance of that class. For example, an Order class can have attributes such as OrderDate and IsPaid, and it can be associated with a Customer object.

Use classes and associations to model related business data. For example, model an order's lines as associated OrderLine objects rather than trying to store a list of line values in one text attribute. This gives each line its own attributes, such as Quantity : Integer and UnitPrice : Decimal.

The general programming concepts of structure and pointer types are not available as MDriven OCL data types. Model the required structure with classes, attributes, and associations instead.

Change a type with care

Changing an existing attribute type can affect stored data, expressions, and ViewModels. Test a conversion before making it permanent.

For example, if an existing Price : Integer must become a decimal amount, create a derived attribute that converts the old value and verify it in the relevant ViewModels. After you have verified the result, use the supported conversion approach to make the intended attribute name available without unnecessary ViewModel changes.

See Attribute or Data Type Conversion for derived attributes, explicit transformations, and the FormerNames approach.

Example: model an order line

The following attributes use types that match their business meaning:

Attribute Type Reason
ProductName String A bounded product name.
Quantity Integer A count of ordered units.
UnitPrice Decimal An amount that can include a fractional part.
IsBackordered Boolean A true/false order state.
RequestedDeliveryDate DateTime A user-entered date.
CustomerComment Text A potentially long comment.

See also

[[Category:Attributes and data types [Beginner]]