Tonight designed the database for a night, with a little MyEclipse Workbench, feel small screen computer with too uncomfortable, a bunch of Windows squeezed together.
Tidy up the odds and ends of something you've encountered:
Field constraints:
Pk:belongs to primary key: primary key
Nn:not null: cannot be empty
Uq:unique Index: Unique
Bin:is binary column: This column is the binary data
un:unsigned data type: Unsigned datatype
Zf:fill up values for this column with 0 's if it is numeric: fills with 0 when the stored data is not sufficient to specify the width, for example int (4) Saves 5, then displays as 0005
Ai:auto Incremental: Auto Add
Default: Defaults, this default value now has some good use, such as Current_timestamp equivalent
Data range:
int is 4 bytes, signed range -2147483648~2147483647, unsigned range 0~4294967295
The decimal and numeric types are specifically used to store accurate data values, such as money, which is implemented as decimal in MySQL, so the attributes of decimal are fully applicable to numeric. MySQL5.5 uses binary format to store decimal.
The general format of decimal is decimal (m,n), M is precision (precision), which represents the number of significant digits, and N is a carry (scale) that represents the number of digits that can be stored after the decimal point. Standard SQL Specifies that decimal (5,2) can store any one 5-digit number that contains 2 decimal places (not the 5-digit number in our general sense), so the storage range of decimal (5,2) is 999.99 to 999.99
In standard SQL, decimal (M) is equivalent to decimal (m,0), similar, decimal is also equivalent to decimal (m,0), and the concrete implementation of each database can decide the default value of M, which is supported by MySQL and the default value of M is 10. If n is 0, then the decimal value does not contain a decimal point or fractional part.
About Timestamp:
Timestamp can now support automatic initialization and Automatic Updates
DEFAULT Current_timestamp supports auto-initialization
On update Current_timestamp supports automatic Updates
Current_timestamp has many synonyms variants: Current_timestamp (), now (), LocalTime, LocalTime (), Localtimestamp, Localtimestamp ()
Android New project: 2nd database design