473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Cascade updating/deleting and 3 tier architecture

Hi everyone,

Wonder if anyone can shed some light on how i should setup cascade
deletes of object data within my database.

One option is to use SQL triggers, is this a good idea? Should the
logic be in my business layer instead? or maybe even the data access
layer?

I also have the problem when performing an insert. If i insert a
record into one table, i also need to insert other values into foreign
key tables. Again, where do i do this?

This is my first 3 tier application and i am not sure which way i
should set this up, so any help would be greatful.

Thanks in advance

Sep 25 '06 #1
1 1441

I don't think there's really a right answer to this - but I will try to give
my $.02 on the subject. When you split up the work in an n-tier architecture,
there are many different things to do based upon your environment and your
application. You can start out by being rigid on certain techniques, but you
are going to find that you will have to bend the rules a bit in different
scenarios.

#1 - make use of your database engine where appropriate. There are definite
performance gains to be had when you use the database engine to do certain
activities. In other words there are times when you don't want to bring over
data to your middle tier to process it because of speed. A lot of times
writing stored procedures are the way to go when you have to do database
activities with a lot of volume.

#2 - make sure you know where your code is. If you are working in an
environment with multiple developers, a lot of times it's nice to have ALL of
the logic in the middle tier, because everyone knows where to look for the
code. If you start writing code in triggers and stored procedures, make sure
the team (and yourself) knows that this is occurring. There's nothing worse
than debugging a routine and 'magic' seems to be happening to your data. And
of course it's happening due to a stored procedure or trigger that everyone
has forgotten was in the database.

#3 - a lot of times you can't do it in the database. For example let's say
you have some complex logic that needs to occur on every row of a cascading
delete. Sometimes doing this in the database can be a nightmare and lead to
bad recursion potential, etc. Or during this process you need to return some
key values to some other functions etc. You may be forced not to put your
cascades in the database, and you may have to drop back to the middle tier to
perform the complex logic. (however this might not be true anymore in SQL
2005 - i have yet to explore this)

A good way to approach this might be to put all of your cascading deletes in
the database to start off with. Then, as situations arise, move the ones that
can't be done in your database out to the middle tier...

....I'm not sure there is a right answer here for every situation. You want
to try to make some standards for your project, and try to adhere to them in
most situations as best you can. Real world development however likes to
intrude on even the most sincere plans and you may end up violating your
standards once or twice (or your norms) simply to get the user what they
really need.

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"Nemisis" wrote:
Hi everyone,

Wonder if anyone can shed some light on how i should setup cascade
deletes of object data within my database.

One option is to use SQL triggers, is this a good idea? Should the
logic be in my business layer instead? or maybe even the data access
layer?

I also have the problem when performing an insert. If i insert a
record into one table, i also need to insert other values into foreign
key tables. Again, where do i do this?

This is my first 3 tier application and i am not sure which way i
should set this up, so any help would be greatful.

Thanks in advance

Sep 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
0
by: Fraser Hanson | last post by:
Hello, I have a table which has a foreign key relationship with itself. I want and expect my updates to cascade (deletes definitely cascade as expected) but instead I just get error 1217:...
25
by: David Noble | last post by:
We've been developing a web site using 3-tier architecture for 18 months now. There is a common layer that defines the classes - using XML schemas. The data layer acts as a wrapper to 3 databases...
33
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
4
by: Patrick | last post by:
I'm writing a winforms database application in C#. I've come across a lot of stuff lately about "N-Tier" architecture. Can anyone give me a simple explanation of N-Tier? The descriptions that...
3
by: RAJESH | last post by:
I am working with c# and asp.net in developing web applications, iam using ..netframework 1.1 ,i want to know what is the need of 3-tier or 4-tier architecture in our application development.what...
1
by: Nemisis | last post by:
Hi everyone, Wonder if anyone can shed some light on how i should setup cascade deletes of object data within my database. One option is to use SQL triggers, is this a good idea? Should the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.