# openEHR archetypes as SQL Tables

**URL:** <https://discourse.openehr.org/t/openehr-archetypes-as-sql-tables/11412>\
**Category:** General Discussion\
**Tags:** aql, archetype\
**Created:** [22 September 2025 12:11 UTC](https://discourse.openehr.org/t/openehr-archetypes-as-sql-tables/11412 "2025-09-22T12:11:45Z")\
**Posts on this page:** 1\
**Showing post:** 53

<div class="post-metadata">

**Author:** ![Sidharth\_Ramesh](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sidharth_ramesh/32/674_2.png) [@Sidharth\_Ramesh](https://discourse.openehr.org/u/Sidharth_Ramesh)\
**Post date:** [24 October 2025 14:28 UTC](https://discourse.openehr.org/t/openehr-archetypes-as-sql-tables/11412/53 "2025-10-24T14:28:16Z")

</div>

I believe the path you’re talking about @matijap has been taken many times, and I’ve read a few papers on people trying to implement the entire openEHR protocol or ISO 13606 using a SQL RDBMS - and they typically have all the pitfalls you and @birger.haarbrandt mention. Usually building the AQL engine is very challenging, and not even attempted. The SQL queries are pretty complex too - even when implemented on JSONB.

Here’s where the approach I’m suggesting diverges significantly from previous efforts in the space:

I’m NOT saying we should implement the openEHR RM and all of its requirements and nuances into a SQL database and expect everything to just work.

But instead, recognise that the real value that openEHR brings to the Health IT community are the maximal clinical data models not the accidental complexity it has introduced in the implementation of this idea.

The spirit of these data models can be implemented in a SQL database trivially if the data modelling techniques were modified to reflect traditional database modelling techniques instead of the complexity we’ve introduced with archetypes and templates. We know because - our team has already translated close to 800+ archetypes into simple SQL tables and it’s possible. There are still many issues in how archetype doesn’t fully respect normalisation principles in a lot of places, but we had to fix these.

This approach is more similar to what OMOP has done, but instead of a few observational entities for research, think all clinical entities.

And an organisation doesn’t need to import all of the table definitions at once and have 1000+ tables. They only pick and apply those they need.

Once you have this logical SQL table definitions in place, my argument is that API technology, RLS, and Postgres wire-protocol native databases have advanced enough to use the authenticated SQL layer directly as the API for multiple apps to interoperate. Or you can have teams pick a REST/GraphQL layer of their choice that autogenerates APIs from the data models (PostgREST, Postgraphile, Hasura - pick any).

This way, openEHR provides what it is really good at - the data models in a format that’s accessible to the general population of developers and this works with the general tools and frameworks available to everyone.

---

_[View the full topic](https://discourse.openehr.org/t/openehr-archetypes-as-sql-tables/11412)._
