Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tips for enterprise level database design

I work with an enterprise application and have picked up some tips for DB design

  1. All tables should have the following fields that helps in audit trail - LastChangedBy, LastChanged, LastChangedPage
  2. All your stored procedures that have dynamic SQL should have the @bDebug parameter. By default it's set to 0. If it's set to 1, print out the dynamic SQL statement and this will be really helpful in debugging.
  3. For CRUD SPs, have a way of partially updating the table. If your table has 10 fields and in one of the SP, you care about updating only 5 fields, have a layer of abstraction to do this.

Any other useful tips you can think of?

EDIT: Thanks for all the answers. I am still looking for an answer that can provide a link to tips/tricks/strategies for DB Design.

like image 346
Nick Avatar asked Jul 11 '09 16:07

Nick


1 Answers

For #1: Move to SQL Server 2008 and just turn on Change Data Capture. If you really need to keep detailed audit trails, this feature alone will justify the cost.

For #2: Any stored procedure with dynamic sql should automatically be put on double secret probation (ie: it's allowed, but has to go through multiple levels of code review to make sure there's not a better way to do it).

like image 191
Joel Coehoorn Avatar answered Nov 15 '22 11:11

Joel Coehoorn