TinyBase logoTinyBase

Relationship

The Relationship type represents the concept of a map that connects one Row object to another, often in another Table.

{
  remoteRowId: {[localRowId: Id]: Id};
  localRowIds: {[remoteRowId: Id]: Ids};
  linkedRowIds: {[firstRowId: Id]: Ids};
}
TypeDescription
remoteRowId{[localRowId: Id]: Id}
localRowIds{[remoteRowId: Id]: Ids}
linkedRowIds{[firstRowId: Id]: Ids}

The Relationship has a one-to-many nature. One local Row Id is linked to one remote Row Id (in the remote Table), as described by the setRelationshipDefinition method - and one remote Row Id may map back to multiple local Row Ids (in the local Table).

A Relationship where the local Table is the same as the remote Table can be used to model a 'linked list', where Row A references Row B, Row B references Row C, and so on.

Note that the Relationship type is not actually used in the API, and you instead enumerate and access its structure with the getRemoteRowId method, the getLocalRowIds method, and the getLinkedRowIds method.