What table structure should be used to store noticed function parameters and results in a relational database?

Given an expensive function of n variables that returns a scalar value:

f(x1, x2, ..., xn) = y

If I wanted to memoize this function in a relational database, what table structure should I use and what data modeling methods are used?

(Connected, but from a different angle: What are the models of the data model parameters and the results? )

0
source share
2 answers

Depending on the value of "n", you can probably model it like this. Suppose the value of "n" is 137.

create table expensive_function_of_n_vars (
  x1 integer not null,
  x2 integer not null,
  ...
  x137 integer not null,
  primary key (x1, x2, ..., x137),
  result integer not null
);

CHECK(), , . , .

, - . , , "x3".

, , , OP "", "" "". - , - , . ( , , - , , , , - .) , "" , {2, 3, 5} {2, 5, 3}. CHECK(), , .

, , , , 6NF, , .

+1

, memoization. , , , , .

, . .

( value1, value2, value3...), :

SELECT result
FROM function_table
WHERE
    input1 = :value1
    AND input2 = :value2
    AND input3 = :value3
    ...

(: , )

  • , . , .
  • (.. ), . INSERT , , .

, .

, ( ), B-Tree .

+1

Source: https://habr.com/ru/post/1613945/


All Articles