# Elixir Level 4: Data Modelling

> Level 4: Data Modelling of the LoWisa Elixir course: Structs, Protocols, Behaviours. 3 lessons and 9 ideas, each explained in one line.

Data Modelling is level 4 of 16 of the [LoWisa Elixir course](/courses/elixir/). It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

## Structs

- **Structs.** A **struct** is a named map with declared keys: %Order{}: typos caught at compile time.
- **Defaults and enforcement.** Structs declare **defaults** and enforced keys: objects born valid or not at all.
- **Updating structs.** Update syntax rebuilds: %{order | status: :paid}: new value, old one **unchanged**.

## Protocols

- **Protocols.** A **protocol** dispatches by data type: String.Chars, Enumerable: polymorphism for data.
- **Implementations.** **defimpl** implements a protocol per struct: your types joining the ecosystem’s verbs.
- **Protocols versus behaviours.** Protocols dispatch on **data**; behaviours contract modules: two polymorphisms, two jobs.

## Behaviours

- **Behaviours.** A **behaviour** declares callbacks a module must export: the compile-checked module contract.
- **Callbacks.** **@callback** specs document each required function: types included.
- **Swappable modules.** Behaviours make modules **swappable**: the real adapter in prod, a fake in tests, one contract.

## Before and after this level

- **Before:** [Level 3: Functional Design](/courses/elixir/level-3-functional-design/): Pipelines, Higher-Order Functions, Recursion and Transformation.
- **Next:** [Level 5: Processes](/courses/elixir/level-5-processes/): Processes, Messages, Links and Monitors.

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See [Checkpoints and flashcards](/help/checkpoints-and-flashcards/).

## Frequently asked questions

### What does Elixir Level 4: Data Modelling cover?

Structs, Protocols, Behaviours: 3 lessons and 9 ideas.

### What should I know before this level?

The level before it, Level 3: Functional Design, which covers Pipelines, Higher-Order Functions, Recursion and Transformation.

## Learn Elixir on your phone

The first level is free. LoWisa is on Google Play and the App Store.

---

Source: https://lowisa.dev/courses/elixir/level-4-data-modelling/ · Updated 2026-11-25
