This guide explains what relationships are inside if Adalo, the different types available, when to use them, and when to use alternative approaches like join collections for better performance.
Introduction
Adalo is a relational database, meaning you can create relationships between one collection and another collection to link records together. Understanding relationships is crucial for building scalable, efficient apps in Adalo.
What Are Relationships?
A Relationship is a connection between two collections that allows you to link records together and access related data. Instead of duplicating information across multiple collections, relationships let you reference data from one collection within another. In Adalo, this is done with MagicText and flyouts via Lists or Available Screen Data.
Real-World Example
Consider a fitness app where you have a Users collection and a Workouts collection. Instead of storing a complete copy of each user's data in every workout record, you create a relationship between them. This way, a single workout record can reference a user, and Adalo automatically pulls in the user's information when needed.
Terminology: Adalo vs Coding
If you have experience with traditional databases and SQL, you might use different terminology than Adalo. Here's how they compare:
Concept
Adalo Term
SQL/Coding Term
Data container
Collection
Table
Individual item
Record
Row
Data property
Property
Column
Connection between data
Relationship
Foreign Key
How to Use Relationships
Creating a Relationship Property
In your collection settings, click the "+" button to add a new property
Select "Relationship" as the property type and select the collection it connects to.
Choose relationship type - This can't be changed in the future.
Accessing Related Data in Your App
Once you've created a relationship, you can access related data throughout your app using flyouts.
Many-to-One or One-to-Many
Parent Properties can be accessed via the Child record MagicText flyout.
Parent record MagicText flyout will only show count when attempting to access the child record properties.
Many-to-Many
M-M record MagicText flyout will only show count when attempting to access the child record properties.
Performance Considerations
While relationships are powerful and convenient, they come with performance costs. Each relationship property you add to a collection increases the amount of data Adalo must load and process each time a record is accessed.
Explore the three different types of relational properties available in Adalo below: