Re: full featured alter table? - Mailing list pgsql-general

From Mattias Kregert
Subject Re: full featured alter table?
Date
Msg-id 02d601c334b7$d0337a80$09000a0a@kregert.se
Whole thread Raw
In response to Re: full featured alter table?  ("scott.marlowe" <scott.marlowe@ihs.com>)
Responses RE : full featured alter table?  ("Bruno BAGUETTE" <pgsql-ml@baguette.net>)
List pgsql-general
> > Presentation order should be done at the application level.

I agree.

Use a VIEW for the presentation!

If you use a VIEW for the presentation, then the presentation code can use SELECT * from that view. The code will never
haveto be changed. The VIEW is the presentation - Change the VIEW, and the presentation is changed. 


If you use SELECT * from a table, then you might have to change the code later if you later decide you want to join in
othertables. 
With a VIEW this is not a problem.

If you want the columns from table "customers" in one order for one report and another order for another report, then a
SELECT* from table will never work. ALTER TABLE ...POSITION.. won't help either. 
With a VIEW this is not a problem.

If you want the rows from table "customers" ordered by customer_name for one report and by sales_limit for another
report,then a SELECT * from table will never work because you don't know (on the application level) what columns there
willbe in the table and what they mean. 
With a VIEW this is not a problem.

If you want the column "very_sensitive_personal_opinions_about_this_customer" not to show up in every report, then a
SELECT* from table will never work. 
With a VIEW this is not a problem.

... and so on...


Sure, you (may) have to update the view when you add or drop a column. However, that is *easy* to do, and you get all
ofthe above mentioned positive effects. 


Conclusion: Use SELECT * FROM <view>

The network is the computer.
The view is the presentation.


/Mattias


Tip 4711: The VIEW is the presentation



pgsql-general by date:

Previous
From: sector119@mail.ru
Date:
Subject: Re: tsearch - v2 new dict
Next
From: Joe Conway
Date:
Subject: Re: Damn triggers and NEW