Skip to content

M2-S2 — Composite read models: a joiner and an aggregate for HR

Section titled “M2-S2 — Composite read models: a joiner and an aggregate for HR”
ModuleM2 — Data across modules
After this session you canGive an audience one list built from several entities, choosing a joiner or an aggregate for the reason the need gives.
TimeFacilitated: 61 min · On your own: 61 min
Before you startM2-S1. The starter’s five applications and two open jobs. Signed in as yourself; Hala Mansour in a private window.
Go deeperCreate a joiner entity · Create an aggregate entity · Link entities

◆ Orientation (1 min) — Read models for people who decide

Section titled “◆ Orientation (1 min) — Read models for people who decide”

HR asked for two lists the starter cannot give: each application shown with its job’s department and deadline, so a recruiter can see which closing jobs still have unscreened candidates; and one worklist with jobs and applications together (R-04). Neither needs new data. Both need the existing data in a new shape. ACD showed you three kinds of virtual entity and built the simplest; here you build the other two and learn to choose.

▤ Concept (4 min) — Joiner, aggregate, and when each is right

Section titled “▤ Concept (4 min) — Joiner, aggregate, and when each is right”

The joiner: one row, several linked entities

Section titled “The joiner: one row, several linked entities”

A Joiner Virtual Entity starts from a primary source and adds Additional Sources, each joined to the primary (or to another additional source) through a relation. Each row carries fields from all of them. A reference field creates its outgoing relation for you, so Job Application’s Vacancy field already links each application to its job.

For each additional source you decide whether it is Mandatory. A mandatory source keeps only the rows that have a match there, like a strict match; otherwise rows are kept even without one. A joiner needs at least one field. People cannot create or archive records through it: they change the sources.

The aggregate: one list, several unrelated entities

Section titled “The aggregate: one list, several unrelated entities”

An Aggregate Entity assembles records from several sources that need not be linked at all. You design its own fields on its Structure tab, then, on the Mapping tab, say for each source where each field’s value comes from: a Source field mapped to the aggregate’s field (Map to field), a fixed value, a calculated expression, or nothing. When a category field uses different options in a source than in the aggregate, Map source category options pairs them up.

flowchart LR
  J["Jobs<br/>Job title · Registration deadline"] -->|"title, due date,<br/>type = Job"| W["HR Worklist<br/>Item title · Item type · Due date"]
  A["Job Application<br/>Full name · Available from"] -->|"title, due date,<br/>type = Application"| W

What to notice: the aggregate owns its field names; each source is mapped into them, and a fixed value tells the reader which source a row came from.

The need sounds like…BuildBecause
“Show another module’s records, perhaps fewer, perhaps editable in a field”ProxyOne source, re-exposed; the only kind people can write through
“Show each X with details of the Y it belongs to”JoinerOne row per primary record, enriched through relations
“One list of X and Y together”AggregateRows from different entities, poured into one shape

Virtual entities are read models: they are rebuilt shortly after each source change, so they lag a little, and a large source makes each rebuild work harder. They cannot have custom indexes. Use them for lists, summaries and reports people read; keep writing on the sources. A workflow stays on its source: a joiner or aggregate record cannot be edited once its source record’s workflow has finished, and archiving a source record archives its virtual copies.

⛏ Lab (22 min) — The Application Pipeline joiner

Section titled “⛏ Lab (22 min) — The Application Pipeline joiner”

Goal. Application Pipeline shows every application with its job’s title, department and registration deadline, for HR.

Before you start. Signed in as yourself.

  1. Open Job Application › Relations. Under Outgoing, find the relation that its Vacancy field created to Jobs. You do not add it; reference fields create it.
  2. Open Administration › Applications › Data Entities › Add Data Entity. Name Application Pipeline, Arabic مسار الطلبات; Choose Module Recruitment System; check the normalized name application_pipeline.
  3. In Data Entity Type, choose Joiner Virtual Entity. In Choose Entity, pick Job Application as the primary source.
  4. Under Additional Sources, add Jobs through the Vacancy relation, and turn Mandatory on. Create the entity.
  5. On its Structure tab, choose the fields: Full name and Available from from Job Application; Job title, Department and Registration deadline from Jobs. Save.
  6. Build the view Pipeline by job on it: Source view Entries, the five fields; Access Permission Authenticated, Select groups HR; Entries list with a Table view sorted by Registration deadline; Entries details. Save and Publish.
  7. As Hala Mansour, open Pipeline by job. Five rows: three for Senior Software Engineer, two for HR Coordinator, each with the job’s department and deadline.

