Database naming rules

Source: Internet
Author: User
0. Character Set combination

A-z A-Z 0-9 and _ 63 in total

1.All notes start with a lowercase letter, and all nouns use a singular number. Therefore, the prefix must be lowercase.

Example: userIduser_id

2. database object naming rules

Database Object = {table, view (query), index, association, stored procedure (parameter query), function}

Rules:The object name consists of the prefix and actual name. It is underlined. Do not leave a space between the characters of the object name. The length cannot exceed 30 characters.

[Object Name]=[Prefix] _ [ACTUAL NAME]

Prefix:Use lowercase letters

Table tb

View vi

Index idx

Associate rl

Stored Procedure sp

Function fn

Actual name:The actual name is used to describe the content of an object. It is composed of words or words. The first letter of each word (except the first one) is uppercase. Other letters are lowercase and do not start with a number or, do not underline the word.

[ACTUAL NAME] = [Words Starting with a lowercase letter] [Words Starting with an uppercase letter]... [Words Starting with an uppercase letter 

Example: userNamepassWord userRegisterTime

[Word] = [A-z | A-Z] [a-z | A-Z | 0-9 | _]... [a-z | A-Z | 0-9 | _]

Example: tb_webUservi_userOrder

3.Database Table naming rules

The table name consists of the prefix (tb) followed by the actual name.

[Table Name] = Tb _[ACTUAL NAME]

4.Field naming rules

[Field name] = [Abbreviated table name] _ [ACTUAL NAME]

Now,[Abbreviated table name]=[Table Name]Of[ACTUAL NAME]Part The sequential combination of the first letter of each word

For example, if tb_userInfomation applies this rule, its table name is short for uI.

5.View naming rules

[View] = Vi _[ACTUAL NAME]

6.Stored Procedure naming rules

[Stored Procedure name] = Sp _[ACTUAL NAME] _ [Operation name]

[Operation name] = [Insert | delete | update | calculate | confirm]

Example: sp_userState_update

7.Index naming rules

[Index] = Idx [0-9] _ [Abbreviated table name] _ [ACTUAL NAME]

Example: idx0_uInfo_age

Note: [abbreviated table name] is different from the preceding [abbreviated table name]. It adopts the following simplified string rule. See the last 9.

8.Association naming rules

[Association] = Rl _[Abbreviated table name] _ [Abbreviated table name]

Example: rl_uInfo_msg

8. database design document specifications

Table Name: tb_userInformation

Author: XXX

Date: 2004-12-17

Version: 1.0

Description: used to save user information.

Details: (in tabular form)

 

9. Simplified string rules (method ):

 

  1. Specify the string length as required. Determine whether the string meets the requirements. If yes, It is simplified; otherwise, proceed to the next step.
  2. Replace each word in the string with the abbreviated word to obtain the new string. The standard method is to create the so-called "abbreviated word library" (which is described below ). Determine whether the string meets the requirements. If yes, It is simplified. Otherwise, cancel the step and proceed to the next step.
  3. A new string is formed by the first letter of each word in the string. Determine whether the string meets the requirements. If yes, It is simplified. Otherwise, cancel the step and proceed to the next step.
  4. Perform "manual intervention"

* ** Word abbreviation library ***

Standardize the abbreviations of some words, such:

As follows:

User → u

Password → pass

Address → addr

Register → reg

Login → li

Logout → lo

Time → t

Date → d

Information → info

Project → prj

Manager → man

...

In this way, userRegisterTime can be abbreviated as uRegT userInformation and can be written as uInfo.

The above rules can be implemented by a program:

The functions and usage of such a program are shown in the following example.

Sampleinput:

UserRegisterInformation

Sampleoutput:

URegInfo

We can set up this program on a server to facilitate our work.

In all the above rules, the [actual name] part of the field will not be simplified, but most of the time this will cause the field to be too long. For this reason, we have the following

** Additional rules: When the [actual name] is longer than x (eg x = 8) characters, apply itSimplified string rules

If an additional rule is used, the following situations may occur when the abbreviated table name is used:

Table Name: tb_projectManager does not meet the requirements according to the additional rules.

After the simplified rules are applied: tb_prjMan

Based on [field name] = [Table Name abbreviation] _ [actual name], How can I obtain the [Table Name abbreviation?

At this time, the table name is tb_prjMan, which is short for prjMan. Therefore, you need to restore the table name to projectManager, and then retrieve the initial pM of the project and Manager. This is short for the table name. Because pM should be prefixed, it should be changed to lower case pm

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.