Re: building a row with a plpgsql function - Mailing list pgsql-novice

From Raphael Bauduin
Subject Re: building a row with a plpgsql function
Date
Msg-id 4188E867.6060405@be.easynet.net
Whole thread Raw
In response to Re: building a row with a plpgsql function  (Michael Kleiser <mkl@webde-ag.de>)
Responses Re: building a row with a plpgsql function  (Joe Conway <mail@joeconway.com>)
List pgsql-novice
Michael Kleiser wrote:
>
> Raphael Bauduin wrote:
>
>> Hi,
>>
>> We have a table collectiong all details of an item:
>> Here is a simplified representation of the tables
>> Tables:
>>
>> items
>> ------
>> item_id
>>
>>
>> item_details
>> ------------
>> item_detail_id
>> item_id
>> item_detail_name
>> item_detail_value
>>
>>
>> That way, we can easily have a variable number of detail for the items
>> (some can have 10 details, some only one).
>
>
> Be carefull: With this design, you can't declare any indexes
> and constraints on an item-detail !
> You also can't use different types for the item-details.
> Triggers would be more complicated.
>
> Consider to make the item-details to table-columns.
>

That was our first choice design, but we really need that extreme flexibility with the details.
Item details specs are a moving target, with impossibility to prevent changes.... Items are also very
different, but if we had to have one table per item, it would be unmanageable. New items types are
regularly created too, which would ask the creation of new tables.

About the different types we could have to store as details: we have a table with date details.

I'm also very cautious with that design, and am aware of the risks in it, but
we have thought about it a long time, and it seems to be the best in our situation.
We are in the final stage in this DB design and all tests until now have been positive.

Thanks for the warning anyway ;-)
I'm still open to an alternative solution, but we can't give up the flexibility this design gives us.

Raph

pgsql-novice by date:

Previous
From: Michael Kleiser
Date:
Subject: Re: building a row with a plpgsql function
Next
From: Joe Conway
Date:
Subject: Re: building a row with a plpgsql function