dimanche 8 mars 2015

Dynamically add rows to table in sqlite (using objective c)

Just like when adding a new contact in the ios contact app, (like this) you can add multiple phone numbers, I'm trying to add those new numbers to sqlite db. Here's how:


I'm trying to dynamically add new rows to a table in sqlite, using objective c. I so far created this (in macs terminal):



CREATE TABLE contacts(
id INTEGER PRIMARY KEY,
name text
);

CREATE TABLE phone_numbers(
id INTEGER PRIMARY KEY,
contact_id INTEGER REFERENCES contacts(id)
);


Is it correct that every time the user adds a new phone number, it should create a new row phoneNumber text inside the table of phone_numbers? If so, then is it okay that the there will be multiple rows name the same thing? (phoneNumber)


Aucun commentaire:

Enregistrer un commentaire