RE: [PHP-DB] store an array in a mysqldb

2001-08-31 Thread Peter J. Krawetzky

If you are setting up a true relational database, arrays would be stored in
a seperate table with a unique key.  Each part of the array would be a
seperate row.  This is called normalization.  If you are doing it for fun,
then you could place some type of seperator (like a comma, semicolon, etc)
between each array field.

Here is an example:
FATHER TABLE:
COLUMNS:FIRST_NAME
LAST_NAME
AGE

A father can have many children which would be your array.  An Array is
really a repeating group of information.
CHILD TABLE:
COLUMNS:FATHER_FIRST_NAME
FATHER_LAST_NAME
CHILD_FIRST_NAME
CHILD_LAST_NAME
CHILD_TITLE

Your tables could have the following information:
FATHER TABLE:
FIRST_NAME  LAST_NAME   AGE
johndoe 39
sam green   44

CHILD TABLE:
FATHER_FIRST_NAME   FATHER_LAST_NAMECHILD_FIRST_NAME   
 CHILD_LAST_NAME TITLE
johndoe robert  doe
 [spaces]
johndoe jennifer   
 doe [spaces]
johndoe sam
 doe [spaces]
sam green   sam
 green   jr
sam green   kelly  
 green   [spaces]

The index on the child table would be every column to make it unique.  If
you want to select each child for john doe, your query would look like this:
select child_first_name,child_last_name_title from child where
father_frist_name = 'john' and father_last_name = 'doe';

This is a very simiplified example.  You would need to taylor it for your
own needs.

-Original Message-
From: Jeroen van Bussel [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 30, 2001 10:43
To: [EMAIL PROTECTED]
Subject: [PHP-DB] store an array in a mysqldb


I would like to know if it is somehow possible to store an array in a mysql
DB.

Could somebody please help me.

greetz Jeroen



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] store an array in a mysqldb

2001-08-30 Thread Justin Buist

Nothing comes to mind that isn't a bit of a "hack" really.  You could try
seperating the data with delimiters before putting it in, then splitting
the data back up into an array at query time.

You could setup some tables, one called 'arrays' and one called
'array_values".

Arrays would pretty much be one column -- just the id.  Array_values would
be 4 columns (3 if order doesn't matter) with: array_value_id, array_id,
value, sequence (optional).

However, I should probably note last I knew PostgreSQL supports the
insertion of arrays into a record natively... though I have never
personally used it.

Justin Buist
Trident Technology, Inc.
4700 60th St. SW, Suite 102
Grand Rapids, MI  49512
Ph. 616.554.2700
Fx. 616.554.3331
Mo. 616.291.2612

On Thu, 30 Aug 2001, Jeroen van Bussel wrote:

> I would like to know if it is somehow possible to store an array in a mysql
> DB.
>
> Could somebody please help me.
>
> greetz Jeroen
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] store an array in a mysqldb

2001-08-30 Thread Jeroen van Bussel

I would like to know if it is somehow possible to store an array in a mysql
DB.

Could somebody please help me.

greetz Jeroen



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]