Every day we calculate the correlation between ~40 different financial instruments and want to be able to store them in our PostgreSQL database. What would be the best way of storing these values?

We would prefer to have one table that includes all of this information instead of one table for each instrment's correlation with the rest. We were thinking of having each column be the correlation between an instrument and another say [corr(a,b), corr(a,c), corr(b,c)] but this looks would cause issues when we need to access the values if new instruments are added.

Are there any typical ways this is done?


  • How are you going to use these numbers? Postgres supports the ARRAY data types
    – mustaccio
    Feb 23 at 22:15
  • Hi, and welcome to dba.se! I think there'll also be a time component (day? hour? minute?...), so @RohitGupta's solution (with added time component) is the way forward.
    – Vérace
    Feb 25 at 11:22

1 Answer 1


If you can't use the advanced features, you can create a table with rows like this.

  • AutoIncrement Key
  • Instrument A Id
  • Instrument B Id
  • Correlation between A and B
  • Seems like the best (only?) way forward - but you're missing a time component - these correlations will vary day-to-day, hour-to-hour, even minute-to-minute so any model will have to take account of this - see my comment under the OP's question.
    – Vérace
    Feb 25 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.