guid| data uses GUIDs for data table primary key benefits
A datasheet master typically takes the following three ways:
1. Automatic delivery increment.
2. Unique name. This is to generate a unique serial number using your own defined algorithm.
3. GUID (globally unique identifier).
GUID and AutoIncrement value and unique name comparison GUID
On a client-side build, the attribute of the GUID determines that a value generated by a GUID can have a duplicate chance of almost zero, thus guaranteeing that the primary key value is unique when the table is inserted.
can facilitate the processing of distributed data submission, such as: Branch data to the head office to submit-directly to the part of the data can be inserted.
Support for off-line data processing. When you add a new record to a local packet, you assign the key field value of the data table to the same value as when it is added online.
Auto Increment value
Generated on the database server side, because the value is handled internally by the database system and is guaranteed to be unique, but because it is generated on the database server side, the value must be returned to the client, through which the client can do other operations. For example, a document (Master-slave table) is the use of automatic increment, when the insertion document is raised, you must return the key field value of the document header, and then insert the document details (document details are linked through the Document Header key field).
The submission of distributed data is not handled well, for example: Branch data is submitted to the head Office-the key field values of the data table must be regenerated when submitting data to ensure that the field value is unique.
To support off-line data processing requires additional processing, where the local packet is saved (saved locally) by inserting a hypothetical unique value, regenerating the real unique value when submitting the offline data back to the data server, and doing the related processing again.
Unique Name
Generated at the client or on the server side, in contrast to the AutoIncrement value, is to maintain the algorithm for generating unique values and the temporary values saved, which can cause errors or other problems. If you are generating a unique value on the client, you must also ensure that the generated value is unique.
The submission of distributed data is not handled well, for example: The branch data is submitted to the head Office-the key field values of the data table must be regenerated (or processed) to ensure that the field value is unique
To support off-line data processing requires additional processing, where the local packet is saved (saved locally) by inserting a hypothetical unique value, regenerating the real unique value when submitting the offline data back to the data server, and doing the related processing again.
Example description
The difference between the comparison GUID and the AutoIncrement/unique name is saved below with a new document
Action
Guid
AutoIncrement Value/Unique name
Document Head
New
Document header key field value: Get and fill in
Document header key field value: None
Save
Save directly
First get and fill in the key field values before saving
Return
return directly
Key field values must be returned when returned
Document details
New
Associated Document Header field value: Fill in directly
Document detail key field values: getting and filling in
Associated Document Header field value: None
Document detail key field values: None
Save
Save directly
Gets the document header key field value and fills in the associated document header field of the document detail;
Then obtain and fill in the Document Detail key field values;
Save again
In combination with the above, using GUIDs as key field values for data tables can mitigate key field-related operations and is the most straightforward and practical method.
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.