Creating new tables for each user automatically

I am trying to use Backendless for a scenario that needs a new set of tables for each user. I am looking for
“The best way to clone two existing tables, e.g., T1 and T2 where T2 has 1-n relation with T1 for each new user. The result should be, for instance, T1_user1, T1_user2 …. And T2_user1, T2_user2 ….”
I have looked at an old blog about Backendless Console API, but it seems to be a non-official method that was not even recommended ( May 2019).
Any suggestions?

Hi @Farhad_Abtahi,

Welcome to our community!

We do not have “Clone DB Table API”, and there is no way to do it without the usage of the unrecommended for the production Console API.
May I ask why you need to clone tables? This sounds like something a little wrong, I think you should reconsider the architecture of how you store data in the database.

Regards,
Stanislaw

Hi @stanislaw.grin

Thanks, I am excited about Backendless.
I have two tables with measurement data from a set of sensors, creating one new data record per second corresponding to 36,00 records per hour and 28,800 for 8 hours per day.
To manage the performance, we want to use a different table for each user. We also consider the 400,000 limits for the objects in a table.
Do you have any alternative suggestions?

Regards,
Farhad

May I also ask you which operations in the future you think will not show high performance with the approach with a single table for all users? Do you think that the operation of saving sensors data itself will slow down or fetch from this table later? And what is the reason for the 400,000 objects limit?

Thanks for prompt replies :slight_smile:

We are mostly concern about fetching from the database. The frontend app will get many queries for generating statistics comparing different time intervals etc., for each user. The data can grow very fast for a user if they want to keep their data for a year.
We are making an MVP for our startup and, hence, trying to find the optimum architecture with fewer costs and high performance now but can be expanded later. Data objects in a table 400,000 is a limit for CLOUD 99. And from phrasing seems to be for each table/user and then for additional 200,000 objects, it will be 10 USD/month. Right?
Can you also give me a hint about the cost of Backendless Pro Limitless?

Regards,
Farhad

Hi Farhad,

How many users do you anticipate to have? Is it in hundreds, thousands, hundreds of thousands? Knowing that information would help to estimate the cost.

Regards,
Mark

Hi Mark

It will be in hundreds in the near future, but I hope to be ready for thousands.
Perhaps for hundreds of thousands, we might need to redesign our solution.

Regards,
Farhad

@Farhad_Abtahi, here is a way on how to implement automatic tables creation:

  1. The API for creating new objects contains the name of a data table. If the table does not exist, Backendless automatically creates it. Each property of the object(s) in the request is validated against the table schema. If a property does not have a matching column, Backendless also automatically creates it.
    If you disabled “Dynamic Schema Definition”, enable it. By default, it’s enabled.
  2. When saving objects, use the following API in order to create a proper relation column and its data on-the-fly:
    Set Relation with objects - Backendless SDK for JavaScript API Documentation
    Backendless.Data.of('TABLE-NAME').setRelation(parentObject, relationColumnName, childrenArray)

If the column does not exist in the parent table at the time when the API is called, the value of the "relationColumnName " argument must include the name of the child table separated by colon and the cardinality notation. The cardinality is expressed as ":1 " for one-to-one relations and ":n " for one-to-many relations. For example, the value of "myOrder:Order:1 " will create a one-to-one relation column "myOrder " in the parent table. The column will point to the Order child table. Likewise, the value of "myOrder:Order:n " will create a one-to-many relation column "myOrder " pointing to the Order table.

Keep in mind that the Cloud99 plan is limited to 200 tables and you can buy 50 additional tables for $25 in our marketplace.

Let me know if you have any questions.

Regards,
Stanislaw

1 Like

Thanks, @stanislaw.grin I saw this solution somewhere but It was missing the relationship part. It should work :slight_smile:

just as input:

i made a test to query a table that have over 13.4 mil records and its executing a query that return 100 objects in 24.689ms.

Backendless is lightening fast. don’t worry

im on Pro version