In this part of the AEM Headless Developer Journey, you learn how to model your content structure. Then realize that structure for Adobe Experience Manager (AEM) using Content Fragments Models and Content Fragments, for reuse across channels.
At the beginning, Learn About CMS Headless Development covered headless content delivery and why it is used. Then Getting Started with AEM Headless as a Cloud Service described AEM Headless in the context of your own project.
In the previous document of the AEM headless journey, Path to Your First Experience Using AEM Headless, you then learned the steps needed to implement your first project. After reading it, you can do the following:
This article builds on those fundamentals so you understand how to prepare your own AEM headless project.
Data Modeling is a large field, as it is used when developing Relational Databases. There are many books and online sources of information available.
This journey only considers the aspects that are of interest when modeling data for use with AEM Headless.
It’s a big, bad world out there.
Maybe, but maybe not. It is certainly a complicated world out there and data modeling is used to define a simplified representation of a very (very) small subsection, using the specific information that is needed for a certain purpose.
As AEM deals with content, this journey refers to Data Modeling as Content Modeling.
There are many Schools, but they all have various things in common:
Even in such a small example, the list can seem endless. But if you only want your application to perform a simple task, limit the information to the essentials.
For example, advertising special events for all schools in the area:
What you want to describe is referred to as Entities - basically the “things” that you want to store information about.
The information that you want to store about them are the Attributes (properties), such as Name, and Qualifications for the teachers.
Then there are various Relationships between the entities. For example, usually a school only has one head teacher, and many teachers (and usually the head teacher is also a teacher).
The process of analyzing and defining this information, together with the relationships between them, is called Content Modeling.
Often you must start by drawing up a Conceptual Schema that describes the entities and their relationships. Usually this is high-level (conceptual).
After this is stable you can translate the models into a Logical Schema that describes the entities, together with the attributes, and the relationships. At this level, examine the definitions closely to eliminate duplication and optimize your design.
Sometimes these two steps are merged, often depending on the complexity of your scenario.
For example, do you need separate entities for
Head Teacher and
Teacher, or simply an additional attribute on the
Data integrity is needed to guarantee the accuracy and consistency of your content, over its entire life-cycle. This includes ensuring that content authors can easily understand what to store where - so the following are vital:
Data redundancy occurs when the same information is stored twice within the content structure. This should be avoided as it can lead to confusion when creating the content, and errors when querying; not to mention the misuse of storage space.
By optimizing your structure you can improve the performance, both for content creation and querying.
Everything is a balancing act, but creating a structure that is too complex, or has too many levels, can be confusing for authors generating the content. And, it can severely affect performance if the query has to access multiple nested (referenced) Content Fragments to retrieve the required content.
Data Modeling is a set of established techniques, often used when developed relationship databases, so what does Content Modeling mean for AEM Headless?
To ensure that your application can consistently and efficiently request and receive the required content from AEM, this content must be structured.
This means that your application knows in advance the form of response and therefore, how to process it. This is easier than receiving free-form content, which has to be parsed to determine what it contains and therefore, how it can be used.
AEM uses Content Fragments to provide the structures needed for Headless delivery of your content to your applications.
The structure of your content model is:
The Content Fragment Models are also used as the basis of the AEM GraphQL Schemas, used for retrieving your content - more about that in a later session.
Requests for your content are made using the AEM GraphQL API, a customized implementation of the standard GraphQL API. The AEM GraphQL API lets you perform (complex) queries on your Content Fragments, with each query being according to a specific model type.
The content returned can then be used by your applications.
Content Fragment Models provide various mechanisms that allow you to define the structure of your content.
A Content Fragment Model describes an entity.
You must enable Content Fragment functionality in the Configuration Browser so that you can create models.
The model should be named so that the content author knows which model to select when creating a Content Fragment.
Within a model:
AEM provides the following data types for you to model your content:
Two data types provide references to content outside a specific fragment:
This provides a simple reference to other content of any type.
For example, you can reference an image at a specified location.
This provides references to other Content Fragments.
This type of reference is used to create nested content, introducing the relationships needed to model your content.
The data type can be configured to allow fragment authors to:
At the start, you must enable Content Fragment Models for your site. This is done in the Configuration Browser under Tools > General > Configuration Browser. You can either select to configure the global entry, or create a configuration. For example:
See Additional Resources - Content Fragments in the Configuration Browser
Then the Content Fragments Models can be created and the structure defined. This can be done under Tools > General > Content Fragment Models. For example:
See Additional Resources - Content Fragment Models.
Content Fragments are always based on a Content Fragment Model. The model provides the structure, the fragment holds the content.
The first step to actually creating your content is to create a Content Fragment. This is done using Create > Content Fragment in the required folder under Assets > Files. The wizard guides you through the steps.
A Content Fragment is based on a specific Content Fragment Model, that you select as the first step of the creation process.
Once your fragment has been created, you can open it in the Content Fragment Editor. Here you can do the following:
After selecting the appropriate model, a Content Fragment is opened for editing in the Content Fragment Editor:
See Additional Resources - Working with Content Fragments.
For a basic structure as sample, see The Sample Content Fragment Structure.
Now that you have learned how to model your structure, and create content dependent on that, the next step is to Learn how to use GraphQL queries to access and retrieve your Content Fragments content. This introduces and discusses GraphQL, then looks at some sample queries to see how things work in practice.