I'm not a C++ guy, but I don't think the question and answer are specific to
C++.
I would use a child table. Think of the two "columns" in your example as two
tables in your database. In its simplest form, it might be:
create table names (id integer primary key, name);
insert into names (name) values ('Kevin');
insert into names (name) values ('Clark');
select * from names;
1|Kevin
2|Clark
create table numbers (id, number);
insert into numbers values (1, '555-1212');
insert into numbers values (1, '555-1213');
insert into numbers values (1, '555-1218');
insert into numbers values (2, '555-1215');
insert into numbers values (2, '555-1216');
insert into numbers values (2, '555-1219');
Knowing (or querying) Kevin's, or Clark's ID, you would derive his numbers
'array' from the data in the numbers table.
select number from numbers where id = 1; --Kevin's numbers;
555-1212
555-1213
555-1218
Using a join, you could get the numbers by the person's name;
select number from numbers
inner join names on
numbers.id = names.id
and names.name = 'Clark';
555-1215
555-1216
555-1219
There's a lot more can do, but this is the most basic example of storing and
retrieving list attributes in a relational database.
-Clark
----- Original Message ----
From: Kevin Piciulo <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, May 15, 2006 9:30:49 AM
Subject: [sqlite] C++ Arrays in sqlite
Hey everyone,
This may not be the place to ask (if not please direct me.) I'm
relatively new to sql, and newer to sqlite. Through experimenting i've
figured out how to add a string to a table, create a table, remove a
string, some basic stuff like that.
What I'd like to do is add an array to my table. For example: i have
2 columns, Name,and Numbers. Numbers needs to hold an array for each
entry under Name. That is each name has it's own array.
I tried to learn a little about BLOBs, but aside from the fact that
they're Binary Large Objects I didn't find much. Is a BLOB what I'd use
to store information in this way?
I appreciate any help or direction you guys can give.
Kevin