Distributed data challenges
Distributed databases that do not have a fixed connection to each other cannot provide any system-wide locking mechanism. In particular, there is no mechanism to prevent you from inserting two rows with the same primary key in two different remote databases, causing primary key conflicts when uploading these rows to the consolidated database.
One solution is to use a composite primary key consisting of a common AutoIncrement column plus a database identifier to resolve the problem of automatic increment value overlap for different databases. A multi-column primary key makes the foreign key definition too complex to be a headache for the application developer, so the globally unique identifier (GUID) is sometimes considered a single-column alternative. GUIDs are 128-bit integers with a shape such as "6f9619ff-8b86-d011-b42d-00c04fc964ff", unique, but result in cumbersome database indexes that are difficult to process when debugging. Another solution is to use a key pool, where the hub server generates and downloads unique key-value groups at the key pool for subsequent use by a single remote database. Key pooling is really a viable solution, but it is very difficult to implement and manage it, especially in multi-level hierarchies. In addition, they can result in additional network traffic.
ASA provides a better solution to the globally unique primary key problem: The partition AutoIncrement tool provided by the Global AutoIncrement column default value. Assign each database a unique database identifier: 1﹑2﹑3, and so on, and automatically use this value to determine which partition or range of the value is used to assign the primary key value of the database.
This is important for Mobile Inspector applications because many tables in each remote database are frequently inserted into new rows, and they all have primary keys that are automatically assigned or manually assigned. The following example shows a bri_sktch table for saving freehand sketches in a BLOB column. The partition size is set to 2,000,000, which means that each inspector can create many sketches until the partition is exhausted. A 32-bit signed integer primary key up to 2,147,483,647;2,147,483,647 divided by 2,000,000 equals 1,073, and 1,073 is the maximum number of databases that apply this mechanism without generating primary key conflicts. 32-bit signed integer for mobile Inspector programs; for other larger applications, you can use 64-bit unsigned integers.
CREATE TABLE BRI_SKTCH (
SKTCH_ID INTEGER NOT NULL DEFAULT
GLOBAL AUTOINCREMENT ( 2000000 ),
STRCTR_ID INTEGER NOT NULL,
SKTCH_TTL VARCHAR ( 45 ) NOT NULL,
SKTCH_DES VARCHAR ( 130 ) NULL,
FILE_NM VARCHAR ( 32 ) NULL,
DEL_FLG_IND BIT NOT NULL DEFAULT 0,
LST_MDFD_TS TIMESTAMP NOT NULL DEFAULT TIMESTAMP,
SKTCH_LOB LONG BINARY NULL,
SKTCH_NBR INTEGER NOT NULL,
SKTCH_SZ_AMT INTEGER NULL,
PRIMARY KEY ( SKTCH_ID ) );
Another challenge for distributed data is to reduce the amount of network traffic required for the synchronization process. Before professional synchronization software appears, you must write application code to determine the data that needs to be transmitted back and forth. Sometimes the code transmits too much data to ensure that no data is omitted. At other times, the transmission time is just as long as it needs to be adjusted.
The Mobilink client reads the remote database transaction log to determine the data that must be uploaded, thereby reducing network traffic. Only rows that have been inserted ﹑ update or deleted after the last synchronization are sent. In addition, if the row has been modified several times between two synchronizations, only the final version is uploaded.
The Mobilink server does not have the same advantages when creating a download stream. Because it works with different databases, such as Oracle﹑sql server and Db2,mobilink cannot access the transaction log. If you do not want to download the full table each time, you must write the appropriate WHERE clause in the Download_cursor script.
You can now take advantage of another ASA feature: the timestamp column defined with the special default timestamp property will be updated automatically each time the update and the row is inserted. The previous CREATE table shows how to make each table have a lst_mdfd_ts column that stays up to date without writing triggers. The previous SELECT statement contains the LST_MDFD_TS >= predicate, which restricts the download result set to those rows that have changed since the last synchronization. The MobiLink server automatically places placeholders "? "Replaces the value of the last synchronization timestamp, so you do not have to write any custom code to track when each remote database synchronizes.
Conclusion
After leaving North Carolina, I began to pay attention to the roadside staff, wondering if they were doing a checkup. Maybe one day in the future, I can find the answer by whether they use a mobile computer or not. The last batch of tablets has reached NC DOT, which is a real success mark in the area of cost concern. If applications such as mobile Inspector apply to this domain, they are applicable to all environments.
Working experience with mobile Inspector applications consolidates two of the lessons I've learned in recent years: first, it's easy to underestimate the complexities of synchronization settings, especially when it's a major part of a large business application. Second, the synchronization of relational database data levels simplifies setup because it separates synchronization logic from application code, restores complex data structures to simple rows and columns, and leverages database basic features like transactional commit and column defaults.