90 "Ali Baba java Development Manual" on MySQL Statute (Statute of the construction of the table)

To build the table Statute

  [Mandatory]

    1, whether or not the field is the concept of expression must be used  is_xxx   way to name, data type is unsigned tinyint (1 is represented, 0 for No) .

      Note: If any of the fields non-negative, it must be unsigned.

      Note: pojo class in any Boolean variables, do not add the prefix is. It is necessary to set the mapping from is_xxx Xxx in <resultMap> in.

    2, table names, field names must be lowercase letters or numbers, start with a number banned, prohibited the middle two underscores appears only one number .

      Description: MySQL is not case sensitive in Windows, but the default is case-sensitive under Linux.

      Counterexample: level_3_name.

    3, table names do not have a plural noun .

      Description: Table name should represent only entity table of contents inside, should not represent the number of entities, DO class name is singular, idiomatic.

    4, disable the reserved words.

    5, the primary key index named pk_ field name  , unique index called  uk_ field name  , the name of the general index was idx_ field name .

    6, decimal type is decimal , prohibit the use of float and double.

      Description: When stored, there is a loss of accuracy problems float and double, are likely when comparing values, get incorrect results. If the range exceeds the range of the data stored in decimal, it is proposed to split the data into integer and fractional and stored separately .

    7, if the length of a string of substantially equal, use  char  fixed-length string type.

    . 8, VARCHAR   variable length strings, not pre-allocated storage space, the length of the inactive longer than 5000 th characters. If the length is greater than this value should be defined as a text, an independent list, with the corresponding primary key, to avoid affecting the efficiency of the index of other fields.

    9, the table must have three fields: the above mentioned id , create_time , update_time .

      Description: id shall wherein the primary key of type unsigned BIGINT , increment single table, in steps of 1. type create_time and update_time are date_time type.

  【recommend】

    1, follow the naming table of the best "The role of business name _ the table" principle.

    2, the library name and application name as consistent as possible.

    3, when the number of rows in a single table of more than 500 million lines or when a single-table capacity of more than 2GB, it is recommended sub-library sub-table .

      Note: If the amount of data expected after three years can not achieve this level, you do not sub-library sub-table when creating tables.

Guess you like

Origin www.cnblogs.com/xiaonengxiong/p/11068577.html