Create table in SQLite with array

1

I am creating a Database in SQLIte and I have 2 tables, a LIST table and other PRODUCTS. The LIST table in addition to the ID numeric , NOME text , fields has a PRODUCT ARRAYLIST. The PRODUCTS table only has ID numeric , NOME text , IMAGEM drawable .

My question is how to create the LIST table in SQLite, if the SQLITE types allowed do not include ARRAYLISTs?

    
asked by anonymous 11.10.2015 / 23:58

2 answers

0

Sqlite does not have the ArrayList type because this does not make sense. The ArrayList is a type that represents a list and a list is represented, in Sqlite (and not only), by a table.

So you should have one table for the list (s) and another for the items in each list.

It will be something like this:

| Listas |
|________|
| Id     |
| Nome   |
|  ...   |
|  ...   |
|________|

|   Itens   |
|___________|
| Id        |
| ListaId   |
| ProdutoId |
| Quantidade|
|    ...    |
|    ...    |
|___________|

The ListaId and ProdutoId fields should be declared as ForeignKey in reference to the Lists and Products , respectively.

    
12.10.2015 / 14:49
0

This table that you call list must have a name type: customers, products, people, airplanes, cars, etc. Name your table in SQLite and only after you have records inside it you can create a list of this table in Java.

Assuming you've created a car table that has its id and name fields, then:

 - ID     NOME
 - 1      OMEGA
 - 2      PASSAT
 - 3      FUSCA

Once you have done this, you just need a list with class Util in Java:

List<Carros> lista_de_carros = new ArrayList<Carros>();
    
12.10.2015 / 04:14