I published the example here: https://github.com/bjornna/openehr-conformance/blob/master/aql/example_comp_obs.adoc
The example illustrates how contains
has two different semantic meanings.
In the first example it is used as a filter on data. In example 2 it is used as an inner join on data. The interpretation depends on how the client defines the select.
One way to implement the datastructure above might be with a simple database model. Two tables where needed. COMPOSITION and OBSERVATION .
Simple databasemodel for the example
Table COMPOSITION
|----|
| ID |
|----|
| C1 |
| C2 |
|----|
Table OBSERVATION
|---------|
| ID | CID|
|---------|
| O1 | C1 |
| O2 | C2 |
| O3 | C2 |
|---------|
CID = Reference key to the COMPOSITION
SQL equivalent to example 1
select c.ID from COMPOSITION c inner join OBSERVATION o on o.CID = c.ID
SQL equivalent to example 2
select c.ID, o.ID from COMPOSITION c inner join OBSERVATION o on o.CID = c.ID