One: Table name definition specification:
(1) The name of the database table is the plural form of the noun and all lowercase, such as cities, categories, friends, etc.
This is not a mandatory rule, you can look at personal habits, unity is good.
(2) If the table name consists of several words, the words are separated by an underscore ("_"), such as subscribed_pois,poi_categories, etc.
(3) The name of the table is as full as possible
(4) The table name is limited to 30 characters characters. Abbreviations can be used to reduce the length of a table name when the full name of the table exceeds 30 characters, such as description-----desc;information---info;address addr, etc.
(5) Homogeneous database objects must have a uniform prefix name
A more complex system, database tables are often many, to quickly locate their own needs of the table, not too easy. Therefore, you can add a uniform prefix to the table in the same module.
For example, the Rights management related tables can be uniformly plus a prefix p_. User table p_user; character table p_role; Organization table p_orgnization;
Permission table P_power;
Intermediate table plus prefix rel_
Two: Field name definition specification
(1) All database fields are in lowercase English words
(2) field length should not be too long, as concise and clear
Field names are limited to 30 characters characters. When the field name exceeds 30 characters, the abbreviation can be used to reduce the length of the field name.
such as description---desc;information---info;address, addr, etc.
(3) If the name of a table or field is only one word, it is recommended not to use abbreviations, but to use complete words.
(4) If the table or field is composed of multiple words, the words are separated by "_".
The first letter of The entity attribute is lowercase, and if there are multiple words, the first letter of the other word is capitalized.
Like what:
/**
* Creation Time
*/
@Column (name = "Creation_time")
Private long creationtime;
(5) Commonly used fields such as name, not directly with the name, preferably defined as xx_name.
To prevent associated queries, the two-table field names are the same and inconvenient to handle. may also need to alias as
(6) field names try to avoid Chinese pinyin
(7) Avoid keywords in the field as much as possible
(8) A nullable column should be avoided in the table.
Although empty columns are allowed in the table, empty fields are a special type of data.
When the database is processed, special processing is required. In this case, the complexity of database processing records is increased.
When there are more empty fields in the table, the performance of the database processing is much lower under the same conditions.
Workaround: One is to avoid the generation of empty fields by setting default values.
(8) fields that cannot be empty are best added with default values
All fields at design time, except for the following data types Timestamp, datetime, must have a default value.
The default value of the character type is an empty character value string ';
The default value of the numeric type is the value 0;
The default value for the Boolean is 0, the value 0 in all logical types in the system is false, and the value 1 is true.
A field of datetime, smalldatetime type has no default value and must be null.
Database definition specification (can be borrowed, not hard standard)