Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...More Foreign keys? More Foreign keys?
Previous
 
Next
New Post
5/5/2011 3:46 AM
 
Addding foreign keys for ModuleID column of any module should not be an issue, but you should add the drop statement to uninstall.sqldataprovider (you need to re-add this statement after upgrading the module as well, otherwise deleting the table upon module uninstall will fail. I agree with Wes, that there is little advantage of adding foreign constraints to auditing columns, but if there is a foreign constraint from any user column to userID, hard delete of users has been implemented to fail gracely with a warning.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
5/5/2011 10:32 AM
 
Thank you all for the detailed replies.  There are about 3 issues in the original post that I could have distinguished better.

First, as to foreign keys on the audit columns (CreatedByUserID and ModifiedByUserID)  Part of the reason for wanting the foreign keys on the audit tables is simply so we have a robust audit trail.  I need to be able to tie audited actions back to a particular user.  If I have to explain why some business transaction didn't work as expected, I want to know who last modified the record.  A foreign key will help to enforce this audit key, even if it is not a panacea.   I have worked on a complex database that doesn't do a good job of maintaining records of users over time.  It is a miserable experience and I want to use every integrity constraint possible to keep the data valid in all future projects.  I want all transactions ACID, that includes durable.  If the audit trail can be easily modified, it isn't quite durable as I can loose data to the accumulation of 'kruft' in the database.

Second, I wanted to share the SQL to find 'missing keys'.  In most cases, a table that has a column named ModuleID has a foreign key referencing the Modules table.  The query quickly finds the tables that do not.  I hope this is useful to the developers responsible for QA in the project.  If I can, I want to help open source projects, if only by making suggestions to the people that do the real work of updating the source code.  The SQL finds missing keys efficiently and it is easy to modify to find other missing keys.  I'm using similar SQL on a different SQL Server project and it is saving me many hours in systematically finding 'missing keys'.

Finally, there is a new CMS named weceem that is an open source grails project.  It has some great features and one that I really like is the the relational database schema implements a foreign key constraint on every relation.  This is enforced automatically by the use of GORM, the groovy object relation mapper.  While weceem is not as mature as DNN, it is an example of the rich diversity and innovation found in OSS.  Since I liked the fact that is uses foreign keys 100% of the time, I thought I would help DNN to use foreign keys 100% of the time.  I view a missing foreign key as a design bug.  I want to be one of the many eye that make bugs shallow, to paraphrase Eric Raymond.

PS.  The discussing on hard delete of users has been helpful for both my understanding and our DNN project.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...More Foreign keys? More Foreign keys?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out