how to create a table in sqlite3 ,which containing a colon of type array

Discussion in 'Mac Programming' started by rahul29tech, Apr 2, 2012.

  1. macrumors member

    Joined:
    Dec 22, 2011
    Messages:
    41
    #1
    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?????
     
  2. macrumors 6502a

    Joined:
    Feb 24, 2012
    Messages:
    530
    #2
    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.
     
  3. macrumors member

    Joined:
    Dec 22, 2011
    Messages:
    41
    #3
    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???
     
  4. macrumors newbie

    Joined:
    Mar 8, 2012
    Messages:
    2
    #4
    You can use the software of "Sqlite Developer".
     

Share This Page