Skip to content

petrakpatrik/in-memory-database-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

In-memory database system for medical data

Project implements a custom database system designed to manage medical records using advanced tree data structures. At its core, it features a generic Binary Search Tree (BST) and a self-balancing AVL Tree.

Binary Search Tree (BST)

Generic tree structure implementing standard operations.

  • Supports Insert, Find, Delete, Level Order, Min, and Max.
  • In Order and Find Interval operations are implemented using the Morris traversal algorithm (transition is based on creating temporary connections in the tree).
  • Uses a nested Node<Key, Data> class that stores references to children, the parent, and a flag indicating whether it is a left or right child. The tree maintains a reference to the root and tracks the total node count.

AVL Tree

A self-balancing extension of the standard binary search tree.

  • The class tracks node heights and includes methods to calculate the balance factor.
  • Automatically executes single or double rotations (Left/Right rotation) during insertion and deletion operations if the tree becomes unbalanced.
  • Inherits properties and methods directly from BSTree, overriding the node creation method to instantiate AVL-specific nodes.

Database

The database logic manages a complex system of 11 parallel trees to enable rapid querying of patients and their test results.

  • PCRTest: An object containing the test date, patient ID, test ID, clinic ID, district ID, region ID, and result details (including a note).
  • Patient: An object containing the name, surname, date of birth, and a unique patient ID.
  • For advanced querying, the system utilizes nested AVL trees. For example, a structure like AVLTree<string, AVLTree<DateTime, AVLTree<int, PCRTest>>> allows the system to find a specific patient's tests, sorted chronologically by date and then by test ID.

Operations

  • Inserting the PCR test result into the system
  • Search for a test result for a patient and view all data
  • List of all PCR tests performed for a given patient, sorted by date and time of their execution
  • List of all / only positive positive tests performed during the specified time period for the specified district
  • List of all / only positive tests performed for the specified time period for the specified region
  • List of all / only positive tests performed for the specified time period
  • List of sick people in the district / region as of the specified date, with the person considered sick n days after the positive test
  • List of sick people in the district on the specified date, where the person is considered sick n days after the positive test, and sick people are arranged by test value
  • List of sick people on the specified date, with the person considered sick n days after the positive test
  • List of one sick person on the specified date, with the person considered sick n days after the positive test from each district with the highest test value
  • List of districts / regions sorted by number of sick people on the given date, where a person is considered sick n days after a positive test
  • List of all tests performed for a specified time period at a given workplace
  • Search for a PCR test by its code
  • Inserting patient into the database
  • Permanent and irreversible deletion of the PCR test result
  • Deleting a person from the system including their PCR test results

Testing

  • Features an extensive test suite (Insert test, Dump test, Partial delete test, Find test, Min/Max test, and Find Interval test) to verify the correctness of individual operations and tree balance.
  • Executes random operations based on set probabilities. Every 10 operations, it validates tree integrity, size, and balance against an auxiliary C# HashSet.
  • Empirically compares the custom BST, the AVL tree, and the standard C# Dictionary across 10,000 operations, measuring execution time in microseconds.

About

Implementation of a generic binary search tree (BST), balanced AVL tree and implementation of a PCR test database, which is based on these data structures.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages