|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, March 20, 2007 12:30 PM
Points: 24,
Visits: 1
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 3:22 PM
Points: 1,276,
Visits: 1,112
|
|
You got my vote In that Celko quote, I think he was specifically referring to a Primary Key.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, June 18, 2012 9:23 AM
Points: 265,
Visits: 16
|
|
Interesting article. Most of things are well known, but here they are summarized and there are also some interesting ideas.The most curious for me was this one:
Recursive I can not imagine any practical use of below code, but theoretically it is possible. CREATE TABLE master( pkey int PRIMARY KEY FOREIGN KEY (pkey) REFERENCES master(pkey))
It really does nothing. I hoped it will prevent update of PK and deleting a record, so I tried it, but unfortunately it doesn't prevent either PK update nor record deleting.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, March 20, 2007 12:30 PM
Points: 24,
Visits: 1
|
|
You got me there! Yes, Celko is referring to primary keys. That was my favorite quote. I wanted to have it in my first article. Hope it will not harm someone….
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Thursday, June 09, 2011 10:47 AM
Points: 779,
Visits: 221
|
|
Recently I came across a highly transactional DB with no FK's! The data integrity was managed by the front-end application.
Unfortunately this is not uncommon in database / application design. I can't tell you the number of vendor-supplied applications I've looked at that don't make use of basic database features such as keys, indexes or constraints. Not to offend anyone, but it usually happens when you've got front-end developers driving the whole thing without a good DBA adding input. When I came to my current position, the developers were running the show and I had to slowly bring them over to agreeing to use things like stored procedures, constraints, keys and db-side functions.
Also, while there are many things I have fundimental disagreements with Celko on, I do like that quote as well.
Good article.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, August 12, 2009 10:14 AM
Points: 18,
Visits: 167
|
|
I really liked the script that will traverse the FK hierarchy. However, it looks like it will only work as long as there is no recursiveness - if a table has a FK within it to itself, the code will loop forever trying to traverse the same table over and over again.
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, April 22, 2013 3:38 PM
Points: 67,
Visits: 143
|
|
"Recently I came across a highly transactional DB with no FK's! The data integrity was managed by the front-end application."
Another reason for this happening is that vendors try to hide proprietary information architecture. No referential integrity, combined with generic object names and procedures/function definitions created on one line. (Great Pains first comes to my mind.) With setup like that, it is really painful to "untagle" relationships at the backend.
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Wednesday, April 03, 2013 10:05 PM
Points: 584,
Visits: 1,571
|
|
"Recently I came across a highly transactional DB with no FK's! The data integrity was managed by the front-end application." I've seen this also. The ERP system was designed to be "generic" - any database platform, on any OS, for any customer. As customers all have differing requriements, an FK for one might be detrimental to another, so all were left off. And then, as the "customer", we paid a fortune getting the application customised to check the data integrity we required. A nice little earner, I must say. 
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Sunday, September 16, 2012 3:26 AM
Points: 1,038,
Visits: 443
|
|
Good article - I too have come across some rather powerful systems with no FKs. Their excuse was that when data loading they could do it in any order. I might send them your quick and easy code to disable and enable all constraints. Hope this article influences some folk to ensure they use ref integrity! 
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 3:22 PM
Points: 1,276,
Visits: 1,112
|
|
I think General Patton said: "Fixed fortifications are a monument man's stupidity." Same could be said for "generic" database applications.
|
|
|
|