Project development specification, database design code

Source: Internet
Author: User
Tags lowercase naming convention

1. Naming conventions

The purpose of defining this specification is to make all documents in a project look like one person writes, adding readability. Reduce the loss caused by substitutions in the project team.

(These specifications do not have to be strictly adhered to, but must make the program good readability)

1.1 Namespace's name

Namespace's name should be made up of words that start with a capital letter, if it consists of multiple words. Capitalize the first letter of each word.



Name of the 1.2 class

Class names must consist of words that begin with uppercase letters and other lowercase letters.

    • For example: Class Raster;

1.3 Naming of local variables

The name of the variable must begin with a lowercase letter. The following words start with capital letters.

1.4 The name of the static variable

The name of the Static variable should be capitalized, and the full meaning is indicated.

1.5 The naming of the number of references

The name of the parameter must be the same as the variable's naming convention.

1.6 Naming of arrays

Arrays should always be named in the following way:

byte[] buffer;

Instead of:

BYTE buffer[];
1.7 Code Gaze

Class Head Gaze

1. Use text to describe the function of the code. and correctly pointed out the writing idea and logical method of the code;

1. Give a gaze header at the beginning of each class;

For reference: (at least these items are required, Description: Descriptive description of such functions.) Author, time.

)

/**

* Description: User Management

 * @Author : Wjl

 * @Create date:2015 - 8 - - Afternoon 4:06:14

*/

When you change something important, you can add content to it.

Method Head Gaze

/**

* jump to join user page

* @return

*/

Interface Head Gaze

/**

* Description:

* param :

* Return :

* @Author :wjl

* @Create date:2015 - 8 - - Afternoon 5:04:34

*/

Entity attribute Head Gaze

/**

* username Word

*/

1.8 function Point Method specification definition

N Initialization

U xx_init

n Query

U xx_query/xx_search

N Authorization

U Xx_auth

N Deny

U xx_reject

N Details

U xx_info

N Input

U xx_input

N New

U xx_add

N Change

U xx_update

n Delete

U Xx_del

V interface naming specification definition

A business a directory inside put so that the business of the JSP interface.

N Query page

U query.jsp

N Detail Page

U show.jsp

N Input Page

U xx_input.jsp

N New

U xx_add.jsp

N Change

U xx_update

n Delete

Most deletions are basically pop-up prompts, whether you are sure to delete.

V Interface Field display format (not stored in database format)

Y date format: 2013-06-28

Time Format: 2013-06-28 15:31:00

Y amount: 999,999,999,999.00. Show decimal and fractional values when integers

Y number: xxx,xxx (displays thousands of bits)


2. Database Design Specification 2.1 database

A total of 63 characters are made up of 26 English letters (distinguishing between uppercase and lowercase) and 0-9 of these 10 natural numbers, plus the underscore ' _ '. No other characters (except annotations) can appear.
Precautions:
1) The above name must not exceed the system limit of 30 characters. The length of the variable name is limited to 29 (does not contain the identity character @).
2) The names of data objects and variables are written in English characters, and Chinese names are forbidden. Never leave spaces between the characters of the object name.
3) Be careful to keep the word, and make sure that your field name does not conflict with reserved words, database systems, or frequent access methods
5) Maintain the consistency of the field name and type, and ensure consistency when naming the field and specifying the data type for it. If the data type is an integer in a table, then there is a table that will not become a character type.

2.2 Database Naming Conventions

database, data tables use prefixes

The official database name is made up of lowercase English and underscores, as far as possible the application or system is used. For example:

Web_19floor_net
Web_car

The backup database name consists of the official library name plus the backup time, such as:

web_19floor_net_20070403
web_car_20070403

2.3 database table Naming conventions

Follow the database entity naming conventions above.

Name of the typical field: (for example, operator information staff)

Inner Code STAFF_ID

Name Staff_name

Ref. Staff_code

Memo Field name remark

The associated field between the table and table is a uniform name.
The UserID in the Web_user table corresponds to the UserID in the Web_group table.

(or you can add a table name prefix)

2.4 field type specification

Rule: Store data in one field with as little storage space as possible.
For example, you can use int without char or varchar.
You can use tinyint without int.
You can use varchar (20) without varchar (255)

Number

For coded fields, Oracle typically uses number (5) or number (ten), and MySQL uses int (11);

Suppose is the amount, generally with number (12,2); MySQL with double (11,2)

Special fields such as: Zip code number (6)

Date Time

DateTime type

2.5 Database Documentation

There are database design documents on the SERVERSVN, and after changing the fields in the database, the database documents are updated. Easy to manage query maintenance later.

Also, when you create a table, you want to stare at all the fields in the table. The Chinese meaning of the field.




Knowledge of related databases:

VARCHAR is variable-length storage, the field length is a database constraint, the definition of reasonable length can also make it easy to understand the purpose of the field.

MYSQL The length assumed in the definition is less than 255 , the field length is used 1 bytes, assuming that more than one 255 , the length of the field is fixed with the 2 a byte representation. ORACLE does not have this problem.

the length of the field definition also has a significant effect on the index. the length of the index storage for the MYSQL database is defined length, not the length of the actual character, which is a big problem. The main reason is expected to be simple, so MYSQL will waste a lot of space on the index to save the string.

nvarcharand thevarcharthe difference is that the storage method is different 
varcharis stored by byte..and with"n"of thenvarcharis stored by character. UseUnicodeto store the data
For Examplevarchar (+),can store +characters of a byte length,when storing Chinese characters,because Chinese characters1is equal to one character2of bytes.sovarchar (+)can only store - Chinese Characters. 
nvarchar (+),will be able to store + Chinese Characters,that means you can store thecharacters of a byte length

Setting the field to NOT NULL is also a second consideration: The column in the MySQL table contains null, and the column is not included in all.

That is, using an index is not valid.

All. Consider the fields that will use the index in the future. Set the field property to be not NULL.

Consider that this field will be searched in the future as a query keyword using the like form. Then you define the field as an index. This makes it faster to use like queries.


Project development specification, database design code

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.