Re: Design Q.:logic in app or db?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: gry(at)ll(dot)mit(dot)edu, pgsql-sql(at)postgresql(dot)org
Subject: Re: Design Q.:logic in app or db?
Date: 2003-02-26 18:25:00
Message-ID: 200302261025.00360.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

George,

> I have general design question about Postgres usage: How does one decide
> how much, and what parts of logic should go in DB rules, triggers,
> functions, constraints etc, versus what should go in the application?

Ideally, this should be done strictly on the basis of carefully planned design
architecture, where each business rule is implemented at the application
level where it is most effective, such as referential data integrity in the
database and security in the middleware.

Realistically, business logic tends to be implemented in the layer where you
have the most programming expertise. The people on this list are often
expert DBAs, so they implement as much business logic as possible in the
database in the form of views, triggers, and rules. However, I"ve seen
plenty of shops with multiple crackerjack Java programmers and a weak DBA
implementing all of their business logic in the middleware.

> The main thing not done yet is to facilitate ad-hoc queries
> (via odbc excel etc.) from db-naive users: maybe restructuring the
> db to make it simpler, maybe views and functions... The data is
> somewhat complex in structure.

This desired feature would argue strongly in favor of putting as much business
logic as possibly in your database in the form of views and rules. If users
can bypass the interface and middleware, you cannot rely on it to enforce
data integrity and access control.

--
Josh Berkus
josh(at)agliodbs(dot)com
Aglio Database Solutions
San Francisco

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Itai Zukerman 2003-02-26 19:05:17 btree_gist, gint4_union
Previous Message Josh Berkus 2003-02-26 17:08:14 Re: Return type of triger functions from OPAQUE to TRIGGER in 7.3