Important Notice
While using ChatGPT, don't copy-paste exact content. Read carefully and make necessary changes.
1. Introduction
A database standards document outlines the essential guidelines, protocols, and best practices that an organization should follow to ensure consistency, quality, and maintainability across its databases. This document is typically used by database administrators, developers, data architects, and other stakeholders involved in database management and development. Here’s a suggested structure and description for your document:
2. Purpose
This document serves as the official standard for database design, development, and management within SIONIQ. Its purpose is to establish uniform guidelines that enhance data integrity, promote best practices, and ensure efficiency and interoperability across all database systems. Following these standards helps improve data consistency, system reliability, and security.
3. Scope
This document applies to all relational database management systems (RDBMS) and any databases developed, maintained, or administered by SIONIQ. This includes but is not limited to the development, deployment, maintenance, security, and governance of databases. The primary focus will be on SQL Server 2022, though principles can be adapted for other platforms if necessary.
4. Table Naming Conventions
Consistent naming conventions help maintain clarity and organization within SQL databases. Follow these standards for naming various database objects:
To maintain consistency and readability, follow these guidelines when naming tables:
4.1 General Instructions
To ensure clarity, consistency, and maintainability in the database structure, follow these general table naming conventions:
-
Use Descriptive Names: Choose names that clearly describe the content or purpose of the table (e.g.,
Employees,SalesOrders). -
Plural Naming: Use plural nouns to indicate that the table holds multiple records of the entity (e.g.,
Customersrather thanCustomer). -
Avoid Spaces and Special Characters: Do not use spaces,underscores, hyphens, or special characters in table names. Use underscores (
_) to history tables (e.g.,OrderDetails_History). -
Prefix with Module Short Codes: If tables are grouped by modules, use a standard prefix for each module (e.g.,
admfor Admin,invfor Inventory) followed by the table name. This helps identify the module association. - Avoid Abbreviations: Use full words whenever possible for readability. Avoid using unclear abbreviations unless they are widely understood.
By following these guidelines, tables will be named in a way that is logical, easy to understand, and scalable as the database grows.
4.2 Use PascalCase
PascalCase is a naming convention in which each word in a compound word or phrase begins with a capital letter. It is commonly used in programming and database design for naming classes, methods, and variables.
Examples of PascalCase
- Single Word:
PascalCase -
Multiple Words:
InventoryOrderCustomerDetailsGetCustomerInfoEmployeeRecord
Key Characteristics
- First Letter Capitalized: Each word starts with a capital letter.
- No Spaces or Underscores: There are no separators between words.
- Readability: Capital letters enhance readability and understanding.
Usage
PascalCase is often used in the following contexts:
- Programming: Common for class names, method names, and some variable names, especially in languages like C# and Java.
- Database Objects: Applied to table names, column names, and stored procedures for consistency and clarity.
| Naming Convention | Example | Description |
|---|---|---|
| PascalCase | InventoryOrder |
Each word starts with a capital letter, no separators. |
PascalCase is beneficial for creating clear and descriptive identifiers, enhancing the readability of code and database structures.
4.3 Module Prefixes
To categorize tables by their respective modules, use a short code prefix for each module in lowercase, followed by the table name. This helps to quickly identify the module a table belongs to.
Guidelines:
- Module Prefix: Use lowercase module short codes as prefixes (e.g.,
admfor Admin,invfor Inventory). - Table Naming Structure: Format table names as
prefixTableName(e.g.,invStock,admCountry). - Example: Use
posBillingfor the Billing table in the POS module.
Module Prefix List:
| Module | Prefix | Example Table Name |
|---|---|---|
| Admin | adm |
admTableName |
| Master | mst |
mstTableName |
| Procurement | prc |
prcTableName |
| Inventory | inv |
invTableName |
| POS | pos |
posTableName |
| Order | ord |
ordTableName |
| Repair | rep |
repTableName |
| B2B | b2b |
b2bTableName |
| Manufacturing | mfg |
mfgTableName |
| Bullion Merchant | blm |
blmTableName |
| Scheme | sch |
schTableName |
| HRMS | hrm |
hrmTableName |
| Accounts | acc |
accTableName |
| Asset Management | asm |
asmTableName |
| E-Commerce | ecm |
ecmTableName |
| CRM | crm |
crmTableName |
| Marketing | mkt |
mktTableName |
| Online Schemes | ols |
olsTableName |
| Scheme website | swb |
swbTableName |
| Digital Catalog | dct |
dctTableName |
| MIS Report | mis |
misTableName |
| Gold Loans | gld |
gldTableName |
| Sioniq Shaping Cart | ssc |
sscTableName |
| Sioniq OMS | som |
somTableName |
| SIONIQ CRM | scr |
scrTableName |
| OMS | oms |
omsTableName |
| Sales & Distribution | snd |
sndTableName |
| Production | prd |
prdTableName |
4.4 Parent-Child Table Naming Convention
For tables with associated child tables, use a module short code as a prefix, followed by the table name. Append the suffix HDR for the parent table and DTL for child tables. This convention indicates both the module and the hierarchical relationship between tables.
Guidelines:
-
Module Prefix: Use lowercase module short codes as prefixes (e.g.,
admfor Admin,invfor Inventory). -
Parent Table (Header): Append the suffix
HDRto the parent table name after the module prefix (e.g.,invOrderHDR,admInvoiceHDR). -
Child Table (Detail): Append the suffix
DTLto the child table name after the module prefix, which contains related detailed information (e.g.,invOrderDTL,admInvoiceDTL). - Consistency: Use this naming convention for all module-based parent-child structures to maintain clarity and consistency across the database.
Example:
| Module | Table Type | Table Name |
|---|---|---|
| Inventory | Parent Table | invOrderHDR |
| Inventory | Child Table | invOrderItemsDTL |
| Inventory | Child Table | invOrderStonesDTL |
| Admin | Parent Table | admInvoiceHDR |
| Admin | Child Table | admInvoiceDTL |
Following this convention clarifies both the module and the hierarchical relationship between tables, making it easier to manage and understand the database structure.
4.5 Vertical Table Naming Convention
For vertical tables that include parent-child relationships, use a module short code as a prefix, followed by the table name. Append the suffix VRL to both parent and child tables to indicate that they are part of a vertical structure.
Guidelines:
-
Module Prefix: Use lowercase module short codes as prefixes (e.g.,
admfor Admin,invfor Inventory). -
Vertical Table (Parent): Append the suffix
VRLto the parent table name after the module prefix (e.g.,invOrderVRL,admInvoiceVRL). -
Vertical Table (Child): Append the suffix
VRLto the child table name as well, typically representing detailed records (e.g.,invOrderItemsVRL,admInvoiceDetailsVRL). - Consistency: Use this naming convention across all module-based vertical table structures to ensure consistency and clarity in the database.
- Primary Key: Main table primary key and vertical table primary column should be same. Name and Data.
Example:
| Module | Table Type | Row Table | Actual Table | Actual PK | Verticle Table | Verticle PK |
|---|---|---|---|---|---|---|
| Inventory | (Parent) | Order | invOrderHDR |
OrderID |
invOrderVRL |
OrderID |
| Inventory | (Child) | OrderItems | invOrderItemsDTL |
OrderItemsID |
invOrderItemsVRL |
OrderItemsID |
| Admin | (Parent) | Invoice | admInvoiceHDR |
InvoiceID |
admInvoiceVRL |
InvoiceID |
| Admin | (Child) | InvoiceItems | admInvoiceITEMSDTL |
InvoiceITEMSID |
admInvoiceItemsVRL |
InvoiceITEMSID |
| Admin | (No Child Table) | Country | admCountry |
CountryID |
admCountryVRL |
CountryID |
Using the VRL suffix for both parent and child tables in a vertical structure makes it clear that they belong to a specific hierarchy within each module.
4.6 History Table Naming Convention
For tables with historical data, use a module short code as a prefix, followed by the table name. Append the suffix _History to all table types to indicate that they store historical records. This includes parent and child tables in a vertical structure.
Guidelines:
- Module Prefix: Use lowercase module short codes as prefixes (e.g.,
admfor Admin,invfor Inventory). - Vertical Table (Parent): Append the suffix
VRLto the parent table name after the module prefix (e.g.,invOrderVRL,admInvoiceVRL). - Vertical Table (Child): Append the suffix
VRLto the child table name as well (e.g.,invOrderItemsVRL,admInvoiceDetailsVRL). - History Tables: For all tables, append the suffix
_Historyto indicate that they contain historical data (e.g.,invOrderHistory,admInvoiceHistory). - Column Naming Convention: For columns within tables, use the module prefix followed by a descriptive name. For parent table columns, end with
HDR, and for child table columns, end withDTL. - Consistency: Maintain this naming convention across all module-based history and vertical table structures for clarity and consistency.
Example:
| Module | Table Type | Row Table Name | Actual Table Name | Actual Table Name (History) | Verticle Table Name | Verticle Table Name (History) |
|---|---|---|---|---|---|---|
| Inventory | (Parent) | Order | invOrderHDR |
invOrderHDR_History |
invOrderVRL |
invOrderVRL_History |
| Inventory | (Child) | OrderItems | invOrderItemsDTL |
invOrderItemsDTL_History |
invOrderItemsVRL |
invOrderItemsVRL_History |
| Admin | (Parent) | Invoice | admInvoiceHDR |
admInvoiceHDR_History |
admInvoiceVRL |
admInvoiceVRL_History |
| Admin | (Child) | InvoiceItems | admInvoiceITEMSDTL |
admInvoiceITEMSDTL_History |
admInvoiceItemsVRL |
admInvoiceItemsVRL_History |
| Admin | (No Child Table) | Country | admCountry |
admCountry_History |
admCountryVRL |
admCountryVRL_History |
By using the _History suffix for all types of tables, along with VRL for vertical tables and HDR / DTL for columns, the structure remains clear and organized within the database.
4.7 Settings Table Name Conventions
Application Settings:
| Application | Module Prefix | Row Table | No Child | If Parent | If Child | History | History |
|---|---|---|---|---|---|---|---|
| Sioniq AI (General) | adm | Settings | admSettings |
admSettingsHDR |
admSettingsDTL |
admSettingsHDR_History |
admSettingsDTL_History |
| Sioniq AI (Functional) | adm | CurrencySettings | admCurrencySettings |
admCurrencySettingsHDR |
admCurrencySettingsDTL |
admCurrencySettingsHDR_History |
admCurrencySettingsDTL_History |
| Scheme Online | adm | SchemeOnline | admSchemeOnlineSettings |
admSchemeOnlineSettingsHDR |
admSchemeOnlineSettingsDTL |
admSchemeOnlineSettingsHDR_History |
admSchemeOnlineSettingsDTL_History |
| Scheme App | adm | SchemeApp | admSchemeAppSettings |
admSchemeAppSettingsHDR |
admSchemeAppSettingsDTL |
admSchemeAppSettingsHDR_History |
admSchemeAppSettingsDTL_History |
Module Settings:
| Application | Module Prefix | Row Table | No Child | If Parent | If Child | History | History |
|---|---|---|---|---|---|---|---|
| Inventory (General) | inv | Settings | invSettings |
invSettingsHDR |
invSettingsDTL |
invSettingsHDR_History |
invSettingsDTL_History |
| Inventory (Functional) | inv | BarcodeSettings | invBarcodeSettings |
invBarcodeSettingsHDR |
invBarcodeSettingsDTL |
invBarcodeSettingsHDR_History |
invBarcodeSettingsDTL_History |
| POS (General) | pos | Settings | posSettings |
posSettingsHDR |
posSettingsDTL |
posSettingsHDR_History |
posSettingsDTL_History |
| POS (Functional) | pos | InvoiceSettings | posInvoiceSettings |
posInvoiceSettingsHDR |
posInvoiceSettingsDTL |
posInvoiceSettingsHDR_History |
posInvoiceSettingsDTL_History |
4.8 Table Name Structure Summary
The structure of a table name can be represented as follows:
Module Prefix: inv (e.g., Inventory)
Table Name: Example
Suffix: HDR (Header)
Suffix: DTL (Detail)
Suffix: VRL (Vertical)
Suffix: _History (Historical)
This format clearly indicates the purpose of the table, making it easy to understand the module it belongs to and its role within the database.
5. Table Column Naming Conventions
5.1 General Instructions
Follow these guidelines when naming columns:
- Keep names as short as possible while still being descriptive.
- Avoid abbreviations unless they are widely accepted.
- For boolean columns, use a
IsorHasprefix:IsActive,HasDiscount.
5.2 Column Name Creation
Column names should be clear, descriptive, and follow the PascalCase naming convention. Use nouns to represent the data stored in the column.
- Use PascalCase for naming:
OrderDate,CustomerName. - Avoid using reserved words or special characters.
- Be consistent in naming across similar types of data.
5.3 Primary Key Columns
Primary key columns should follow these conventions:
- Use the table name followed by
ID:OrderID,CustomerID. - Make sure the primary key is unique and not null.
5.4 Foreign Key Columns
Foreign key columns should clearly indicate their relationship to the primary key of another table:
- Use the name of the referenced table followed by
ID:CustomerIDin theOrdertable referencingCustomertable. CustomerIDcolumn primary key the in theCustomertable and foreign key inOrdertable.
5.5 Common Column Specifications
| Column Name | Data Type | Purpose |
|---|---|---|
| LocationID | Guid |
Stores the locatiion details. |
| FinancialYearID | Guid |
Stores the financial id details. |
| TerminalID | Guid |
Stores the system that created the record. |
| TransctionDate | DATETIME / TIMESTAMP |
Stores the exact the transaction date when the record was created. |
| CreatedBy | Guid |
Stores the user that created the record. |
| CreatedDate | DATETIME / TIMESTAMP |
Stores the exact datetime when the record was created. |
| ModifiedBy | Guid |
Stores the user that created the record. |
| ModifiedDate | DATETIME / TIMESTAMP |
Stores the datetime when the record was last modified. |
| Status | BIT |
Indicates whether the record is deleted (1) or not (0). |
5.6 Summary Table of Column Naming Conventions
| Column Type | Naming Convention | Example |
|---|---|---|
| General Columns | PascalCase | OrderDate |
| Primary Key | TableName + ID | CustomerID |
| Foreign Key | ReferencedTableName + ID | OrderID (in Customer table) |
| Boolean Columns | Is/Has + Descriptor | IsActive |
| Text Columns | PascalCase with descriptor | CustomerName |
| Date Columns | PascalCase with "Date" suffix | CreationDate |
| Time Columns | PascalCase with "Time" suffix | CreationTime |
| Percentage Columns | Descriptor + Percent | DiscountPercent |
6. Stored Procedures Naming Conventions
Common Naming conventions
| Procedure Type | SP Prefix | Module Prefix | Action Prefix | Naming Convention | Example |
|---|---|---|---|---|---|
| Get / Retrieve Data | sp | inv [Inventory] | Get | spinvGet[EntityName] | spinvGetCustomerDetails |
7. Functions Naming Conventions
Common Naming conventions
| Function Type | fn Prefix | Module Prefix | Action Prefix | Naming Convention | Example |
|---|---|---|---|---|---|
| Get / Retrieve Data | fn | inv [Inventory] | Get | fninvGet[EntityName] | fninvGetCustomerDetails |
8. Data Types
Select appropriate data types for each field:
| Data Type | Standard | Description | Example |
|---|---|---|---|
| Integer | INT | Used for whole numbers. | ProductQuantity |
| Decimal | DECIMAL(18,2) | Used for precise numeric values, with scale defined (e.g., currency). | Price |
| Varchar | VARCHAR(255) | Used for variable-length text up to 255 characters. | CustomerName |
| Text | TEXT | Used for long text data, such as descriptions or comments. | ProductDescription |
| Date | DATE | Used for date values without time. | BirthDate |
| Datetime | DATETIME | Used for date and time values. | OrderTimestamp |
| Boolean | BIT | Used for binary values (true/false). | IsActive |
| UUID / GUID | UNIQUEIDENTIFIER | Used for globally unique identifiers, often for primary keys. | OrderID |
9. Indexing Guidelines
Best practices for indexing:
- For clustered indexes:
IX__ _CL - For non-clustered indexes:
IX__ _NC - For composite indexes:
IX__ _ _NC