Update ARHUT adding a new dataset tutorial authored by vinnetu's avatar vinnetu
...@@ -68,8 +68,78 @@ Similarly create all your required collections ...@@ -68,8 +68,78 @@ Similarly create all your required collections
--- ---
---
## 5. 🔗 Add Relational Fields Between Collections
To connect your data model and ensure referential integrity, you can create **relational fields** between collections.
### Why Use Relations?
- 🔍 Enables **filtering**, **joining**, and **displaying** related data across collections.
- 🔁 Ensures **data consistency** via enforced foreign keys.
- 🧭 Improves **data navigation** in the Admin UI and APIs.
---
### 🛠 How to Add a Relation (Admin UI)
Example: Link `academic_works.juhendaja` to a `people` collection.
1. Go to **Settings → Collections & Fields → academic_works**.
2. Click **➕ Add Field**.
3. Choose:
- **Field Name**: `juhendaja_id` (or simply `juhendaja`)
- **Type**: `uuid` (or `integer`, depending on the target collection's `id`)
- **Interface**: `Select Dropdown` or `User` if relevant
4. Enable **"This field is a relational field"**.
5. Set relation type:
- 🧍 Many-to-One → A thesis has one supervisor, but a person can supervise many theses.
6. Choose the related collection, e.g., `people`.
7. Save the field.
---
### 📘 Types of Relations in Directus
| Type | Description |
|------------------|--------------------------------------------------|
| One-to-One | A matches B exclusively |
| One-to-Many | A has many B (foreign key in B) |
| Many-to-One | Many A link to one B (foreign key in A) |
| Many-to-Many | Uses a **junction table** (Directus manages it) |
---
### 🔒 Permissions & Access
Ensure you enable appropriate **read** and **create** permissions on both collections **and** the relational field itself in:
> **Settings → Roles & Permissions**
---
### ✅ Tips
- You can display related fields in the list view using **"Display Template"** like:
```
{{juhendaja.first_name}} {{juhendaja.last_name}}
```
- Use **“Field Group”** to organize relational fields for clarity.
- For many-to-many relations, Directus auto-generates a **junction collection** unless you create one manually.
---
### 📖 Reference
- [Directus Docs – Relational Fields](https://docs.directus.io/guides/relationships/)
- [Permissions for Related Items](https://docs.directus.io/guides/permissions/#related-items)
---
## 5. 🗂 Create subfolder for the project ## 6. 🗂 Create subfolder for the project
Similarly and drag your newly created collections under it. (See Kohainfo, TARA etc.) Similarly and drag your newly created collections under it. (See Kohainfo, TARA etc.)
Then navigate to data management->ARHUT settings->Databases (Andmebaasid)(https://db.arh.ut.ee/admin/content/databases) and add a record for the folder to recently added. Then navigate to data management->ARHUT settings->Databases (Andmebaasid)(https://db.arh.ut.ee/admin/content/databases) and add a record for the folder to recently added.
...@@ -77,9 +147,7 @@ Then navigate to related Views (Vaated, https://db.arh.ut.ee/admin/content/views ...@@ -77,9 +147,7 @@ Then navigate to related Views (Vaated, https://db.arh.ut.ee/admin/content/views
## Associate data with other tables
Users should have access to associated tables, otherwise they wont see those connections.
# Create user roles # Create user roles
The roles you should have are The roles you should have are
... ...
......