dbTalk Databases Forums  

Stored Procedure Vs. View / Trigger

comp.databases comp.databases


Discuss Stored Procedure Vs. View / Trigger in the comp.databases forum.



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

Default Stored Procedure Vs. View / Trigger - 11-15-2006 , 04:36 PM






Hi,

This might be a generic question, but when to use trigger and when to
use stored procedures?
Similarly when to use views and when to use stored procedures?


I am going to start working on a financial project which will support
both OLTP and DSS, and will obviously have large amount of data.


Please give me some examples, as i tried reading many theories but its
not helping.


Thanks in advance!


Reply With Quote
  #2  
Old   
Ed Prochak
 
Posts: n/a

Default Re: Stored Procedure Vs. View / Trigger - 11-16-2006 , 10:00 AM







Rose wrote:
Quote:
Hi,

This might be a generic question, but when to use trigger and when to
use stored procedures?
Similarly when to use views and when to use stored procedures?


I am going to start working on a financial project which will support
both OLTP and DSS, and will obviously have large amount of data.


Please give me some examples, as i tried reading many theories but its
not helping.


Thanks in advance!
A TRIGGER, as the name implies is executed when an event triggers it,
such as an INSERT to the table. So the execution is controlled by the
DBMS. Application code may not even be aware of the work done by the
trigger.

A PROCEDURE is a routine that executes in the database server when
invoked by an application call to it. So the execution is controlled by
the application.

So the choice between TRIGGER or PROCEDURE depends on the business
requirements and application design.

There would be little choice between a VIEW and a PROCEDURE. more
likely you have to decide between using a VIEW and a TABLE during the
design of the database. A VIEW is essentially a built in query. It
allows the application to view data in a way that is different then how
it is actually stored. For example, you might design a view for the
inventory table that shows only the stock allocated for shipment, but
not yet sent.

You use a VIEW as if it was another table.

Finally, not to insult you, but if you do not understand these
fundamental concepts, I am really surprised you are working on such a
large, business critical application system. Surely there are more
experienced, senior Developers in your company assigned to your project
that you can learn from?

Ed



Reply With Quote
  #3  
Old   
AMO
 
Posts: n/a

Default Re: Stored Procedure Vs. View / Trigger - 11-16-2006 , 02:35 PM



"Rose" <rose.washington (AT) yahoo (DOT) com> wrote

Quote:
Hi,
This might be a generic question, but when to use trigger and when to
use stored procedures?
Similarly when to use views and when to use stored procedures?
I am going to start working on a financial project which will support
both OLTP and DSS, and will obviously have large amount of data.
Please give me some examples, as i tried reading many theories but its
not helping.
Thanks in advance!
Use a trigger to fire off a process for a given event. Use a stored
procedure to store business logic. In general, a trigger can be simple and
simply call a stored procedure. By putting your business logic in a stored
procedure it is easily accessible by anything that needs to call it. Keep
your triggers simply wherever possible.

Views are used to filter the information a user can see on the raw data
tables and also to format them in a way that is easy for the user to
understand. If the information they need to see comes from several tables,
a view can be put in place to let the user see a simplified formatting of
the data. You can then deny the user access to the actual tables especially
if there is security sensitive information that person should not be seeing.

You will need to readup on OLTP and DSS. These are fairly extensive and
reasonably complex topics.

AMO




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 - 2012, Jelsoft Enterprises Ltd.