Re: PHP & PostgreSQL

From: Date: Tue, 31 Dec 2002 01:35:35 +0000
Subject: Re: PHP & PostgreSQL
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-129724@lists.php.net to get a copy of this message
At 07:59 AM 12/30/02 -0600, Michael Sims wrote:
On Mon, 30 Dec 2002 04:11:02 -0700, you wrote: , or the types SET and ENUM. I'm not sure what SET is, never used it,
Color set( 'red', 'green', 'blue' ) can contain only the following values:
NULL;    'blue';       'green';      'green,blue';
'red'; 'red,blue'; 'red,green'; 'red,green,blue'; You can enter the color names in any order, but they always come out like this. Only words contained in the set are allowed. You can also look at a set as a number, and do bit manipulation on it. The list of values above are 0 to 7 when used in a numeric context.
but ENUM is totally unnecessary in Postgres because it supports foreign keys.
The big difference using set and enum is in data storage. If you look on the disk you will find both types are stored in the smallest integer they fit in. Even 'red,green,blue' fits in a single byte each time it is stored.
This is more standard anyway, and if you need to update the set there is no need to touch the database schema.
I like being able to define some things in the schema. I have widgets in my toolkit that build arrays of checkboxes, radio buttons or drop down lists based on the values allowed in an enum or set. They get used quite a bit, in fact losing these widgets may be the biggest thing keeping me using MySQL. (Harder prototyping is a close second.) Rick. P.S. Thanks for the info on handling dates!

« previous php.general (#129724) next »