HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

Naming Specification

Unified Object Naming Specification

The unified standards for naming database objects, such as database, schema, table, column, view, index, constraint, sequence, function, trigger, etc. are as follows:

  • The length cannot exceed 63 characters.

  • It is advised to use meaningful English vocabularies.

  • It is advised to use a combination of lowercase letters, numbers, and underscores.

  • It is not advised to use double quotation marks (") unless it must contain special characters such as uppercase letters or spaces.

  • It is not advised to start with PG, GS (to avoid confusion with the system DB object), and it is not advised to start with a number.

  • It is forbidden to use reserved words. Refer to official documents for reserved keywords.

  • The number of columns that a table can contain varies from 250 to 1600 depending on the field type.

Temporary and Backup Object Naming

  • It is recommended to add a date to the names of temporary or backup database objects (such as table), for example, dba.trade_record_1970_01_01(where dba is the DBA-specific schema, trade_record is the table name, and 1970_01_01 is the backup date).

Tablespace Naming

  • The user tablespace of the database is represented by ts_<tablespace name>, where the tablespace name contains the following two categories:
    1. Data space: For the user's default tablespace, it is represented by default. For other tablespaces, it is represented according to the category of the tables hosted on the tablespace. For example, the table that stores code is represented by code. The table that stores customer information is represented by customer. Try to use one tablespace to host the tables of that category. If a table is particularly large, consider using a separate tablespace.
    2. Index space: add idx_ in front of the name of the corresponding data tablespace. For example, the index space for the user's default tablespace is represented by ts_idx_default. For index tablespace of code table, use ts_idx_code.

Index Naming

  • Index object naming rules: table_column_idx, such as student_name_idx, the index naming method is the default naming method when the index name is not explicitly specified when an index is created for the MogDB database.

    Therefore, it is advised to create indexes without naming them explicitly, but using DBMS defaults.

create unique index on departments(department_id);
CREATE INDEX
 \di
+----------+-------------------------------+--------+---------+
| Schema  | Name              | Type  | Owner  |
|----------+-------------------------------+--------+---------|
| mogdb   | departments_department_id_idx | index  | mogdb  |
+----------+-------------------------------+--------+---------+
SELECT 1

Variables Naming

  • English words should be used for naming, and pinyin should be avoided, especially pinyin abbreviations should not be used. Chinese or special characters are not allowed in the naming.

  • If no complicated operations are involved, simple applications such as counting are always defined by number.

Partitioned Table Naming

  • The name of the partitioned table follows the naming rules of ordinary tables.

  • A table is partitioned by time range (one partition per month), and the partition name is PART_YYYYMM.

    For example, PART_201901 and PART_201902

Function Naming

  • The name should be consistent with its actual function. A verb should be used as a prefix command to cause an action to take place.

    Example: The following naming conforms to the specification:

    func_addgroups (Add multiple groups)
    func_addgroup (Add one group)
Copyright © 2011-2024 www.enmotech.com All rights reserved.