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”| Module | M2 — Data across modules |
| After this session you can | Give an audience one list built from several entities, choosing a joiner or an aggregate for the reason the need gives. |
| Time | Facilitated: 61 min · On your own: 61 min |
| Before you start | M2-S1. The starter’s five applications and two open jobs. Signed in as yourself; Hala Mansour in a private window. |
| Go deeper | Create 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.
Choosing
Section titled “Choosing”| The need sounds like… | Build | Because |
|---|---|---|
| “Show another module’s records, perhaps fewer, perhaps editable in a field” | Proxy | One source, re-exposed; the only kind people can write through |
| “Show each X with details of the Y it belongs to” | Joiner | One row per primary record, enriched through relations |
| “One list of X and Y together” | Aggregate | Rows from different entities, poured into one shape |
What they cost
Section titled “What they cost”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.
- 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.
- Open Administration › Applications › Data Entities › Add Data Entity. Name
Application Pipeline, Arabic مسار الطلبات; Choose Module Recruitment System; check
the normalized name
application_pipeline. - In Data Entity Type, choose Joiner Virtual Entity. In Choose Entity, pick Job Application as the primary source.
- Under Additional Sources, add Jobs through the Vacancy relation, and turn Mandatory on. Create the entity.
- On its Structure tab, choose the fields: Full name and Available from from Job Application; Job title, Department and Registration deadline from Jobs. Save.
- 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.
- 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 see | What to do |
|---|---|
| Jobs is not offered as an additional source | The 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 missing | With 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.
- Add a data entity HR Worklist, Arabic قائمة أعمال الموارد البشرية, in Recruitment System;
normalized name
hr_worklist. In Data Entity Type, choose Aggregate Entity. - Pick Jobs as the primary source, then Add source and pick Job Application. Create it.
- 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.)
- 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.
- 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.
- 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.
- 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 see | What to do |
|---|---|
| A row has an empty title | That source’s mapping for Item title is missing. |
| Only jobs appear | The 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 fails | Aggregates 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”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?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
A joiner of Projects with their Sponsor is missing the projects that have no sponsor yet. What explains it?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
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?
Check your answer
The correct answer is C. Open the explanation under each option to see why.
A team wants recruiters to correct a candidate’s phone number directly in HR worklist. What do you tell them?
Check your answer
The correct answer is A. Open the explanation under each option to see why.
↺ Recap (1 min) — After Module 2
Section titled “↺ Recap (1 min) — After Module 2”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.