Use GUID as the benefits of the primary key
Data table is usually used in the following three ways:
1. Automatically deliver value.
2. The only name. This is a unique serial number using the algorithm that uses your own definition.
3. GUID (globally unique identifier).
GUID and automatic increment value and unique name
GUID
Generate in the client, determined by the characteristics of the GUID, the value generated by the GUID may have a repetition opportunity almost equal to zero, so that the primary key value is only unique when the table is inserted.
It can be easily handled for distributed data, such as: Branch data, submit to the header - inserting the part of the data directly.
Support offline data processing. The key field value of the data table can be assigned to the local data packet, and the processing method is consistent with the new time.
Automatic deliver value
Generate in the database server side, because the value is processed inside the database system, it guarantees its uniqueness, but because it is generated in the database server, the value must return to the client, the client passes the other operating. For example, a document (primary slave table) is automatically increasing value. When the document is inserted, the key field value of the document is returned, and the document detail (the document is detained by the document ") .
Failure to deal with distributed data, such as: Branch Data Submit to the General Store - The key field value of the data table must be regenerated when submitting data to ensure that the field value is unique.
To support the offline data processing, additional processing needs to be performed, you need to insert a hypothesis unique value when saving the local packet (saved to the local), re-generate the true unique value when submitting offline data back data servers, and re-perform Related processing.
Unique name
Generate or generate on the client side is the algorithm for generating a unique value relative to the automatic delivering value, which is easy to cause errors or other problems. If you generate a unique value in the client, you must also guarantee that the resulting value is unique.
Failure to deal with distributed data, such as branch data, submit (or pre-processed) the key field value of the data table (or pre-processed) to ensure that the field value is unique.
To support the offline data processing, additional processing needs to be performed, you need to insert a hypothesis unique value when saving the local packet (saved to the local), re-generate the true unique value when submitting offline data back data servers, and re-perform Related processing.
Example statement
The following is the difference between the comparison of GUID and automatic delivery value / unique names below
action
GUID
Automatic delivery value / unique name
Document
Added documents to the key field value: Get and fill in the document of the document: No Save Direct Save First Get and Fill in the key field value, then save the return Direct return to return to return to the key field value to return documents
New related association document header value: Directly fill in the document detail key field value: get and fill in the associated document header value: no document fine key field value: no
Save Direct Save Get Acquisition Click on the key field value and fill in the document detail field in the document detail; then get and fill in the document value;
In integrated, the key field value with GUID as a data sheet is to reduce the operation related to the key field, and is the most direct practical method.