Problem Description
I have SQLite database in which I have keep two tables, In first Table Companies I keep company ID which is unique for that company, Name of company, Websites and Emails. Every company can have several addresses, so I create second Table Addresses and keep there company ID which is not unique in this case and other information.
For Example:
If in Companies table I have record like this
7785413 MyComp http://www.mycomp.com [email protected]
In the Addresses table I can have records like this
7785413 0 Address1 +64841518549 +9985212848
7785413 1 Address2 +64841542359 +9985212848
As there is no unique columns in my second Table, I want to know how I can update records? In first case I call
database.insertOrThrow(DATABASE_TABLE_NAME, null, values);
function and if my IDs are same function throws an exception I catch it and update record. I can't do same thing in second Table as there is no unique columns and function will not throw an exception. Which is the best way to do that ?
Tables
CREATE TABLE Companies (ID TEXT UNIQUE, Name TEXT, Websites TEXT, Emails TEXT)
CREATE TABLE Addresses (ID TEXT, Position NUMERIC, Address TEXT, Tel TEXT, Mob TEXT)