2

How you can see in image i have a TABLE A, TABLE C e an array list A.

I need to create a relational table (Table B) that have id of Table A (id_A) and id of Table C (id_C). The array list have every id's of table C that I need. So i need a way to save data of table B where 1 id_A respect to N elements of id_C.

I know that i can do with inner joins, but i don't know how start this in content provider. Anyone can give a help, or a example?

Thanks or your time

enter image description here

Ricardo Filipe
  • 435
  • 4
  • 8
  • 24

1 Answers1

0

I'm wrong about this point. Inner join serves to make query to database, not to create one table that result of two other.

Here is my solution to do what i pretend, using foreign key's

      private static final String DATABASE_SOCIO_QUOTA = " CREATE TABLE IF NOT EXISTS  "
        + SocioQuota.TABLE_NAME + " ( "
        + SocioQuota.C_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "
        + SocioQuota.C_VALOR + " DOUBLE NOT NULL, "
        + SocioQuota.C_ESTADO + " INTEGER NOT NULL, "
        + SocioQuota.C_SOCIO_ID + " INTEGER NOT NULL, "
        + SocioQuota.C_SESSAO_QUOTA_ID + " INTEGER NOT NULL, "
        + " FOREIGN KEY( " + SocioQuota.C_SOCIO_ID + " ) REFERENCES " +              Table_A + " ( " + Socio.C_ID + " ) "
        + " FOREIGN KEY( " + SocioQuota.C_SESSAO_QUOTA_ID + " ) REFERENCES " + Table_C + " ( " +SessaoQuota.C_ID + " ) "
        + " ) ";

and then save the value for each column of this table

Ricardo Filipe
  • 435
  • 4
  • 8
  • 24