User Tools

Site Tools


Sidebar

Dokumentation

vortex:examples:defining_relations

Defining relations in a Vortex instance

This guide will show you how to setup and define relations between tables in a Vorted DBI.

Requirements

  • A working Vortex DBI
  • At least two tables to create relations between, here called Table1 and Table2
  • Knowledge on how to create and edit records in the Vortex

Overview

In the Vortex there are three types of relations between tables.

  • 1-1 relations, where one record in Table1 refers to exactly one record in Table2, for instance one social security number relates to a person in this way, as one person can only have one number and one number only refers to that same person
  • 1-x relations, where one record in Table1 refers to many records in Table2, but where that record in Table2 only refers to the one record in Table1. For example a person relates to cars in this way, where one person can own many cars but a car can only have one owner.
  • x-x relations, where many records in Table1 referes to many records in Table2. For example users relate to groups in this way where one user can relate to many groups, and one group to many users

Relation fields

For the first two relation types, 1-1 and 1-x, the record on the 1-side contains a field pointing to the related record, where the record on the x-side doesn't have this field but instead has a list of related records.

  • For 1-1 relations, both sides has a relation field
  • For 1-x relations, the 1-side record has a relation field

To create a relation field, simply create a field in the table of type Relation and give it a suiting name and description.

Setting up the relation

When the required tables and fields are created, open the Admin menu and choose Relations. An in detail description of relations is given in the User Manual

  1. Choose the first table in the Table1 column
  2. Enter a name for the first table in Name1, ie what is related, would be owner if Table1 was a car having one owner
  3. Enter a description for the first table in Description1, would be My Owner in the example above
  4. Choose the second table in the Table2 column
  5. Enter an name for the second table in Name2, would be cars in the example above
  6. Enter a description for the second table in Description2, would be Cars owned by person in the example
  7. Choose a type in the Type dropdown list, for the cars/owner example above this would be 1-x
  8. If the type is 1-1 or 1-x, choose the related field in Field1, would be the owner field in the car table in the example. Choose this by right-clicking the i symbol and choosing Field, only relation fields are shown in the list.
  9. If the type is 1-1, choose the related field from the second table in Field2

Observe that it is very important that the right field for the right table is chosen in the Field columns, otherwise behaviour of theese tables will be erratic!

Saving the relation makes the connection between the tables active.

vortex/examples/defining_relations.txt · Last modified: 2019/06/28 07:20 by hubbe