Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Your first view
How to use views
6. Tables vs views
Summary

Instruction

Good! You may be wondering what the difference is between tables and views. If they're so similar, why would we use views?

A view doesn't actually contain any data. Data is physically stored in tables. Each time you query a view, the table (or tables) underneath the view is queried to get the rows again. Views are also represented differently in ERDs:

There are many applications for views:

  1. For security reasons, you may only want to expose a limited number of table rows or columns to a certain group of users.
  2. You may want to create some calculated columns on the fly – e.g., to convert between the imperial and metric systems.
  3. You may want to have a convenient way of working with aggregated columns without grouping the rows in every query you run.

In all of these cases, it's usually better to create a view than a new table. This way you avoid data redundancy and optimize disk space usage.

We'll explore these view uses in the following exercises.

Exercise

Click Next exercise to continue.