Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the rules for database naming

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces you what are the rules of database naming, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Database naming convention

1 purpose

Standardize the naming rules of various objects in the database.

2 principles of database naming

2.1 data file

If the database uses a file system instead of a bare device, the following naming rules are established:

1) the data file starts with the tablespace name and ends with .dbf, all named in lowercase letters plus numbers. If the tablespace has multiple data files, start with the second data file and add _ after the name of the table space.

Example: data file for system tablespace: system.dbf,system_2.dbf

2) the control file of oracle database is represented by control.ctl. Such as control01.ctl,control02.ctl.

3) for the log files of oracle database, the online log files are represented by redo.dbf. Both the group name and the file sequence name are represented by 2 digits. For example, the two files in the first group represent bits redo0101.dbf and redo0102.dbf. Archive logs are represented by arch_%t_%s.arc. Where% t and% s are variables agreed by oracle.

2.2 Tablespace

2.2.1 Database system tablespace

Database system tablespace includes system tablespace, temporary tablespace, rollback segment tablespace. The following naming conventions are established:

1) the system tablespace is directly defined by the database and cannot be modified.

2) temporary tablespaces are represented by temp. If you have multiple temporary tablespaces, start with the second temporary tablespace and add it after temp.

3) the tablespace of the rollback segment is represented by undotbs. If there are multiple rollback segment tablespaces, start with the second rollback segment tablespace and add it after undotbs.

2.2.2 user tablespaces for the database

The user tablespace of the database is represented by ts_. Where the tablespace name is as follows:

1) data space: for the user's default table space, it is represented by default. For other tablespaces, they are represented according to the category of tables stored on the tablespace. Such as the table that puts the code, it is represented by code. A table containing customer information, expressed in customer. Try to use a table space to hold tables of this type. If a table is particularly large, consider using a separate tablespace.

2) Index space: precede the name of the corresponding data table space with ind_. For example, the index space of the user's default tablespace is represented by ts_ind_default. The index table space of the code table is represented by ts_ind_code.

2.3 Table

The naming of database tables follows the following rules:

1) the table name begins with T _. The length of the table name cannot exceed 30 characters. All the words in the table name are singular, and the words should be capitalized.

2) connect multiple words with an underscore (_). If there are multiple systems in the library, the table name is the system name + word or multiple words, and the system name is the abbreviation of the development system, such as VNET.

3) complete words are recommended for the words contained in the table. If the table name is more than 30 characters long, the abbreviation of that word is used forward, starting with the last word. (if there is no agreed abbreviation, the first four letters of the word will be used.)

The field naming of the database table follows the following rules:

1) the database field names are all lowercase English words, separated by "_". The length of the field cannot exceed 30 characters.

2) if the field is a code, add _ id after the word.

3) if the field represents a time, use the suffix _ time.

2.4 View

Database views are named according to the following rules:

1) the view name starts with V _, and the length of the view name cannot exceed 30 characters. The view name is represented by uppercase English words.

2) if the view is generated by several tables, connect the names of several tables with an underscore (_). If there are too many tables, you can simplify the table names appropriately, but be sure to list all the table names.

2.5 sequence

The naming of database sequences follows the following rules:

The sequence name begins with seq_, followed by the field name that uses the sequence. If several fields use the same sequence, connect the names of several fields with an underscore (_). If you need to use different sequences for the same field names in different tables, add the characteristics of the table to the field names and connect with an underscore (_). The length of the sequence name cannot exceed 30 characters. Sequence names are represented by lowercase English words.

2.6 stored procedure

The naming of stored procedures follows the following rules:

The stored procedure name begins with Pr_ and cannot be more than 30 characters long. Stored procedure names are represented by lowercase English words.

2.7 function

The function is named according to the following rules:

The function name begins with Fu_, and the length of the function name cannot exceed 30 characters. Function names are expressed in lowercase English words.

2.8 trigger

Triggers are named according to the following rules:

The trigger name begins with Tr_, and the length of the trigger name cannot exceed 30 characters. Trigger names are represented by lowercase English words.

2.9 Primary key

The naming of the primary key follows the following rules:

The primary key name starts with pk_, followed by the name of the table where the primary key is located. The length of the primary key name cannot exceed 30 characters. If it is too long, abbreviate the table name. The abbreviation rules are the same as those of the table name. The primary key name is represented by lowercase English words.

2.10 Foreign key

The naming of foreign keys follows the following rules:

The foreign key name starts with fk_, followed by the table name of the foreign key and the corresponding primary table name (excluding t _). The child table name and the parent table name are separated by an underscore (_). The length of the foreign key name cannot exceed 30 characters. If it is too long, abbreviate the table name. The abbreviation rules are the same as those of the table name. Foreign key names are represented by lowercase English words.

2.11 Index

The naming of the index follows the following rules:

1) the index name is represented by lowercase letters and numbers. The length of the index name cannot exceed 30 characters.

2) the index corresponding to the primary key has the same name as the primary key.

3) each type of index ends with _.

4) the uniqueness index begins with uni_, followed by the table name. General sex references start with ind_, followed by the name of the table.

5) if the index length is too long, the table name can be abbreviated. The abbreviation rules are the same as those of the table name.

What about the database naming rules are shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report