Support Topics Documentation Slack YouTube Blog

Relation in tables

Hello,
I have a table for data, I want to set a relation between this data table and Users.
I created one column in the data table for DataRelation and connected to the Users table.but when I import data in the data table, There is no value in the DataRelation field, not in the data table and not in the Users table

The path of my tables:
InFlash project -> Cards table and Users table

Hello @saeed_noshadi

How do you import these data tables?
Could you please provide us steps to reproduce your problem and also attach files for import

Regards, Vlad

i posted data to backendless by below code:

  fun dataMap(map: HashMap<Any, Any>) {
    val postAddCardData =
        Backendless.Persistence.of("Cards").save(map, object : AsyncCallback<Map<*, *>> {
            override fun handleFault(fault: BackendlessFault?) {

            }

            override fun handleResponse(response: Map<*, *>?) {
                Timber.e(response.toString())
            }

        })

    return postAddCardData
}

should i handle relations manually?i want to set relations when i insert data to tables

yeah, you have to setup relations manually if you add records in the Console

so I want to set a relation when each item inserts to the table.
for my scenario, the Cards table has a list of cards that the user insert. Each of the cards should have a relation with the Users table. This means every card inserts by a user and that card has a relationship with one of the users.
It is not logical for any user to enter the database by adding a card and dump that card into their credentials

Sorry for confusing you,
I just thought you are trying to insert data using Console.

You have a few options how to setup relations between data objects:

  1. manually, using Backendless Console
  2. using api Set/Add relations
  3. using custom business logic, afterCreate EventHandler, here is doc for JS https://backendless.com/docs/bl-js/bl_eventhandlers_getting_started_js.html

Regards, Vlad

also, if you do requests as logged in user you can use userId from invocation context,
take a look at this https://backendless.com/docs/bl-js/bl_invocation_context2.html

i use backendless in android project

here you go https://backendless.com/docs/android/data_relations_set_add_overview_android.html

also you can write your custom business logic on Java https://backendless.com/docs/bl-java/bl_generating_event_handler_code.html