Here is the video going over the examples in this post (It may be easier to visualize by watching the examples play out) :
Before we dive in, I have the database schema included here below for easy reference just in case it helps (Note that the highlighted fields in bright yellow are from the adjustments that I made to the original set of data before I populated the database. It won’t affect anything here.):

Let’s talk about views. A view is a virtual table based on the result set of a SQL table. Even though a view is not a real table, it behaves like one and can be interacted with as if they were. Views do not store data permanently and only displays select data from the base tables being queried. We can think of a view as a predefined query that is run when it is invoked. Because a query must be run first, a con is that it may take longer to access the data in a view.
An important use of views is for security measures for data access. It prevents users from having direct access to the base tables. It also can limit data displayed for different users through different views.
To create a view, we start off by typing “CREATE VIEW”, then give it a name (in this case, it is called teacher_names), and follow by “AS”. We then move into the query, indicating which columns to access from which base table. Here we want to create a view that displays the first names and last names of all the teachers within our yoga_teacher table :
CREATE VIEW teacher_names AS
SELECT f_name, l_name
FROM yoga_teacher;
If we should ever need to delete this view, we would do so with the code below:
DROP VIEW teacher_names;
Anytime there is an update made to any of the base tables, the associated views will automatically reflect those changes as well. This is beneficial since we won’t need to make the same updates in multiple places and the views will always be up-to-date since they use components from real tables. Generally, we would not want to repeat data across our tables and ideally we’d want to make changes in one place.
Ok, that is a quick overview of views. I hope this is helpful. Feel free to watch the related video. It may be easier to visualize and understand the examples.
Thanks for learning with me, friends :).

