Skip to content

Commit 8355677

Browse files
Merge pull request #37 from omkar-ethz/relationships
docs: add guide on dataset's relationships
2 parents 862c0c1 + 60142f7 commit 8355677

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

87.3 KB
Loading

docs/datasets/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Generally, actions depend on what is implemented at your site and can cover a wi
1010
comprising them into a *new datacollection of a custom type* [(see advanced documentation)](../datasets/datasetTypes.md) to
1111
using that selection of datasets to *run an analysis* on them.
1212

13+
Datasets can also store **relationships** to other datasets or external entities, e.g. a logbook entry or a journal article. See [relationships](relationships.md) for details.
14+
1315
## How to search for datasets
1416
Datasets can be queried in several places:
1517

docs/datasets/relationships.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Relationships
2+
3+
Datasets can store **relationships** to other entities, either other datasets in the same SciCat catalog or entities outside of it, e.g. a [SciLog](https://scilog.readthedocs.io) logbook entry, a journal article (via DOI) or an arXiv preprint. Previously, relationships could only point to other SciCat datasets; the schema was generalized to support external entities too, see [backend PR](https://github.com/SciCatProject/backend/pull/2661).
4+
5+
Relationships are displayed on the dataset detail page in a dedicated **Relationships** tab, see [frontend PR](https://github.com/SciCatProject/frontend/pull/2416).
6+
7+
The schema is inspired by DataCite's [relatedIdentifier](https://datacite-metadata-schema.readthedocs.io/en/4.7/properties/relatedidentifier/) property, where `identifierType` roughly corresponds to DataCite's `relatedIdentifierType`, `relationship` to `relationType`, and `entityType` to `resourceTypeGeneral`.
8+
9+
## Relationship fields
10+
11+
Each entry in a dataset's `relationships` array describes a link to one related entity:
12+
13+
| Field | Required | Default | Description |
14+
| --- | --- | --- | --- |
15+
| `identifier` | yes | - | Identifier of the related entity, e.g. `https://example.org/datasets/123`, `10.1016/j.epsl.2011.11.037`, `arXiv:0706.0001`. |
16+
| `identifierType` | no | `Other` | Type of the `identifier`, e.g. `URL`, `DOI`, `arXiv`. `Local` may be used for SciCat-internal identifiers. |
17+
| `relationship` | no | `IsReferencedBy` | Nature of the relationship between this dataset and the related entity, e.g. `IsReferencedBy`, `IsSupplementTo`, `IsCitedBy`. |
18+
| `entityType` | no | `Other` | Type of the related entity, e.g. `Dataset`, `Logbook`. |
19+
| `externalId` | no | - | Identifier of the related entity within its own external system. Not used for SciCat-internal relationships. |
20+
21+
If `identifierType` is set to `URL`, the `identifier` must be a valid URL, otherwise the request is rejected.
22+
23+
`Local` is currently just a naming convention, reserved for possible future support for linking SciCat-internal entities through `relationships`; it has no special handling today. Existing SciCat-internal links, e.g. to instruments or samples, are handled through the dataset's own `instrumentIds` and `sampleIds` fields, not through `relationships`.
24+
25+
## Viewing relationships in the UI
26+
27+
If enabled, the dataset detail page shows a **Relationships** tab listing all relationships of the dataset in a table, with client-side pagination and sorting. Identifiers of type `URL` or `DOI` are rendered as clickable links, other identifier types are shown as plain text.
28+
29+
![Relationships tab](img/dataset_relationships_tab.png)
30+
31+
The tab's visibility is controlled by the `datasetRelationshipsEnabled` frontend config key, see the [frontend configuration guide](../frontendconfig/index.md).
32+
33+
## Example usage
34+
35+
Relationships can be added or updated via `PATCH /api/v4/datasets/:pid`, for example to link a dataset to a SciLog logbook and a journal article:
36+
37+
```json
38+
{
39+
"relationships": [
40+
{
41+
"identifier": "https://scilog.example.ch/logbooks/6895bea625f055bca783dfdd",
42+
"identifierType": "URL",
43+
"entityType": "Logbook",
44+
"externalId": "6895bea625f055bca783dfdd"
45+
},
46+
{
47+
"identifier": "10.1016/j.epsl.2011.11.037",
48+
"identifierType": "DOI",
49+
"entityType": "JournalArticle"
50+
}
51+
]
52+
}
53+
```
54+
55+
Since `relationships` is an array, a `PATCH` request replaces the whole array rather than merging individual entries. If two clients patch it concurrently without coordination, one update can silently overwrite the other. To avoid this, send the `If-Unmodified-Since` header with the dataset's last known `updatedAt` timestamp: the backend enforces this precondition atomically and responds with `412 Precondition Failed` if the dataset was modified in the meantime, see [PR](https://github.com/SciCatProject/backend/pull/2685).

0 commit comments

Comments
 (0)