There are days I like to pull my hair out and create a dynamic 4D map that holds a list of records. 🤯

Yes there's a valid reason to build this map, generally I'm against this kind of depth 2 or 3 is usually where I draw the line, but I need something searchable against multiple indexes that doesn't entail querying the database over and over again as it will be used against large dynamic datasets, and the only thing I could come up with was a tree to filter down on as required.

  • 1
    use graph database then

    postgres have agensgraph
  • 2
    @sweetnothings how to explain this without the people I work with finding me🤔

    Essentially it is a configurable set of rules stored in the database which the business can create, change, and enable / disable at will without notice.

    When applicable records are updated the are checked against this dynamic list of rules which the code does not have any working knowledge of the actual rules, but there is predefined criteria of when the rule would apply in different scenarios, and to only evaluate the appropriate rules and proceed or fail (there could be 0 rules or 100 rules applicable to the current state of the record)

    So to save on database queries I need to generate a map of all the rules in a searchable manner, while keeping in mind this map could be used against many records at a time in different states.
  • 2
    @vane if only that was an option.
  • 0
    @C0D4 or recurrence, I build similar rule matching engine for client and those rules also got embedded rules but those were only matched against different values so recurrence was enough :)
  • 1
    I don't have embedded rules to handle, but this will need to work with related records as well, as some of the known criteria will be outside the record.

    I've done many things but I can't say I've built a dynamic rule engine before.

    I welcome the insights though.
  • 1
    @C0D4 I don’t remember much besides that update of rule was most nasty thing and I was refactoring this code like 10 times before I was happy with results.
Add Comment