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:

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
Key Characteristics
Usage

PascalCase is often used in the following contexts:

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 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:

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:

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:

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][TableName][suffix]

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:

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.

5.3 Primary Key Columns

Primary key columns should follow these conventions:

5.4 Foreign Key Columns

Foreign key columns should clearly indicate their relationship to the primary key of another table:

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: