Database Synchronization Using Reverse Query Method: The Case of SIMRS Khanza

I am a developer from Indonesia
Search for a command to run...

I am a developer from Indonesia
No comments yet. Be the first to comment.
Dokumen Nilai, Arah Hidup, dan Pedoman Implementasi 1. Pendahuluan Prinsip Hidup AhliWeb merupakan fondasi nilai yang menjadi arah berpikir, bersikap, mengambil keputusan, bekerja, membangun bisnis,
![[Indonesian] Prinsip Hidup AhliWeb Versi 2](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F6608de5cd660c76b8626061d%2F8a6aa718-4fc2-493c-86ad-5f26b1dcaf99.png&w=3840&q=75)
Pendahuluan AW Non-Commercial License 1.0 adalah lisensi perangkat lunak source-available yang dirancang untuk memungkinkan akses publik terhadap source code sekaligus tetap menjaga kontrol eksklusif
![[Indonesian] Memahami Wiki AW Non-Commercial License 1.0](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F6608de5cd660c76b8626061d%2Ff2bf3812-7079-4c4f-a6f9-fe2ba1c0aa06.png&w=3840&q=75)
Introduction The AW Non-Commercial License 1.0 is a source-available software license designed to allow public access to source code while preserving the copyright holder’s exclusive control over comm

Indonesia menghadapi tantangan besar di ruang digital, di mana jumlah pengguna media sosial telah melebihi 191,4 juta jiwa per Februari 2022, mencakup sekitar 68,9% dari populasi. Peningkatan sirkulasi konten ini, sayangnya, disertai dengan risiko ti...

🔰 RINGKASAN SINGKAT STRATEGI MARKETING HODi: HODi (Hybrid Omnichannel Distribution Initiative) adalah strategi distribusi dan pemasaran terpadu yang menggabungkan kekuatan online + offline, otomatisasi + human touch, teknologi + komunikasi personal...
In the realm of hospital information system development, like the Hospital Management Information System (SIMRS) Khanza, database synchronization is a common challenge. This process is crucial to ensure that the stored data is always up-to-date and consistent across the system. One method that can be employed to achieve this goal is the reverse query method.
The reverse query method refers to the process of reversing the direction of information search. In the context of database synchronization, this means starting from the desired outcome - a synchronized and updated database - and working backwards to determine the necessary steps to achieve it.
Let's consider a scenario where the deposit and ipsrsopname tables in the SIMRS Khanza database need to be synchronized to update the structure and remove data duplications.
deposit TableRemove Old Primary Key:
ALTER TABLE `deposit` DROP PRIMARY KEY;
This step is necessary for changing the primary key structure, possibly due to business requirements change or database design improvement.
Update the no_deposit Column:
UPDATE `deposit` SET no_deposit = LEFT(no_deposit, 17);
This command modifies the no_deposit values to ensure uniform formatting, which might be crucial for system integration or data standardization.
Identify and Remove Duplications:
DELETE c1 FROM deposit c1 INNER JOIN deposit c2 WHERE c1.`tgl_deposit` < c2.`tgl_deposit` AND c1.`no_deposit` = c2.`no_deposit`;
This query removes duplicate entries based on no_deposit, retaining only the most recent based on tgl_deposit.
Modify and Re-add Primary Key:
ALTER TABLE `deposit` MODIFY COLUMN `no_deposit` varchar(17) NOT NULL FIRST;
ALTER TABLE `deposit` ADD PRIMARY KEY(`no_deposit`);
These steps change the no_deposit column to the appropriate data type and set it as the primary key, ensuring data integrity.
ipsrsopname TableAdd Temporary id Column:
ALTER TABLE `ipsrsopname` ADD `id` INT AUTO_INCREMENT UNIQUE;
This adds an id column to facilitate unique identification of each row.
Remove Duplications:
DELETE FROM `ipsrsopname` WHERE id NOT IN ( SELECT MAX(id) FROM `ipsrsopname` GROUP BY `kode_brng`, `tanggal` );
This query removes duplicate rows based on the combination of kode_brng and tanggal, leaving only the most recent.
Clean Up and Reset Primary Key:
ALTER TABLE `ipsrsopname` DROP `id`;
ALTER TABLE `ipsrsopname` ADD PRIMARY KEY (`kode_brng`, `tanggal`) USING BTREE;
These steps remove the temporary id column and set a new primary key combination of kode_brng and tanggal using B-Tree data structure for query efficiency.
The reverse query method in database synchronization allows administrators and developers to strategically plan and implement database structure updates and data cleaning. Through the example on SIMRS Khanza, we can see how this approach facilitates data structure enhancement and redundancy elimination, leading to a more efficient system and more accurate data. The steps, though technical, demonstrate how the concept of reverse query can be applied in real practice to address database synchronization challenges.