Re: domains, types, constraints - Mailing list pgsql-novice

From Andrew Winkler
Subject Re: domains, types, constraints
Date
Msg-id 698627.31080.qm@web52710.mail.re2.yahoo.com
Whole thread Raw
In response to domains, types, constraints  (Andrew Winkler <the_andrew_winkler@yahoo.com>)
List 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

pgsql-novice by date:

Previous
From: Tjibbe
Date:
Subject: pgsql 7.3.2 updating FOREIGN KEYS after transaction
Next
From: Jeff Willden
Date:
Subject: Indexes and sequences