Wessel said:
If they were anything like the ones I took, they were largely about
theory and in small part about simplified, idealistic practice.
of course, but still very serious.
I'd have to disagree with that. The relational model can enfore
business rules-- like, at most one customer per order, every order
has a unique identifier, and it's obligatory to fill in the postal
code for an order.
True, but so can other code.
It's not as if the data inside the database isn't storable anymore if
I don't place a check-constraint on a table or add a trigger somewhere.
Also it doesn't have to conflict with my relational model.
You see, I can define business rules according to my functional
research I did on the business PROCESS I have to automate. I then
analyse which entities are used in the process, how they relate and
define a relational model from that (niam or other abstract modeling
technique for example). I can then decide to enforce static rules in
the RDBMS, using FK/Check or default constraints and other rules,
perhaps flexible rules, to be applied in the application logic. If
someone says "that's wrong!", I'd like to know why.
You can for example state that the application logic with the BL rules
+ the data in the database form your application. However where the
application logic is stored is not important, nor where the data is
stored. It's just moving a border: first it's: "everthing inside the
RDBMS is correct", then it's "everthing below (including) the BL tier
is correct. It just depends on how you look at it.
Besides, there's more about a database than the relational model.
- It can restrict access for certain people (only managers can see
other people's salary; only senior help desk officers can re-assign
tickets; ...)
sure
- It can restrict status transitions by controlling the
change through a stored procedure (like moving an order from
InProgress to Fullfilled; requiring a resolve-date when a help desk
ticket is closed; ...)
ah, the stored procedure argument.
Give me one reason why I can't do this from my BL tier?
- It provides a fool-proof way to ensure
there's only one version of the business logic in production
yeah, like that's an argument..
Such safeguards in the database are simple to develop, and more
fool-proof than safeguards at another level. I think it's safe to
say enforcing BL in the database is a "best practice".
#define best.
You only argue that there is more than one way to do certain things,
to enforce certain behavior. You also forget things like:
you have a SAP system and a system in SQLServer. You want to run a
transaction with both SAP calls and SQLServer DML actions, as some data
is in SAP and other data is in the Sqlserver. It's logical to run such
a transaction using a transaction monitor like COM+ or tuxedo. From
inside the RDBMS? Not logical
SOME rules can be enforced at the RDBMS level, others are not. Some
are better of inside the RDBMS (referential integrity, null checks
etc., eventually using views to enforce data availability in
streamlined fashions). However the scope of BL is far broader than a
set of static integrity rules defined on the data. If I define a rule
"Customer C is a gold customer if customer C has purchased at least n
orders in the last m months and once becoming one, will stay a gold
customer for one year", I can enforce that in real time, in each select
for a customer, I can write a function in the RDBMS which is used for
that, I can also set a flag in the customer entity calculated on a
regular basis (e.g. when a customer purchases an order). Which is
better? Don't know, depends on the requirements. Though the outcome of
that results in where the code is placed. I don't need to place my flag
setter code inside an RDBMS, I can, but I don't have to. After all, the
code which makes the calls to the RDBMS to add an order isn't
originating from inside teh RDBMS also, is it?
Would you agree with the statement that in the vast majority of
projects, scalability is not an issue?
You mean, they purchases such a big box for their rdbms it can run
forever without having to worry about scalability? I'm not sure, I
don't have statistical data for that, all I know is what I hear which
is that to be able to keep a big iron box running for a long time with
an RDBMS on it, it can be you run out of breathing room for the RDBMS
and placing new boxes in a BL farm is easier and cheaper than replacing
a big iron box with a bigger iron box.
FB
--