Category Relationships

Learn how to relate elements between categories in Layer using Related Element, Spatial Relationship, and Lookup fields. Build one-to-one, one-to-many, or many-to-many relationships.

Zach Soflin

Sep 24, 2024

Relating Elements between categories in Layer allows you to truly leverage the power Layer to transform and act on your data. Imagine that you have two categories in an employee directory project - Employees and Departments. Employees contains individual elements for each employee working in your firm or company, and Departments contains elements for each team or group that employees are divided into. Layer’s flat data structure means that the implicit link between these two categories isn’t automatic - it must be specified by the user. In turn, Elements retain their original Category structure and classification while also being cross-linked to Elements in other Categories.

In the employee directory example above employees have departments, and departments have employees - the relationship can be viewed and acted upon from either side. Relationships between categories can be either one-to-one, one-to-many, or many-to-many.

How it Works

There are a few different ways to relate elements between categories in Layer - each with their pros and cons. Read on to get a better idea of how to apply these methods in your project.

Related Element Field

A Related Element field is a manual link between two categories. When configuring a related element filed in one category, you specify the other category to which it will connect. In the example above, you would create a related element field in the Employees Category configured to point at the Departments Category. When editing Employee elements, you would have the option to select a Department to tie to that particular Employee. That’s it! A link has been made between the two categories and data can be added. For more information, see the Related Element field page.

Spatial Relationship Field

A Spatial Relationship field is an automatic link between two Model Categories.

Lookup Field

Lookup fields are another way of relating data in Layer. More complex than Spatial Relationship or Related Element fields, they can either build on those two fields to provide more specific data cross-category or automatically build relationships from related pieces of data.