Page 1 of 1

Looking for some advice

Posted: Wed Nov 16, 2005 1:13 pm
by will83
I am building (attemting) an online quote and buy system using php and mysql for our company. I have come to the point where i'm designing the database to record any purchases made.

Its an insurance booking system which will have to take names and ages for anything up to 10 people per booking.

Is it possible to store multiple values in the same table field? - to be later pulled out and seperated for them to be viewed.

I just wander what people suggest as I do not want to end up with creating 10 sets of name and age columns just incase there is a larger than normal booking.

Thanks

Will

Posted: Wed Nov 16, 2005 1:31 pm
by neophyte
You could. I've seen it done before where fields have comma separated data. But it's not the best design pattern in the world. I think it would be better to just use another table(s)

Posted: Wed Nov 16, 2005 1:35 pm
by will83
hmm, I don't really want to use a different table if I can help it.

maybe i'l take a look into the comma thing.

Thanks

Posted: Wed Nov 16, 2005 1:43 pm
by JAM
There is also this idea. Sorry, but it's a standard snippet I use to demonstrate:

Code: Select all

<pre>
<?php
$item[] = 'cow';
$item[] = 'cat';
$item[] = 'evil_smurf_of_doom';
print_r($item);
$newitem = base64_encode(serialize($item));
echo $newitem;
$olditem = unserialize(base64_decode($newitem));
print_r($olditem);
?>
Results:

Code: Select all

Array
(
    [0] => cow
    [1] => cat
    [2] => evil_smurf_of_doom
)

YTozOntpOjA7czozOiJjb3ciO2k6MTtzOjM6ImNhdCI7aToyO3M6MTg6ImV2aWxfc211cmZfb2ZfZG9vbSI7fQ==

Array
(
    [0] => cow
    [1] => cat
    [2] => evil_smurf_of_doom
)
What I'm saying, you might be able to transform the data into something obscure, but still usable before adding it to the db. Then convert it back to usable data after retrieving it. Play around with it.

Posted: Wed Nov 16, 2005 1:48 pm
by will83
Definately worth looking at. Im just surprised there is no other straight forward way.

Thanks for this.

Posted: Wed Nov 16, 2005 5:21 pm
by will83
Relational Databases was the answer.

http://www.edm2.com/0612/msql7.html

Thanks for your help.