![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
nor a way to query the database about what constraints are enforced generally (short of parsing the result of SHOW CREATE TABLE). |
|
The only solution I can think of is to implement validation one layer above the database. This seems dangerous, not to mention redundant, because it requires the programmer to keep the database constraints and application constraints in sync => maintenance nightmare. |
#3
| |||
| |||
|
|
It has traditionally been the case that it is expensive and time-consuming to implement such changes to the data model in a project. Good project managers understand this, and work hard to define the business rules early, to minimize the "requirements creep" after the data model has been implemented. |
|
Bill K. |
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Bill, Thank you for the lead about the INFORMATION_SCHEMA standard. I suppose that may be where I have to start. But as I say, this just seems fundamentally flawed: That the RDBMS engine usually lacks a method for giving specific error information at the source, and forces the application developer to maintain the business rules if he wants to make sense of them. My concern about the possibility of changing the underlying database structure is really secondary. My primary nag is the need to write error handling without using the database engine, when it is so plain that engine implementors could throw something meaningful. The engine must know what the constraint was and exactly how it failed when it throws the error; why does it not share this information? Is there a coding framework that abstracts this? It seems so basic to developing database applications. What is the point of implementing business rules in the database engine if you then have to re-implement them in the application because the engine doesn't provide good enough feedback when an error occurs? It is worse than redundant. I can only think I just don't know about the right tools yet because I can't be the only person who doesn't want to re-implement constraints checking every time I build a database. Thanks again for your help. -Jason Chang |
#8
| |||
| |||
|
|
What DBMS are you using? Oracle PL/SQL works the way you describe. Coding follows a BEGIN normal code logic> EXCEPTION <error handling logic> END; Pattern. Violating a constraint is an error like many others. Ed |
#9
| |||
| |||
|
|
Ed, I have been trying out MySQL and SQLite, as they are free and thus easier for me to try. I guessed that Oracle would have something of the kind, but I feel like that would be overkill for my purposes (a local-area web site and an end-user program using an embedded database engine), in terms of software heft if not cost. Admittedly, I haven't looked too hard at Oracle's licensing terms yet, I'm just going off their reputation/marketing. Perhaps my problem is that I am listening to people who say "move the logic into the database" but who really mean "into a database engine that actually supports doing so." -Jason Chang |
#10
| |||
| |||
|
|
Perhaps my problem is that I am listening to people who say "move the logic into the database" but who really mean "into a database engine that actually supports doing so." |
|
-Jason Chang |
![]() |
| Thread Tools | |
| Display Modes | |
| |