Uploading JSON/CSV Data into a Custom Database Structure

Hello Bubble Community,

I am currently working on a project where I need to upload data from JSON/CSV files into a custom database structure that I have created in Bubble. The database, named CSVFILE, contains the following fields:

  • USER_ID
  • DATA_ID
  • COLUMN_NAME
  • COLUMN_VALUE
  • DATA_TYPE

My goal is to import each row from the JSON/CSV files into this database in a specific format. For example, consider the following CSV table:

name, age, email
john, 30, john@example.com
jack, 36, jack@example.com

I would like each row from this table to be entered into my database in the following manner:

user_id, data_id, column_name, column_value, data_type
1, 01, name, john, text
1, 01, age, 30, number
1, 01, email, john@example.com, text

In this format, each cell from the CSV is transformed into a separate record in the database, with the appropriate data_type (text, number, etc.) assigned based on the content.

I am seeking advice on the best way to achieve this in Bubble. Specifically, I am looking for guidance on:

  1. Efficiently importing data from CSV/JSON into the Bubble database.
  2. Dynamically assigning data_type based on the content of each cell.
  3. Ensuring that each cell becomes a unique record in the database, structured as per my requirement.

Any insights, tips, or pointers to relevant resources or examples would be greatly appreciated. Thank you in advance for your help and support!

Best regards,
Netanel

Such database structure is known as entity-attribute-value model:

There are a lot of disadvantages to this model, for example:

  • single storage data type for all modelled data types, i.e. storing numbers and dates in a text field
  • Bubble’s automatic indexing would be inefficient with the mixed data types in the same field
  • having to pivot whenever using the data (i.e. complicated search expressions)
  • not easy to express relationships between attributes

The main reason to choose this model is when you expect an unknown number of attributes.

For common attributes (age, name, email) I suggest using a more usual structure (each attribute in its own field) and only using E-A-V for those attributes that change, equivalent to a table of “other” stuff.

I greatly appreciate your reply.

As you indicated, I am compelled to utilize this structure since I have no idea which table the edge user would upload. Since the bubble database is constrained, I need to come up with a method for dynamically saving user tables.

Do you know how to accomplish this? I would adore to hear.

Check this plugin @Netanelyasi

Hey.

I know the plugin. It is still limited.

I want to do this in JS or a structured foundation

Do you know?

Netanel

Does the upload need be done in the front end or can it be done via the editor’s data base?

For this you can upload CSVs via the upload option in the editor. Then you can establish a database trigger that detects new entries and does the parsing you need to dynamically assign the data_type which I assume is a text field.

Another method could be to build an endpoint where you send a POST with your JSON and have Bubble do the creation and parsing of the records.

This topic was automatically closed after 70 days. New replies are no longer allowed.