|
|
|
---
|
|
|
|
title: 'Links'
|
|
|
|
description: 'This article explains how to create & work with a Links field.'
|
|
|
|
tags: ['Fields', 'Field types', 'Links based types', 'Links']
|
|
|
|
keywords: ['Fields', 'Field types', 'Links based types', 'Links', 'Create links field']
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
`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 multiple `Cities`.
|
|
|
|
- `Belongs-to` - Multiple records in one table can have a single record in another table.
|
|
|
|
- Example: A `City` `Belongs-to` a `Country`.
|
|
|
|
- `Many-to-Many` - Multiple records in one table can have multiple records in another table.
|
|
|
|
- Example: A `Student` can have multiple `Subjects` & a `Subject` can have multiple `Students`.
|
|
|
|
|
|
|
|
:::note
|
|
|
|
- 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 augments `Belongs-to` relationship field in the adjacent table automatically
|
|
|
|
:::
|
|
|
|
|
|
|
|
## Create a link field
|
|
|
|
1. Click on `+` icon to the right of `Fields header`
|
|
|
|
2. On the dropdown modal, enter the field name (Optional).
|
|
|
|
3. Select the field type as `Links` from the dropdown.
|
|
|
|
4. Select the relation type : Either `Has-Many` or `Many-to-Many`.
|
|
|
|
5. Select the table to which the relation is to be established with.
|
|
|
|
6. Configure label to be used for display in the cell. Defaults to `Link`, `Links` (Optional).
|
|
|
|
7. Click on `Save Field` button.
|
|
|
|
|
|
|
|
![image](/img/v2/fields/types/links.png)
|
|
|
|
|
|
|
|
### Cell display
|
|
|
|
The cell will display number of links for a record to the related table.
|
|
|
|
|
|
|
|
![image](/img/v2/fields/links-cell-display.png)
|
|
|
|
|
|
|
|
Clicking on the link-text will open a `Linked Records` modal with the list of links & associated additional information.
|
|
|
|
|
|
|
|
### List linked records
|
|
|
|
|
|
|
|
![image](/img/v2/fields/linked-record-modal.png)
|
|
|
|
|
|
|
|
A brief note about the modal components:
|
|
|
|
1. This modal is displaying linked records for `PENELOPE`
|
|
|
|
2. Icon represents `Many-to-Many` relation
|
|
|
|
3. Linked records belong to `Film` table
|
|
|
|
4. Search bar, to narrow down the list of linked records displayed
|
|
|
|
5. List (cards) of linked records
|
|
|
|
6. To view additional information (expanded record), hover on the card & click on the `<>` icon
|
|
|
|
7. Indicates total records linked
|
|
|
|
8. Pagination bar
|
|
|
|
9. Click on `+ Link more Records` button to add new links : [Read more](#link-new-records)
|
|
|
|
|
|
|
|
### Link new records
|
|
|
|
|
|
|
|
Modal to add new links can be opened by
|
|
|
|
- Clicking on `+ Link more Records` button in the `Linked Records` modal
|
|
|
|
- Clicking on the `+` icon in the cell (appears on clicking on the cell)
|
|
|
|
|
|
|
|
![image](/img/v2/fields/add-link-modal.png)
|
|
|
|
|
|
|
|
A brief note about the modal components:
|
|
|
|
1. Links being created are for `PENELOPE`
|
|
|
|
2. Icon represents `Many-to-Many` relation
|
|
|
|
3. Linked records belong to `Film` table
|
|
|
|
4. Search bar, to narrow down the list of records displayed
|
|
|
|
5. Linked record card is displayed in blue color
|
|
|
|
6. Records available for link are displayed in white color; use expand icon on the cord to view additional information
|
|
|
|
7. Indicates total records linked (including the ones being linked)
|
|
|
|
8. Pagination bar
|
|
|
|
|
|
|
|
:::info
|
|
|
|
Multiple records can be linked at once.
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Unlink records
|
|
|
|
To unlink a record, open the `Linked Records` modal & click on the card of the record to be unlinked.
|
|
|
|
|
|
|
|
:::info
|
|
|
|
Multiple records can be unlinked at once.
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Related fields
|
|
|
|
- [Lookup](020.lookup.md)
|
|
|
|
- [Rollup](030.rollup.md)
|