Screenshot pending The Additional Sources section of the Application Pipeline joiner, with Jobs joined through the Vacancy relation and Mandatory on What to notice: the joiner follows the relation the Vacancy field created; Mandatory means an application without a job would not appear.

Check.

  • Application Pipeline is a Joiner Virtual Entity whose primary source is Job Application.
  • Jobs is an additional source through the Vacancy relation, Mandatory.
  • Five fields: two from Job Application, three from Jobs.
  • Hala Mansour sees five rows, each with its job’s department and deadline.

Pass condition. Hala Mansour sees each starter application with its job’s department and registration deadline in Pipeline by job.

If something goes wrong

What you seeWhat to do
Jobs is not offered as an additional sourceThe relation is missing: check Job Application’s Vacancy field points at Jobs.
Joiner entity should has one field at least (the product’s wording)Choose the fields on the Structure tab before saving.
Rows are missingWith Mandatory on, only applications with a matching job appear. All starter applications have one; wait a moment and reload.
Model answer

Application Pipeline is a joiner: primary Job Application, plus Jobs through the Vacancy relation, mandatory. Each row carries Full name and Available from from the application and Job title, Department and Registration deadline from its job. Each of the five starter applications appears once. It is read-only: HR still screens candidates on the application itself.

⛏ Lab (26 min) — The HR Worklist aggregate

Section titled “⛏ Lab (26 min) — The HR Worklist aggregate”

Goal. HR Worklist lists jobs and applications together, each with a title, its type and a due date, sorted by due date (R-04).

Before you start. Signed in as yourself.

  1. Add a data entity HR Worklist, Arabic قائمة أعمال الموارد البشرية, in Recruitment System; normalized name hr_worklist. In Data Entity Type, choose Aggregate Entity.
  2. Pick Jobs as the primary source, then Add source and pick Job Application. Create it.
  3. On the Structure tab, add three fields: Item title (Text, main title), Item type (Text), Due date (Date). Save. (If Save greys out after the Date field, use the Calculated on-and-off workaround.)
  4. Open the Mapping tab and select the Jobs source. Map Job title to Item title (Source field, Map to field), Registration deadline to Due date, and give Item type the fixed value Job.
  5. Select the Job Application source. Map Full name to Item title, Available from to Due date, and give Item type the fixed value Application. Save.
  6. Build the view HR worklist on it for HR: Entries list with a Table view of the three fields, sorted by Due date; Entries details; no create, edit or archive. Under Appearance, Pin to sidebar. Save and Publish.
  7. As Hala Mansour, open HR worklist: seven rows, two of type Job and five of type Application.

Screenshot pending The Mapping tab of HR Worklist for the Job Application source, mapping Full name to Item title and Available from to Due date, with Item type set to the fixed value Application What to notice: each source is mapped into the aggregate’s own three fields; the fixed value is how a reader tells a job row from an application row.

Check.

  • HR Worklist is an Aggregate Entity with Jobs and Job Application as sources.
  • Each source maps a title, a due date and a fixed Item type.
  • HR worklist is published for HR, sorted by Due date, read-only.
  • Hala Mansour sees seven rows of the two types.

Pass condition. Hala Mansour sees the two jobs and five applications in one list, each labelled with its type and sorted by due date.

If something goes wrong

What you seeWhat to do
A row has an empty titleThat source’s mapping for Item title is missing.
Only jobs appearThe Job Application source has no mappings yet, or the change has not been rebuilt: wait a moment and reload.
The view offers Editing entries but saving failsAggregates are read models: changes belong on the source. Turn editing off.
Model answer

