From: | Christopher Browne <cbbrowne(at)acm(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Using Views |
Date: | 2003-11-30 04:01:14 |
Message-ID: | m31xrqbj3p.fsf_-_@wolfe.cbbrowne.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
After a long battle with technology, shane(dot)dawalt(at)wright(dot)edu (Shane D), an earthling, wrote:
> That sounds find if all you want to do is to populate your
> drop-down list box with selection choices or use the same search
> criteria each time. But if I want to access certain information for a
> particular customer that requires joins and the like, then a view
> would be great. But as far as I know, I am unable to place search
> parameters into a view. Is this false or am I totally missing the
> point of views?
A VIEW is essentially "macroexpanded" into being the query requested,
in more-or-less the manner LISP handles macro expansion.
Suppose I define a view...
create view january_transactions as
select * from transaction_table where trans_on between
'2003-01-01' and '2003-02-01';
I can then narrow things down when I use the view...
select * from january_transactions -- So I'm looking only at Jan
where txn_type in (1, 2, 4);
If there's a "parameter" that you're expecting to use, then that means
that's a field you want to make sure you are selecting so that, when
you use the view, you can throw in a WHERE clause to specify the
"parameter." That's what the "where txn_type in (1,2,4)" part
expresses.
One of the guys I work with is building "data warehouse" application
code; I keep commending that he use VIEWs as much as possible, and
building summary tables only when performance dictates it. And the
way to define the views most usefully is to make them fairly generic.
In most cases, that means that the VIEW should JOIN tables together to
extract useful information. And anything that could be a parameter
should be selected. That way, filtering can be done on the view, and
so the view can be used for multiple reports.
--
output = reverse("moc.enworbbc" "@" "enworbbc")
http://www3.sympatico.ca/cbbrowne/linuxxian.html
"Heuristics (from the French heure, "hour") limit the amount of time
spent executing something. [When using heuristics] it shouldn't take
longer than an hour to do something."
From | Date | Subject | |
---|---|---|---|
Next Message | CSN | 2003-11-30 04:59:31 | permission errors for set authority and schema public |
Previous Message | Doug McNaught | 2003-11-30 03:28:39 | Re: Was: Triggers, Stored Procedures, PHP |
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Browne | 2003-11-30 04:11:16 | Re: *sigh* |
Previous Message | Doug McNaught | 2003-11-30 03:37:06 | Re: *sigh* |