Re: Foreign Key for PHP serialized data - possible? - Mailing list pgsql-general

From Dave
Subject Re: Foreign Key for PHP serialized data - possible?
Date
Msg-id 1d644$470a31d5$453dce02$11656@FUSE.NET
Whole thread Raw
In response to Re: Foreign Key for PHP serialized data - possible?  (Hannes Dorbath <light@theendofthetunnel.de>)
Responses Re: Foreign Key for PHP serialized data - possible?  (Michael Glaesemann <grzm@seespotcode.net>)
Re: Foreign Key for PHP serialized data - possible?  (Richard Huxton <dev@archonet.com>)
List pgsql-general
"Hannes Dorbath" <light@theendofthetunnel.de> wrote in message
news:4707FFF6.7010402@theendofthetunnel.de...
> Dave wrote:
>> What I'm trying to do is to create a foreign key on tb1_column so that if
>> a
>> number in tb2_column changes or gets deleted, it cascades to the
>> appropriate
>> segment of the serialized data.
>> e.g. if an id of Oranges changes from '5' to '24', the  tb1_column rows
>> will
>> get changed in the above example row to:
>> a:5:{i:0;s:1:"9";i:1;s:2:"24";i:2;s:2:"11";i:3;s:2:"100";i:4;s:2:"10";}
>
> No offense, but that sounds like sick application design. Anyway, a
> plphp trigger can do it:
>
> http://www.commandprompt.com/community/plphp
>
>
> --
> Best regards,
> Hannes Dorbath


> No offense, but that sounds like sick application design
Offense taken :)
Well, you don't know the whole picture, so I can see why this would look bad
to you. That's why asked any other ideas.
The problem I need to solve is this:

I have main table with lets say:

11 | Pears
100 | Plums
9 | Apples
5 | Oranges
10 | Cranberries

Now, I need to create another table with options for each of the above. So
for the apples:
ID | colors_available                                 | favourite_color |
kind | favourite kind |  Other similar options ...
9 | red, green, yellow, ...infinity | red | Granny smith, Golden delicious,
... infinity | Granny smith | Other similar values

What I'm trying to do is to keep the options for each froot in one row, as
opposed to creating separate table for colors, kind, etc.
I realize that I could create separate tables for colors, kind, etc, and
separate tables for favourite colors and favourite kind, but this would
involve accessing four different tables in this case. I guess, I can always
set up views with joins, but could not come up with a good way to query this
in a one returned row, e.g.:
ID | Name  |  colors              | fav_col | kind
| fav_kind       |  etc.
11 | Apples | red, green, etc. | red       | Granny smith, Golden
delicious.. | Granny smith | etc.



pgsql-general by date:

Previous
From: Ben
Date:
Subject: Re: Re : Very asynchrnous replication system
Next
From: "Dmitry Koterov"
Date:
Subject: How to make LIKE to use index in "abc%" query?