if i have a status code that is used to govern how a particular row should be processed, and that status code can take several values, and each value has a different meaning in the application...
... are all you don't-put-app-logic-into-the-database guys really saying that i should choose option 1 instead of option 2 here?
option 1
Code:
CREATE TABLE foo
( ...
, status CHAR(1) NOT NULL -- valid values defined in the app
, ... )
option 2
Code:
CREATE TABLE foo
( ...
, status CHAR(1) NOT NULL
, CONSTRAINT valid_status
FOREIGN KEY (status) REFERENCES statuses (status)
, ... )
because, you know, i think that this kind of business logic ~does~ belong in the database
this thread admirably points out once again the folly of trying to come up with hard and fast, black and white, my way or the highway rules like "not a good idea to let MySQL handle logic" and "letting the database manage business logic is a horrible idea"
like it or not, there is ~no~ clean divide between business logic and database implementation
Bookmarks