Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rahul29tech

macrumors member
Original poster
Dec 22, 2011
41
0
create table contacts (id integer primary key autoincrement, name text, address text, phone text);


in above line of code i want to store an array of phone numbers on place of a single number means smething like :-

create table contacts (id integer primary key autoincrement, name text, address text, phone array);


so my queestion is how to create a colon which can save an array object in it????? which data type should i used?????
 
There is no array data type in SQL. Some people get around the problem by using a delimited VARCHAR data type, which in your case look something like:

"xxx-xxx-xxxx; yyy-yyyy-yyyy; zzz-zzz-zzzz;"

Your code would have to parse the varchar string to extract the multiple phone numbers.

However, having multiple values in a single column is against the fundamental tenet of relational model since an attribute in a relation can have only one value drawn from an appropriate type. In other words its bad database design.

A better design would be to move the phone numbers out of the name/address table and put them in a separate table linked to the name/address table. That way each name could have zero to n telephone numbers associated with it.
 
sir , i want to store an nsdictionary object in a colon of each row

thanks sir,

sir is it possible to save an nsdictionary object as an field entry in sqlite? which data type should i take to store nsdictionary or nsarray object???plz suggest me ???????

is it possible by blob data type or any other???
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.