Search code examples
sqllanguage-agnosticterminologyconceptual

What is the correct term to describe a procedure that produces the same result irrespective of how many times it is run?


Say you want to create a new table in a database. If you run a script that only contains the CREATE... code, then it will work the first time, but crash if run again, since it will be trying to create an object that already exists. By adding IF EXISTS ... logic (or DROP TABLE ...) first however, you can avoid such errors.

I know there is a specific technical term that describes this concept or property, i.e. the ability of a script to be run multiple times without changing the end result from the result of running the script only once, but I can not seem to recall it, and I have not been able to find it. Multi-something-something? or poly-something-something?


Solution

  • Idempotent operations

    can be applied multiple times without changing the result beyond the initial application.

    For example, function f is idempotent if for all inputs x it holds

    f(x) == f(f(x))
    

    I have often encountered the concept within the context of idempotent HTTP requests, and within the context of functional programming as referential transparency.