How can I create an array column in the database?

I am trying out Backendless and have data I would like to import in to the database. When I either try to import the csv data or try to create a new column from scratch I see no choice to designate a column as an array data type. Is this not supported? Is there a way to create a column containing an array of numbers, strings, or objects in the database?

Some additional info, just tried to import the follow data, when specifying the column types I just left the array column as “string”. Here is the csv data:

“category_name”,“category_id”,“subcats”
“Art”,30,[“1”,“2”]
“Wine”,40,[“1”,“2”]
“Movies”,50,[“1”,“2”]
“Music”,60,[“1”,“2”]

Here is the result of the import that was emailed to me:

1 21:32:54 IMPORT_DATA Importing Started.
2 21:32:55 IMPORT_DATA Start import table: categories_be_test_arr
3 21:32:55 IMPORT_DATA Error inserting row to table categories_be_test_arr com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry ‘2]’ for key ‘PRIMARY’
4 21:32:55 IMPORT_DATA Error inserting row to table categories_be_test_arr com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry ‘2]’ for key ‘PRIMARY’
5 21:32:55 IMPORT_DATA Error inserting row to table categories_be_test_arr com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry ‘2]’ for key ‘PRIMARY’
6 21:32:55 IMPORT_DATA Table ‘categories_be_test_arr’ was imported at 0 seconds
7 21:32:55 IMPORT_DATA Finish import table: categories_be_test_arr
8 21:32:55 IMPORT_DATA Importing Finished.
I’m hoping there is some easy way to get an array column in to the DB.

Hi GregMc,

Arrays are supported only for relations. See the “Relations” section in the doc:

http://backendless.com/documentation/manage/mgmt_import.htm

The best way to learn how to forma the CSV data is to create a few tables by hand, define relations, add a few records and then do export.

Regards,
Mark

Hi Mark, I read through that section but still did not see any mention of arrays so I’m still confused. Are you saying that it is not possible to store an array in a DB column and that if I want to have a list of items for a column the only way to do that is to have a one to many relation with a separate table?

Can you let me know what DB is being used for Backendless, is it mongoDB?

We do not support arrays of primitive values as a native primordial type. If you want to have a list of primitive items (ints, strings, dates), you could store them as a JSON string and then parse it into an array when it arrives from the server.

Backendless uses a combination of MariaDB and mongoDB, but in the spirit of mBaaS that is really irrelevant because you consume the persistence function as a service through the APIs.