Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8157425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:16:47+00:00 2026-06-06T17:16:47+00:00

Given an expensive function of n variables that returns a scalar value: f(x1, x2,

  • 0

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

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

If I wished to memoize this function in a relational database, what kind of table structure should I use, and what data modelling methodologies apply?

(Related but from a different angle: What kind of data model models function parameters and results?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:16:50+00:00Added an answer on June 6, 2026 at 5:16 pm

    Depending somewhat on the value of ‘n’, you can probably model it like this. Assume that 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
    );
    

    Under normal conditions, I’m reluctant to store a result without including a CHECK() constraint to make sure it’s the correct result. In your case, that might not be practical, but you should give it some thought anyway.

    This assumes that each column carries some kind of meaning. That is, I’m assuming that, in the real problem domain, each of these columns has a name more meaningful than “x3”.

    For example, in the article you referenced, the OP uses “height”, “width”, and “depth”. In some applications, those dimensions are not interchangable–you can unambiguously identify which dimension on the real-world object is height, which is width, and which is depth. (One example might be a shipping container on a pallet, where height is obvious, width is the edge a forklift is expected to fit under, and depth is the remaining dimension.) In other applications, they’re interchangable, which means you’re liable to find “duplicate” primary keys like {2, 3, 5} and {2, 5, 3}. In cases like that, you might want to order the arguments from lowest to highest, and use CHECK() constraints to make sure they’re ordered.

    This is just straightfoward normalization, with the caveat that, in this case, you’re starting in 6NF, I think, so there’s not much to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following code: $(.force-selection).blur(function() { var value = $('matched-item').val(); //check if the input's
Is this possible? Given that C# uses immutable strings, one could expect that there
Given that the web application doesn't have su privileges, I'd like to execute a
Given this method to work on a HTML page in a webbrowser: bool semaphoreForDocCompletedEvent;
Given a certain date, I want to set the value of a cell with
Given a MySQL table of real estate data, I would like to generate a
The following simple function applies a given monadic function iteratively until it hits a
When thinking in a functional mindset, given that functions are supposed to be pure,
I have a function that gives me a number as result: Now to make
I want to write a function that takes an int between 1 and 64,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.