Looking for a technical term

Hi,

thank you for reading my post. I’ve got s simple question: What’s the
correct technical term for data which IS NOT calculated and data which
IS calculated regarding database design.

Simple example: saving a user message in a corresponding table vs.
counting all messages of a user.

If you also know the german expressions, you’re welcome to post them,
too. :slight_smile:

Thanks for your help,
ms

I’m not sure if this answers your question in regards to your specific
example, but let’s say you have a simple table with just two numerical
columns, say two integers.

SELECT i1, i2, i1+i2 AS “Sum” FROM MyTable
will show three columns, two of them real columns from the table and one
computed.

So the term in this case is a COMPUTED column.

Best regards,
Rolf

Rolf P. wrote:

I’m not sure if this answers your question in regards to your specific
example, but let’s say you have a simple table with just two numerical
columns, say two integers.

SELECT i1, i2, i1+i2 AS “Sum” FROM MyTable
will show three columns, two of them real columns from the table and one
computed.

So the term in this case is a COMPUTED column.

The term “derived column” is technically (slightly) more accurate.

ms wrote:

Simple example: saving a user message in a corresponding table vs.
counting all messages of a user.

  1. Saving user messages in a corresponding table.

This would be called a “one-to-many relationship,” or “association” for
short.

Example:
user = User.first
user.messages

  1. Counting all messages of a user.

These types of calculations are called called “aggregate functions.”

Example:
user = User.first
user.messages.count

2a. Caching aggregate functions.

It’s also possible to store the results of aggregate functions in a
column on the parent model. Rails has built-in support for this pattern,
which is called a “counter cache.”

AFAIK Rails support the counter cache only. I’ve occasionally wished it
had direct support for caching “sum” and “average” (avg) aggregate
functions as well, but it can still be doe manually in a similar pattern
as counter cache.