WEBVTT

00:00:00.350 --> 00:00:01.331
Welcome back!

00:00:01.511 --> 00:00:03.175
Here's what we'll learn in this lesson.

00:00:03.355 --> 00:00:08.934
Give a relationship path a short name, calculate
each invoice row's amount, and watch that

00:00:08.934 --> 00:00:11.227
formula respond to a quantity change.

00:00:11.407 --> 00:00:14.202
One row at a time, in our existing database.

00:00:15.600 --> 00:00:16.987
Let's call this path city.

00:00:17.167 --> 00:00:21.220
Alias column gives our two-hop customer city a
reusable name.

00:00:21.400 --> 00:00:24.045
Reload the model and get a fresh table handle.

00:00:25.375 --> 00:00:27.253
Let's read and filter with that name.

00:00:27.433 --> 00:00:30.526
Dollar city follows the original relationship
path.

00:00:30.706 --> 00:00:33.010
It does not store another copy of the city.

00:00:34.400 --> 00:00:36.512
Let's calculate quantity times price.

00:00:36.692 --> 00:00:39.700
Formula column declares an SQL expression.

00:00:39.880 --> 00:00:44.104
Round it to two decimal places, and describe the
result as numeric.

00:00:45.434 --> 00:00:47.226
Let's read the calculated amounts.

00:00:47.406 --> 00:00:49.454
Two teas at three fifty make seven.

00:00:49.634 --> 00:00:52.685
The database evaluates the formula when we query
it.

00:00:54.100 --> 00:00:56.489
Let's check whether the database needs changing.

00:00:56.669 --> 00:00:58.845
True means no migration is needed.

00:00:59.025 --> 00:01:02.225
Aliases and formulas add no physical columns.

00:01:03.600 --> 00:01:06.032
Let's temporarily change the quantity to three.

00:01:06.212 --> 00:01:09.369
The calculated amount becomes ten fifty
immediately.

00:01:09.549 --> 00:01:15.139
The old total imported from CSV stays seven
because it is an ordinary stored column.

00:01:16.469 --> 00:01:17.877
Let's undo that change.

00:01:18.057 --> 00:01:23.710
Rollback restores the original quantity, so the
rest of our examples use the same dataset.

00:01:25.100 --> 00:01:26.593
Thanks for following along!

00:01:26.773 --> 00:01:31.040
We named a path and calculated a row amount
without storing another column.

00:01:31.220 --> 00:01:36.297
Next, we will summarize related records:
invoice, customer and product totals.
