dbTalk Databases Forums  

Re: [NOVICE] Application using PostgreSQL as a back end (experienced

mailing.database.pgsql-novice mailing.database.pgsql-novice


Discuss Re: [NOVICE] Application using PostgreSQL as a back end (experienced in the mailing.database.pgsql-novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Marcus Engene
 
Posts: n/a

Default Re: [NOVICE] Application using PostgreSQL as a back end (experienced - 11-19-2005 , 04:46 PM






Bill Dika wrote:
Quote:
Thanks Nikola.

Your explanation of layering was helpful. The consensus from you experts
seems to be that I should keep the business rules and logic out of the
database, so I will do that.

Hi,

Just a small note here. I've seen projects where exactly everything is
put into the application, including validations of data and such. The db
was basically a bit bucket with indexes. That turned out to be a
complete disaster. It's much harder to keep track of all validations in
the java/whatever code than letting the db do this for you.

It's very easy to add constraints, foreign keys and such to a db and
that should always be done. There are no excuse what so ever not to.
Everything you can validate (via CHECK(), fk, trigger, whatever) do it.
A db with errors is a nightmare to patch. It's much better to have the
application tell you it won't do an operation and you do a fix rather
than the application inserting errors silently.

Ok, this was the introductionary chapter of any db book. Sorry about
that. ;-)

Best regards,
Marcus

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
Chris Browne
 
Posts: n/a

Default Re: [NOVICE] Application using PostgreSQL as a back end (experienced - 11-26-2005 , 10:45 PM






mengpg (AT) engene (DOT) se (Marcus Engene) writes:
Quote:
Bill Dika wrote:
Thanks Nikola.
Your explanation of layering was helpful. The consensus from you
experts seems to be that I should keep the business rules and logic
out of the database, so I will do that.

Just a small note here. I've seen projects where exactly everything is
put into the application, including validations of data and such. The
db was basically a bit bucket with indexes. That turned out to be a
complete disaster. It's much harder to keep track of all validations
in the java/whatever code than letting the db do this for you.

It's very easy to add constraints, foreign keys and such to a db and
that should always be done. There are no excuse what so ever not
to. Everything you can validate (via CHECK(), fk, trigger, whatever)
do it. A db with errors is a nightmare to patch. It's much better to
have the application tell you it won't do an operation and you do a
fix rather than the application inserting errors silently.

Ok, this was the introductionary chapter of any db book. Sorry about
that. ;-)
There are multiple sorts of "business logic"; this is a pretty eminent
example.

I'd say that "yeah, having constraints, foreign keys, and such would
seem good here." Starting with a database schema that prevents the
data from getting invisibly unclean seems a good thing.

The "business logic" that's really in question is of where/how to
perform the tax calculations. It seems to me that "inside the DBMS"
is quite likely not to be the right answer.
--
(format nil "~S@~S" "cbbrowne" "acm.org")
http://www.ntlug.org/~cbbrowne/linuxxian.html
"In most countries selling harmful things like drugs is punishable.
Then how come people can sell Microsoft software and go unpunished?"
-- <hasku (AT) rost (DOT) abo.fi> Hasse Skrifvars

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.