Skip to main content

Db Naming Conventions

Basic Rules

  • General principle: All name parts are formed using PascalCase (the first letter of each word is capitalized, written contiguously). (Id included)

  • Segmented structure: Object names consist of segments separated by _ (underscore). Each segment must be PascalCase.

    • Template: [Prefix]_[Rn | RnPj]_[ModuleCode]_[ObjectName]
    • Example: Tb_Rn_Inventory_Items, Sp_RnPj_Production_CreateBomCost
  • Expressed in English: English is used in names.

  • Temporary structures: Temporary table/view names start with the relevant Tmp prefix.

  • No Turkish characters: The characters Ç, Ğ, İ, Ö, Ş, Ü and spaces are not used in names; ASCII characters are preferred.

  • Plural names: Table names are plural: Items, Orders.

  • Primary keys: In the form [SingularTableName]Id (e.g., ItemId, OrderId).

  • Text fields: The 'NVARCHAR' type is used. (e.g., NVARCHAR(50), NVARCHAR(100), NVARCHAR(250), and NVARCHAR(MAX) when necessary). All Unicode constants must be written in the form N'...'

  • Date/time fields: The suffixes Date, DateTime, UtcDateTime are used (e.g., AddDate, UpdateDate, UpdateDateTime). Datetime is preferred. The smalldatetime type should be avoided.

  • Logical fields: Start with Is* and are of bit type (e.g., IsActive, IsFinished). The 'Tinyint' type should be avoided.

  • Numeric Fields: The 'int' type is used for integers, and the 'decimal(18,6)' type for decimal numbers. The 'Tinyint' type should be avoided.

  • Term selection (type/kind/group): Among expressions that may have the same meaning, tip (English equivalent: Type) is preferred. Words such as "kind", "group", "class", "category" are not used in naming.

    • Correct: ItemTypeId, PriceTypeId, OperationTypeId
    • Incorrect: ItemTurId, PriceGroupId, OperationClassId
  • Fixed/standard abbreviations: Their use is discouraged. However, when necessary, they are limited to a widely known and consistent list across the project:

    • Allowed (examples): Id, No (number), Qty (quantity), Avg, Min, Max, Net, Gross, Ref, Code, Desc (if necessary).
    • To be avoided: ...
    • Unit/symbol abbreviations: Technical/international standards are used as is (Kg, Mm, Cm, Usd, Eur).
    • Abbreviation principle: Clear name > abbreviation. Abbreviation is used only if the name is very long, if it is a recurring pattern, or if there is a space constraint in the field.
    • Consistency: Once chosen, an abbreviation must be used with the same meaning throughout the entire schema.
    • Examples:
    • Line Number: LineNumber
    • Description: Notes
    • UserId: @sssip (in SPs)
    • BypassTrig: If a table has an Update trigger, a field named 'BypassTrig' is created.

Object Types

  • Table
  • View
  • Stored Procedure
  • Function
  • Trigger
  • Index
  • Foreign Key (FK)
  • Default Constraint
  • Sequence

General Template

[Prefix]_[Rn | RnPj]_[ModuleCode]_[ObjectName]

Prefixes

PrefixTypeNote
Tables
TbTableUsed for permanent tables
TmpTemporary TableSession/temporary content
View
PvViewPrimary (operational) view
SvSelection (Lookup) ViewNot used for now
CvReport Catalog ViewNot used for now
TmpPvTemporary ViewView that looks at temporary tables
Stored Procedure
SpStored ProcedureBusiness rule/process
Function
FnFunctionScalar/table-valued

Module Codes

PrefixModuleExample
Main Modules
SalesOrderTb_Rn_Sales_Order
PlanningPlanningTb_Rn_Planning_WorkOrder
InventoryStock & Bill of MaterialsTb_Rn_Inventory_Item
ProductionProductionTb_Rn_Production_Bom
PurchasePurchasingTb_Rn_Purchase_Order
SystemSystemTb_Rn_System_User

Name Templates for Other Objects

NameSyntaxExample
Trigger[TableName]_[Function]Tb_Rn_Sales_Order_UpdateAudit
IndexIx_[TableName]_[Column1]_[Column2]...Ix_Tb_Rn_Sales_Order_OrderCode
Unique IndexUix_[TableName]_[Column1]_[Column2]...Uix_Tb_Rn_System_User_UserName
Foreign KeyFk_[TableName]_[RefTableName]_[FieldName]Fk_Tb_Rn_Sales_Order_Tb_Rn_Inventory_Item_ItemId
Default ConstraintDf_[TableName]_[ColumnName]Df_Tb_Rn_System_User_IsActive
SequenceS_[TableName]_[FieldName]S_Tb_Rn_Sales_Order_OrderNo

Note: All of the TableName, RefTableName, and FieldName segments must be PascalCase.


Examples

  • Table: Tb_Rn_Inventory_Item
  • View: Pv_Rn_Production_BomTree
  • SP: Sp_Rn_Purchase_CreateOrder
  • FN: Fn_Rn_System_DivideByZero
  • Trigger: Tb_Rn_Quality_SsTransactionItems_UpdateLock
  • Index: Ix_Tb_Rn_Inventory_Item_ItemCode
  • FK: Fk_Tb_Rn_Production_Bom_Tb_Rn_Inventory_Item_ItemId
  • DF: Df_Tb_Rn_System_User_AddDate
  • Sequence: S_Tb_Rn_Finance_ExchangeRate_RateNo

Style Checklist (Quick Check)

  • Are segments separated by _?
  • Is each segment PascalCase?
  • Are there no Turkish characters?
  • Are entity names singular?
  • Do the PK/FK, date, and bit field names comply with the rules?
  • Are the prefix and module code correct?

Snippet

Redgate Sql Prompt

tip

Write Sql quickly and consistently with snippets. To write Sql code that is 100% compliant with the naming conventions, use the ready-made templates in this repo: ReniumYazilim / SQL-DEV / SQL-PROMPT / Snippets

Quick Pick: Scenario → Snippet

ScenarioSnippet to Use
Creating a tablesnp_CreateTable-a27c8d44-5ecc-475a-90a1-caf7b22dbe24.json
Creating an SPsnp_CreateSp-0c85b39e-3122-44db-9de0-603b18f4bec6.json
TvFn / Fnxxx / Function_TvFn_Template.sql
Triggerxxx
Index / Unique Indexxxx

How do I use snippets in editors (Ssms / Visual Studio)?

  1. Clone the repo or download it as a ZIP.
  2. Open the snippet file in the editor and edit it with your own table/object name.
  3. Review the field names according to our naming checklist.
  4. Keep the source as a "template"; copy and fill it directly for new objects.
tip

Renium users. You can access faster SQL snippets that comply with naming standards from the ...\OneDrive - RENIUM\Belgeler - Proje\General\GitHub\SQL-DEV\SQL-PROMPT\Snippets folder:::