Skip to content

Relations with Data Objects

Backendless Data Service manages application's data objects and provides APIs to work with data objects. Backendless provides integration between data objects managed by Data Service and geo points managed by Geo Service for the scenarios when a logical connection between the two types must exist in an application. For instance, in a taxi ordering app a data object may represent a taxi car, while a geo point represents its location on the map. It is logical to link the two together so they can be retrieved and managed at once.

The Geo-to-Data integration is implemented through geo point metadata. A metadata property may reference one or more data objects. These relations may be created using the API or with Backendless Console. Once a relation is established, the console displays it in the Metadata column as a link to related data object(s). When a geo point is retrieved using the API, any related data objects can be retrieved by using the same principle for loading geo point metadata. The geo-to-data relation is bidirectoral, that is, a data object may reference a geo point through object properties (table columns). You can learn more about it in the Relations with Geo Points  section of the Data documentation.

Apart from linking with the data objects, you can also link a geo point with a user object. Establishing relations with a user objects is performed the same way as with a data object.

Establishing Relations with a Data Object via Console

To link a geo point with a data object:

  1. Click the Geolocation icon to open the Geo location screen.
  2. Select a geo category to get a list of geo points from it.
  3. Click the plus icon for a geo point you want to link with a data object.
  4. The Add Related Object pop-up window will display.
  5. Type in a metadata property name in the Property field. This is the name of a new metadata property which will point to a related data object:
  6. Select a data table from from the Table drop-down menu. If you want to establish relation with a user object, select the Users  table from the drop-down menu. A list of the data objects which belong to the selected table will display.
  7. Select the check-boxes for the data object(s) you want to link the geo point with.
  8. Click the Add Related Objects button to establish a relation and save the changes.

Once a relation is established, the name of the property and the related data table name will display for the geo point:


Updating/Deleting Relations

You can update or delete a geo to data relation by following the same process as above. The only difference is in order to access the"relation management" popup click the yellow box identifying the relation:

Create a Geo to Data Relation with the API

Creating a relationship between a geo point and data objects uses the same API as saving a geo point with metadata. The data object referenced in the metadata is saved in a table in the Data Service storage.

The example below adds a geo point representing a location of a taxi cab. The geo point includes the "TaxiCab" metadata property which references an object from the TaxiCab data table. This is an example of a one-to-one relation (one geo point is related to one data object).

curl -H Content-Type:"application/json" -X PUT \  
-v "" \  
-d '{"latitude":40.750549,"longitude":40.750549, "categories":["Pickups"], \  
 "metadata":{"TaxiCab": {"___class":"TaxiCab", "CarMake":"Ford", "CarModel":"Crown Victoria"}}}'

To link a geo point with multiple data objects (a one-to-many realtion) use an array of data objects as shown below with the availableCabs property:

curl -H Content-Type:"application/json" -X PUT \  
-v "" \  
-d '{"latitude":40.750549,"longitude":-73.994232, "categories":["Pickups"], \  
 "metadata":{"availableCabs": [{"___class":"TaxiCab", "CarMake":"Ford", \  
 "CarModel":"Crown Victoria"},{"___class":"TaxiCab", "CarMake":"Toyota", \