What’s the best practice to update joined table using backendless Database API?
This is my need:
I imported data from csv to a temporary table
I want update application’s tables joining them with temp table and, in details:
update existing records (records found in both table)
add new record (records in temp table that aren’t in application’s tables)
delete old record (records in application’s table that aren’t in temp table)
Backendless version 6.4.4
Welcome to our community and thank you for trying out Backendless.
We do not support Inner Join. You can search the two tables with the conditions you need, after which you can perform the actions you need.
you can join the temp table with the application table by relations. Create a relation column in the application’s table, which points to the temp table. Then join records in tables using API
To update existing records in both tables you can use transactions
Find all records that have no relation to the application’s table
delete all records that have no relation to temp
I’ll try with your suggestion.
have a nice day,
not sure to undestand the first part of your response;
I have the situation explained in this image:
with this data, for example, imported on the temp table.
I need to import Customer avoiding duplication; saying that Customer on tmp table is identified by ID, and there are two different names FOR THE SAME ID, I need to select only the first one.
After imported Customer, I need to import Plans (avoiding duplication) generating the relationship between Customer and Plan
I don’t understand how adding join between application’s table and temp table can help.
To understand how to structure the CSVs with related data, I recommend adding a few sample records in each table, establishing relations between them and then running an export of your data on the Manage > Export screen of the app. On the Export screen make sure to select the entire “closure” of the tables. The resulting zip file with all the CSVs will be placed into the
/export directory in the file storage of your app. It will be the best representation of the format you should use to import related data.
at the moment I’ve a Springboard plan…
export not available
I just posted a cookbook article describing how to format relational data in CSVs:
Relational data support is one of the strongest points of the Backendless database system. In some cases, you want to bootstrap your development by bringing some sample (or existing) data into Backendless. This can be done using the import function available on the Manage > Import screen in the Backendless console:
[Manage Import - ConsoleDemo - Backendless 2022-09-09 11-41-17]
When you import data into Backendless database, a single CSV file brings data into a single database table. If the t…
Hope it helps.
Thank you for the cookbook!
Is there a way to call backendkess’s import process from an Api Service?
Let me explain: in my application end user will upload a CSV with all data; at the end of the upload, the application Will call an Api Service to import data in Tables. End user knows nothing of CSV formatting. He periodically will import CSV file on application to update data.