Re: domains, types, constraints

From: Andrew Winkler <the_andrew_winkler(at)yahoo(dot)com>
To: Andrew Winkler <the_andrew_winkler(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: domains, types, constraints
Date: 2008-01-19 02:45:01
Message-ID: 698627.31080.qm@web52710.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

What I wish I could do is something like this:

create domain value as ( amount numeric(30,9), expressedIn int references currency );
which I can't do because domains can't qualify composite types.

So what I'm trying to do instead is something like

create type value as ( amount numeric(30,9), expressedIn int);
create table values ( v value, foreign key ( v.expressedIn) references currency);

but all the ways I can think of trying it give me syntax errors. Am I out of luck?

My impression of the way the system is organized is that it's architected towards extensibility, so
I'd be interested in looking into what it would take to support this kind of thing, but since I've just
started browsing the sources, I'm not up to speed.

Since types are created automatically for tables, with table constraints added in, they are in particular
effectively domains of composite type, anyway, so all the necessary code is already there somewhere,
as is the necessary grammar. The big question of course, is whether that code is tightly coupled in its
place...

Any guesses at what I'd be looking at, on a scale from crazy-to-even-be-thinking-about-it to no-big-deal?

____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

Browse pgsql-novice by date

  From Date Subject
Next Message Jeff Willden 2008-01-19 22:04:34 Indexes and sequences
Previous Message Tjibbe 2008-01-18 20:48:25 pgsql 7.3.2 updating FOREIGN KEYS after transaction