Links
Links
field type is used to establish relationship between tables & create links to other records.
NocoDB supports following types of relations:
Has-Many
- A record in one table can have multiple records in another table.- Example: A
Country
can have multipleCities
.
- Example: A
Belongs-to
- Multiple records in one table can have a single record in another table.- Example: A
City
Belongs-to
aCountry
.
- Example: A
Many-to-Many
- Multiple records in one table can have multiple records in another table.- Example: A
Student
can have multipleSubjects
& aSubject
can have multipleStudents
.
- Example: A
- Links can be created only between tables in the same database.
- Self-referencing links are supported. (Link to the same table)
- For every
Has-Many
relation defined, NocoDB augmentsBelongs-to
relationship field in the adjacent table automatically
Create a link field
- Click on
+
icon to the right ofFields header
- On the dropdown modal, enter the field name (Optional).
- Select the field type as
Links
from the dropdown. - Select the relation type :
One-to-one
,Has-Many
, ORMany-to-Many
. - Select the table to which the relation is to be established with.
- Advance settings: Configure label to be used for display in the cell. Defaults to
Link
,Links
(Optional). - Click on
Save Field
button.
You can control record visibility in the Link records
modal by limiting the records available for selection. Read more
Cell display
The cell will display number of links for a record to the related table.
Clicking on the link-text will open a Linked Records
modal with the list of links & associated additional information.
List linked records
List of linked records will appear as a dropdown containing linked records as cards. A brief note about the modal components:
- Search bar, to narrow down the list of linked records displayed
- Icon represents
Many-to-Many
relation. The count indicates the number of linked records - List (cards) of linked records
- To view additional information (expanded record), hover on the card & click on the
<>
icon - Click on the
-
icon to unlink the record - Click on
+ New record
button to create and link a new record to the current one - Click on
Link more records
to link an existing record Read more - Pagination bar
Link new records
Modal to add new links can be opened by
- Clicking on
+ Link more Records
button in theLinked Records
modal - Clicking on the
+
icon in the cell (appears on clicking on the cell)
A brief note about the modal components:
- Search bar, to narrow down the list of records displayed
- Icon represents
Many-to-Many
relation. The count indicates the number of linked records - List (cards) of records available for linking
- To view additional information (expanded record) before linking, hover on the card & click on the
<>
icon - Click on the
+
icon to link the record - Click on
+ New record
button to create and link a new record to the current one - Pagination bar
Multiple records can be linked at once.
Unlink records
To unlink a record, open the Linked Records
modal & click on the -
icon on the card of the record to be unlinked.
Multiple records can be unlinked at once.
Limit record selection
This feature enables users to restrict the records available for selection within the Link records
modal. This can be achieved by two modes:
- Limit by view
- Limit by filter ☁
Note that,
- These options are not mutually exclusive & can be used together. When both are used, the records available for selection will be the intersection of the records satisfying all conditions.
- This feature only affects the records available for selection & does not affect the existing links.
- The limit is applied only on the Link records modal & does not restrict the link modification process via API, Copy-Paste or any other mechanisms.
- Limit by filter option is available only in cloud version.
Limit by view
To limit the records available for selection based on a view, follow the steps below:
Steps
- Enable
Limit record selection to view
- Select the view from the dropdown
- Click on
Save Field
button
In the example image above, the records available for selection will be limited to the records available in Trailers
view.
Note that,
- Only one view can be selected at a time.
- Deleting the view associated with links field will disable the limit by view option.
- Change in filters within the view will also reflect records available for selection during linking.
Limit by filter ☁
To limit the records available for selection based on filters, follow the steps below:
Steps
- Enable
Limit record selection by filter
- Configure filter
- Click on
Add filter
button. - Select the field, operator
- Configure value
- Click on
Save Field
button
In the example image above, the records available for selection will be limited to the records available in Trailers
view where rating
is PG
.
Note that,
- Multiple filters can be added.
- Deleting the field associated with links field will disable associated filters.
Filter Type
Conditions in the filter can be of two types: Static & Dynamic.
- Static condition: Filter value is a constant value.
- Dynamic condition: Filter value is a field value from the current record.
Use the ⚙️ icon to the right of the filter to toggle between static & dynamic filter values.
Note that, it's allowed to have a mix of static & dynamic conditions in the filter.