Looking for some advice

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

Looking for some advice

Post 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
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post 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)
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

Post 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
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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.
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

Post by will83 »

Definately worth looking at. Im just surprised there is no other straight forward way.

Thanks for this.
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

Post by will83 »

Relational Databases was the answer.

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

Thanks for your help.
Post Reply