Re: full featured alter table?

From: "Mattias Kregert" <mattias(at)kregert(dot)se>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: full featured alter table?
Date: 2003-06-17 10:04:16
Message-ID: 02d601c334b7$d0337a80$09000a0a@kregert.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 have to 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 other tables.
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 will be 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 of the 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message sector119 2003-06-17 10:07:57 Re: tsearch - v2 new dict
Previous Message Oleg Bartunov 2003-06-17 09:57:56 Re: tsearch - v2 new dict