Tuesday, April 3, 2012

Database Coding Convention


  1. Each database object must have a short description

  2. If needed, each object should have ‘Implementation Flow’ (bullet point) which will describe the logic implemented within it. Comment should point to proper bullet point

  3. Each logic should have proper comment and should refer to appropriate  ‘Implementation Flow’ point

  4. Each database object must have ‘Version History’. Every time the object is modified an entry should be added. The format is as below-
    1. Format - [Serial #] - [Author] - [Date] - [Short Description]
    2. Example – 1 – Tom Brady – 03/20/2012 – Created
    3. Example – 2 – Tom Brady – 03/21/2012 – Unit tested

  1. Database object Naming Convention as follow -
    1. Stored Procedure – prefix SP
                                                              i.      Example - SPStoredProcedureName
    1. Function – prefix FN
                                                              i.      Example – FNFunctionName
    1. Trigger – prefix TR
                                                              i.      Example – TRTriggerName
    1. Variable – camel case (first letter of first word in small case, first letter of subsequent words in upper case)
                                                              i.      Example - @firstVariableName
    1. Temp table – camel case

  1. NULL checks need to be added for each mandatory input. If value is missing, error need to be raised
    1. Example -

-- NULL check for inputs

IF @inputOne IS NULL OR @inputTwo IS NULL
BEGIN
            RAISERROR('All inputs are required', 10, 1);
            RETURN;
END;

  1. TRY – CATCH block need to be added
[Not complete]

No comments: