I have a technical question about views. I know that the views are like stored queries that actually don't have any data in them until they are executed, but what happens when you create a view from another one? I mean, do I need to execute the first view before to execute the second one that contains the first one? Or just with execute the second view the first one would be executed?
Is a little bit tricky for me, so I need to understand it well, and sorry if sounds simple but I'm a little bit new on it.
Tanks for your time by the way, I hope you can help me with this theoretic question.
If you are familiar with other programming languages, you might think of a view as a "macro". It is generally not a general-purpose macro, but there are similarities.
The key idea is that when you refer to a view, you can instead think that the code is replaced in the query, as a subquery. So it gets executed when the query is run.
If a view refers to another view, the same thing happens. When the outer view gets substituted. Then the code referring to the second view gets substituted. And so on ad infinitum.
This is a conceptual description. Some databases might pre-compile views, so it is not actually substituting the text of the view definition. But the same idea applies.