SQL Server - Schema / Code Analysis Rules. What will your rules be?

We use Visual Studio Database Edition (DBPro) to manage our schema. This is a great tool that, among other things, can analyze our schema and rule-based T-SQL code (just like FxCop does with C # code) and mark certain things as warnings and errors.

Some examples of rules may consist in the fact that each table should have a primary key, without underlining in column names, each stored procedure should contain comments, etc.

The number of rules built into DBPro is quite small and a bit strange. Fortunately, DBPro has an API that allows the developer to create their own. I am curious what types of rules you would create your DB command (both schema rules and T-SQL rules). Reviewing some of your rules may help us decide what we should consider.

Thanks - Randy

+5
source share
2 answers

Some of mine. Not all can be tested programmatically:

  • There is no Hungarian style prefix (for example, “tbl” for a table, “vw” for viewing)
  • If it is likely that this will ever be ported to Oracle, identifiers will not exceed 30 characters.
  • ,
  • -
  • ( "" "" )
  • , , , , , .
  • "IX _".
  • "PK _".
  • "FK _".
  • "UC _".
+1

, , :

, , , , ( varchar (max) ) / .

, PK FK , . , , - FK , PK, PK , . , PersonID , , CustomerPersonID RepPersonID.

, FK .

, , . , , , , , .

, , , .

PK. , , . , PK int.

, .

, .

.

, SSN, SocialSecurityNumber .., . CreditCardNumber.

( , SQL Server , ).

, . , . , .

GUID.

DateInserted InsertedBy ( , , .)

. , .

ID. . . tablenameID, PK PK, FK.

. , , , .

, , . ?

, proc SQl, , , Debug ( SQl, , Debug 1),

, , , (insert/update/delete), proc , - .

, .

+1

All Articles