Re: Composite types or composite keys? - Mailing list pgsql-general

From Tony Theodore
Subject Re: Composite types or composite keys?
Date
Msg-id CAD1A9D2-5CA0-4D2E-B6C6-E433D03417AA@gmail.com
Whole thread Raw
In response to Composite types or composite keys?  (Tony Theodore <tony.theodore@gmail.com>)
Responses Re: Composite types or composite keys?
List pgsql-general
On 15 Nov 2013, at 8:04 pm, Chris Travers <chris.travers@gmail.com> wrote:
>
> In general, if you don't know you need composite types, you don't want them.  You have basically three options and
theway you are doing it is the most typical solution to the problem 

The current way is much easier since I discovered the “JOIN ... USING(..)” syntax and I’m tempted to try natural joins.

> Having experience with table inheritance and composite types in tuples, I will say the former has fewer sharp corners
thanthe latter.  
>
> Where composite types really work well is where you want to add functions which take the type as input.  In essence
youcan develop some very sophisticated models with them, but you probably would not use them for storage unless you
haveother considerations in mind. 

Thanks for that, I’ve done some reading on inheritance and it looks like I can create an empty parent table that acts
likea column definition template. This also automatically creates a type that can be used in functions which sounds
likewhat I’m after. There are also scenarios where “product” is a combination of “level" and “id” (where “level” can be
thingslike brand/category/sku) and I’d like to use the same calculations regardless of where it sits in the hierarchy. 

Cheers,

Tony



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: What does this error message mean?
Next
From: Felipe Gasper
Date:
Subject: Re: PGSQL: listing db/role and user/role relationships