Implemented as a custom, file-based database system designed to manage medical records using advanced data structures. At its core, it features a Linear Hash File and a Heap File to ensure efficient direct access and management of secondary storage.
An unsorted file structure with direct access, where R implements the IRecord interface.
- Operates in three distinct modes: Normal, Overflow, and Main. These modes dictate block sizes and operation behaviors (e.g., automatic free block management only occurs in Normal mode).
- Utilizes an internal Block class to manage operations at the block level. It tracks partially or completely free blocks in RAM using a SortedSet for rapid access.
- During deletions, if the system detects empty blocks at the end of the file, it automatically truncates the file to save space.
A dynamic hashing structure that utilizes two underlying Heap Files: one configured as 'Main' and the other as 'Overflow'.
- Maintains a basic address space (initialized to 2), the current level, modulo, a split pointer, and the total record count. Main and overflow blocks store addresses pointing to subsequent blocks in the chain.
- Dynamic Resizing like Split and Merge triggered when the load factor exceeds or drops.
- Defragment operation is called during deletions if it is possible to save at least one block in the overflow chain, keeping storage optimized.
The database logic manages two parallel Linear Hash Files: one for Patient records and one for PCRTest records. Both models implement the IRecord interface, which defines methods for comparing records, retrieving static sizes, calculating hashes, and serializing to/from binary.
- PCRTest: Contains details such as TestDate, PatientID, TestID, Result, Value, and a Note (UTF-16 string). A single test record occupies exactly 52 Bytes in memory.
- Patient: Contains Name, Surname, BirthDay, PatientID, and an array holding up to 6 Test IDs along with a valid test count. A single patient record occupies 97 Bytes in memory.
- Insert a new patient into the system.
- Insert a PCR test result for a specific patient.
- Search for a patient (outputs patient details alongside all their associated tests).
- Search for a specific PCR test (outputs test details alongside the associated patient's details).
- Edit a patient's personal details (IDs and associated tests cannot be modified).
- Edit a PCR test's details (IDs cannot be modified).
- Permanently delete a PCR test (automatically updates the patient's record to remove the reference).
- Permanently delete a patient (cascades to delete all of their valid tests).
Tests are initialized with 1 000 records and execute 10 000 random operations with a distribution of 40% insertions, 15% searches, and 45% deletions. Every 100 operations, the actual record count is validated against an auxiliary structure. Block validation routines read the entire file to verify the real number of free/partially free blocks. Tester specifically traverses and verifies all overflow chains in the Linear Hash File. Data structures have been successfully tested across 100 independent replications.