The aggregate owns three fields. Jobs maps Job title → Item title, Registration deadline → Due date, fixed Job → Item type. Job Application maps Full name → Item title, Available from → Due date, fixed Application → Item type. Seven rows result: two jobs and five applications. A later summary on HR Worklist could count waiting items by type for HR’s dashboard, because summaries and reports work on virtual entities like on any other.

◇ Worked scenario (2 min) — Three requests, three kinds

Section titled “◇ Worked scenario (2 min) — Three requests, three kinds”

Three requests arrive the same week. Decide each before reading on.

1. Finance wants the list of signed offers in its own module, read-only. Decide. One source (Job Application, those that reached Add employee), re-exposed in another module: a proxy, with a proxy view scoped by a query on the step. A joiner adds nothing here, and an aggregate would invent a shape nobody asked for.

2. The IT manager wants each onboarding checklist shown with the new hire’s company email. Decide. One row per checklist, enriched with data from a linked record: a joiner, but only if a relation links the checklist to New Hires. Your checklist deliberately stores plain values and has no such link, so the honest answer is: add a reference field from Onboarding Checklists to New Hires (both in IT’s module, so independence is kept), then join.

3. The quality team wants one register of every complaint, incident and audit finding, three separate entities with different field names. Decide. Rows from unrelated entities in one common shape: an aggregate, with a fixed Source value per mapping.

The question that decides it: is there one source, one source plus linked ones, or several unrelated ones?

✓ Practice (5 min) — Check your understanding

Section titled “✓ Practice (5 min) — Check your understanding”
PracticeChoose one answer.

A sales director wants every order shown with its customer’s segment and its sales rep’s region. Orders reference both customers and reps. Which do you build?

  1. Explanation for A

    ✗ Incorrect

    Not this one: an aggregate pours unrelated sources into a common list, so customers and reps would appear as rows of their own. See choosing.

  2. Explanation for B

    ✓ Correct

    Correct: one row per order, enriched through the two relations the reference fields created. See the joiner.

  3. Explanation for C

    ✗ Incorrect

    Not this one: a proxy re-exposes one source’s own fields; it cannot bring in fields of linked records. See choosing.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

A joiner of Projects with their Sponsor is missing the projects that have no sponsor yet. What explains it?

  1. Explanation for A

    ✗ Incorrect

    Not this one: without Mandatory, rows are kept even when the linked source has no match. See the joiner.

  2. Explanation for B

    ✓ Correct

    Correct: a mandatory additional source keeps only the rows that have a match there. See the joiner.

  3. Explanation for C

    ✗ Incorrect

    Not this one: a rebuild delay lasts moments, and it would hide new projects of every kind, not only unsponsored ones. See what they cost.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

An aggregate pulls Status from two sources. One uses Open/Closed, the other New/Done, and the aggregate’s own Status uses Open/Closed. Rows from the second source show no status. What fixes it?

  1. Explanation for A

    ✗ Incorrect

    Not this one: it changes another team’s entity to suit a read model. The aggregate has its own setting for this. See the aggregate.

  2. Explanation for B

    ✗ Incorrect

    Not this one: the mapping already offers a pairing of options, which is clearer and needs no formula. See the aggregate.

  3. Explanation for C

    ✓ Correct

    Correct: the pairing translates the source’s options into the aggregate’s. See the aggregate.

Check your answer

The correct answer is C. Open the explanation under each option to see why.

PracticeChoose one answer.

A team wants recruiters to correct a candidate’s phone number directly in HR worklist. What do you tell them?

  1. Explanation for A

    ✓ Correct

    Correct: aggregates and joiners show data; changes belong on the source record. See what they cost.

  2. Explanation for B

    ✗ Incorrect

    Not this one: the view cannot give the aggregate an ability it does not have. See the aggregate.

  3. Explanation for C

    ✗ Incorrect

    Not this one: a joiner is read-only too; only a proxy can write through to its source. See choosing.

Check your answer

The correct answer is A. Open the explanation under each option to see why.

You built a joiner and an aggregate and can choose among the three kinds of virtual entity by the shape of the need. After Module 2 you can build the data side of a multi-module architecture: a second module, a seam between modules, and read models that combine data without copying it.

Next. Data is in place. Module 3 makes it move: chained and cross-module automation, formulas, advanced routing and scheduled jobs.