RE: [PHP-DB] store an array in a mysqldb
| From: | Peter J. Krawetzky | Date: | Fri, 31 Aug 2001 09:17:44 +0000 |
| Subject: | RE: [PHP-DB] store an array in a mysqldb | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-12023@lists.php.net to get a copy of this message | ||
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
john doe 39
sam green 44
CHILD TABLE:
FATHER_FIRST_NAME FATHER_LAST_NAME CHILD_FIRST_NAME CHILD_LAST_NAME TITLE
john doe robert doe [spaces]
john doe jennifer doe [spaces]
john doe 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:add@zeelandnet.nl]
Sent: Thursday, August 30, 2001 10:43
To: php-db@lists.php.net
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: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net