Database Naming Conventions Summary _ database other

Source: Internet
Author: User
Tags lowercase naming convention rollback

Database Naming Conventions

1 Purpose

A naming convention that regulates the various objects of a database.

2 Database naming principles

2.1 Data Files

If the database is based on a file system rather than a raw device, the following naming conventions are agreed:

1 The data file begins with the table space name, with the. dbf as the end, all with lowercase letters plus a digital name. If the table space has more than one data file, start with the 2nd data file, and then add _ after the table space name.

Example: Data file on the system tablespace: SYSTEM.DBF,SYSTEM_2.DBF

2 The control file of Oracle database, expressed by CONTROL.CTL. such as Control01.ctl,control02.ctl.

3 to the Oracle database log files, the online log files are represented by redo< group name >< file sequence name >.dbf. Where the group name and file sequence names are represented by 2 digits. For example, the first group of two files represents bits redo0101.dbf and redo0102.dbf. The archive log is represented by ARCH_%T_%S.ARC. Where%t and%s are all Oracle-agreed variables.

2.2 Table Space

2.2.1 Database system table Space

The database system table space includes the system table space, the temporary table space, and the table space for the rollback segment. Contract the following naming rules:

1 The system table space is directly qualified by the database and cannot be modified.

2 temporary table space is expressed by temp. If you have more than one temporary table space, start with the 2nd temporary table space and add it behind the temp.

3) The rollback segment table space is expressed by UNDOTBS. If there is more than one rollback segment tablespace, start with the 2nd rollback segment table space and add it to the Undotbs.

2.2.2 User table space for the database

The user table space for the database is represented by the ts_< table space name >. Where the table space name is divided into:

1 data space: For the user's default table space, represented by default. For other table spaces, this is represented by the categories of tables that are stored on the table space. For example, a table with code to represent it. A table of customer information, expressed by customer. Try to use a table space to store the table for that class. If a table is particularly large, consider using a single table space.

2 Index Space: Add Ind_ before the name of the corresponding datasheet space. For example, the index space of the user's default table space is represented by Ts_ind_default. The index table space for the Code table, expressed in Ts_ind_code.

2.3 Table

Database tables are named with the following rules:

1 The table name starts with T_, the table name length cannot exceed 30 characters, the table name contains the word all in the singular form, the word should capitalize.

2 multiple words are connected by an underscore (_). If there are more than one system in the library, the name of the table is System + word or multiple words, system name is the abbreviation of development system, such as Vnet.

3 the words contained in the table are suggested with complete words. If the table name is more than 30 characters long, start with the last word, and then forward to the abbreviation of the word. (the first 4 letters of the word are represented if there is no abbreviated contract).

The field naming of database tables follows these rules:

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

2 If the field is code, add _id after the word.

3 If the field represents a time, the _time is used as the suffix.

2.4 View

The naming of database views takes the following rules:

1 The view name begins with V_ and the view name cannot exceed 30 characters in length. The view name is expressed in uppercase English words.

2 The view is generated by a few tables with an underscore (_) to connect the names of several tables, if too many tables can be appropriately simplified table names, but be sure to list all the table names.

2.5 sequence

The naming of database sequences follows these rules:

The sequence name starts with Seq_ followed by the field name that uses the sequence. If you have several fields with the same sequence, use an underscore (_) to connect the names of several fields. If you need to use a different sequence for the same field name in a different table, add the table's characteristics after the field name and use an underscore (_) to connect. A sequence name cannot exceed 30 characters in length. The sequence name is expressed in lowercase English words.

2.6 Stored Procedures

The naming of stored procedures takes the following rules:

The stored procedure name begins with Pr_ and the stored procedure name cannot exceed 30 characters in length. Stored procedure names are expressed in lowercase English words.

2.7 function

The naming of functions takes the following rules:

The function name begins with Fu_ and the function name cannot exceed 30 characters in length. The function name is expressed in lowercase English words.

2.8 triggers

The naming of triggers takes the following rules:

The trigger name begins with Tr_ and the trigger name cannot exceed 30 characters in length. The trigger name is expressed in lowercase English words.

2.9 PRIMARY Key

The naming of primary keys takes the following rules:

The primary key name begins with Pk_ followed by the name of the table in which the primary key is located. The primary key name cannot exceed 30 characters in length. If it is too long, the table name can be abbreviated. Abbreviated rules with table names. The primary key name is expressed in lowercase English words.

2.10 FOREIGN Key

The naming of foreign keys takes the following rules:

The foreign key name begins 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 (_). A foreign key name cannot exceed 30 characters in length. If it is too long, the table name can be abbreviated. Abbreviated rules with table names. Foreign key names are expressed in lowercase English words.

2.11 Index

The naming of indexes takes the following rules:

1 The index name is expressed in lowercase letters and digits. The index name cannot be longer than 30 characters in length.

2 The primary key corresponds to the same index as the primary key.

3 each type of index with _ end.

4 The uniqueness index begins with the Uni_, followed by the table name. The generic index starts with ind_ followed by the table name.

5 if the index length is too long, the table name can be abbreviated. Abbreviated rules with table names.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.