↓ Skip to main content
A paper cut-out of a shopping list with five lines beside a teal shopping basket. The basket holds five items: a rose apple, an orange bottle, a dark loaf of bread, a teal box and a teal fish.

Schema Design Best Practices

A schema looks like a list of column names, and for the first weeks that is all it has to be. Then a page needs the description of the asset, the tasks of the work order, or a text that Maximo does not store. Each of these has its own way into a schema, and each one changes the request and the shape of the row. We wrote five schemas for the same work order and read both.

MAS 9.2 series guide

Datasource Basics introduces the schema as a shopping list. This guide is about what to put on the list. We ran every step on our test system, on the MAS 9.2 series, on a page of our Components Explorer. All five datasources read through the object structure mxapiwodetail.

Three phone frames of the page “Data: what a schema asks for”. First, the row of the schema with dots, shown as text: a key “location” and a key “asset”, each with an object that holds a description, and below it the fields of the plain schema and of the dot schema. Second, the row of the schema with a relationship: a key “woactivity” with a list of two tasks, each with a description and a task id. Third, the fields of the alias schema, bound to item.assetdesc and item.locdesc, and the list of the computed schema with lines such as “1000: priority 3” and “1000-10: priority none”.
The row of a schema with dots, the row of a schema with child records, and a list over a computed attribute

Rule 1 · The schema is the request
#

Every attribute of a schema goes into the select list of the request, and nothing else does. This schema:

<schema id="fs_d_schema_plain_s">
  <attribute name="wonum" unique-id="true" id="fs_d_schema_plain_a_wonum"/>
  <attribute name="description" id="fs_d_schema_plain_a_description"/>
  <attribute name="assetnum" id="fs_d_schema_plain_a_assetnum"/>
  <attribute name="location" id="fs_d_schema_plain_a_location"/>
</schema>

sent this request, and got this row:

oslc.select=wonum,description,assetnum,location

{"assetnum":"11200","description":"HVAC overheating","location":"BR200","wonum":"1221"}

The row holds what the schema names. An attribute that a field of the page binds to has to be in the schema. When it is missing, the build still passes, and the field shows a striped bar in place of a value. The cookbook recipe Add a Field shows that case and how our MAF editor marks it.

Rule 2 · Reach a related record with a dot#

The page should show the description of the asset. The work order holds only its number. A dot follows a relationship of the work order to the other record:

<attribute name="asset.description" id="fs_d_schema_dot_a_asset"/>
<attribute name="location.description" id="fs_d_schema_dot_a_location"/>
oslc.select=wonum,asset.description,location.description

{"location":{"description":"HVAC System- Main Office"},
 "asset":{"description":"HVAC System- 50 Ton Cool Cap/ 450000 Btu Heat Cap"},
 "wonum":"1221"}

One request brought the work order with both descriptions. The row has a nested object for each related record, and a binding follows the same path:

<field id="fs_d_schema_dot_f1" label="Asset" value="{fs_d_schema_dot.item.asset.description}"/>

Use the dot for one or two values of a record that belongs to the row. It saves a second datasource and a second request.

Rule 3 · Give a related attribute a name of its own#

Two dashes after the attribute give it an alias:

<attribute name="asset.description--assetdesc" id="fs_d_schema_alias_a_asset"/>
<attribute name="location.description--locdesc" id="fs_d_schema_alias_a_location"/>
oslc.select=wonum,asset.description--assetdesc,location.description--locdesc

{"locdesc":"HVAC System- Main Office",
 "assetdesc":"HVAC System- 50 Ton Cool Cap/ 450000 Btu Heat Cap",
 "wonum":"1221"}

The alias travels in the request, and Maximo answers with a flat row. The binding gets shorter: {fs_d_schema_alias.item.assetdesc}.

A flat row with short names is easier to read in a binding and in a controller. IBM’s Technician app uses this form in well over a hundred attributes of its schemas.

Rule 4 · Bring child records with a relationship
#

A work order has tasks. They are records of their own, and a row can carry them:

<attribute name="rel.woactivity{taskid,description}" id="fs_d_schema_child_a_tasks"/>
oslc.select=wonum,rel.woactivity{taskid,description}

{"woactivity":[{"description":"Review hot and cold air flow","taskid":10},
               {"description":"Provide access to HVAC system","taskid":20}],
 "wonum":"1221"}

The attributes in the braces are the schema of the child. The row came back with a list of two tasks, in the same single request.

This form suits a page that shows a few child records together with their parent. A page that lists many child records with their own paging is a case for a child datasource, which Datasource Basics introduces.

Rule 5 · Keep a computed attribute cheap
#

Some values exist only in the app: a line that joins two attributes, a flag that decides whether a button shows. A computed attribute names a method of the datasource controller:

<attribute name="computedLine" computed-function="computedLine" id="fs_d_schema_comp_a_line"/>
// FsSchemaDsController, the controller of the datasource, shown without its call counter
computedLine(item) {
  return `${item.wonum}: priority ${item.wopriority === undefined ? 'none' : item.wopriority}`;
}

The request did not name the attribute: oslc.select=wonum,description,wopriority. Maximo never hears of it. The row had it all the same, and the list of our page drew it: 1000: priority 3.

We counted the calls of the method. The first load of three rows called it three times. A reload of the same three rows called it nine more times. The framework asks for a computed value more often than once per row.

So a computed function has to be fast and free of side effects. It may read the item and return a value. A request, a change of state or a slow loop inside it runs for every row, and more than once.

Rule 6 · Ask for a status in both forms
#

A status has a value and a text. The schema of a page that shows the status needs both attributes:

<attribute name="status" id="fs_d_load_one_a_status"/>
<attribute name="status_description" id="fs_d_load_one_a_status_description"/>

We left out status once and kept status_description. The field then drew a striped bar where its value belongs. Loading and Displaying Data tells that story.

Rule 7 · One schema for each job
#

Every attribute costs on every row. In our measurement, a schema with 40 attributes gave an answer about two and a half times as large as a schema with 4, at every page size. With 500 rows it took three times as long.

A list and a details page have different needs, so give each its own datasource:

Datasource ofSchemaPage size
a listwhat a row shows, and the key20 to 40
a details pageas wide as the page needs, with related attributes and child records1

A list with forty attributes loads them for every row the user scrolls past. A details datasource loads them for one record. Pagination and Performance has the numbers.

The five forms at a glance
#

In the schemaIn the requestIn the row
descriptiondescriptionitem.description
asset.descriptionasset.descriptionitem.asset.description
asset.description--assetdescasset.description--assetdescitem.assetdesc
rel.woactivity{taskid,description}rel.woactivity{taskid,description}item.woactivity, a list
computedLine with computed-functionnothingitem.computedLine

What to read next#

Saving and Updating Data shows what the schema does at the other end: its attributes are what a save asks Maximo to return. Selecting Data with oslc.select covers the same forms on the level of the REST API.


IBM documents <schema> and <attribute> in the product itself. In the Application Configuration application, open the ? menu and choose Component Documentation. The forms of a select list are described in IBM’s documentation of the Maximo REST API.