A View is a virtual relation that acts as an actual relation. It is not a part of logical relational model of the database system. Tuples of the view are not stored in the database system and tuples of the view are generated every time the view is accessed. Query expression of the view is stored in the databases system.
Views can be used everywhere were we can use the actual relation. Views can be used to create custom virtual relations according to the needs of a specific user. We can create as many views as we want in a databases system.
When the results of a view expression are stored in a database system, they are called materialized views. SQL does not provides any standard way of defining materialized view, however some database management system provides custom extensions to use materialized views. The process of keeping the materialized views updated is know as view maintenance.
Database system uses one of the three ways to keep the materialized view updated:
- Update the materialized view as soon as the relation on which it is defined is updated.
- Update the materialized view every time the view is accessed.
- Update the materialized view periodically.
Materialized view is useful when the view is accessed frequently, as it saves the computation time, as the result are stored in the database before hand. Materialized view can also be helpful in case where the relation on which view is defined is very large and the resulting relation of the view is very small. Materialized view has storage cost and updation overheads associated with it.
Differences between Views and Materialized Views:
|Query expression are stored in the databases system, and not the resulting tuples of the query expression.||Resulting tuples of the query expression are stored in the databases system.|
|Views needs not to be updated every time the relation on which view is defined is updated, as the tuples of the views are computed every time when the view is accessed.||Materialized views are updated as the tuples are stored in the database system. It can be updated in one of three ways depending on the databases system as mentioned above.|
|It does not have any storage cost associated with it.||It does have a storage cost associated with it.|
|It does not have any updation cost associated with it.||It does have updation cost associated with it.|
|There is an SQL standard of defining a view.||There is no SQL standard for defining a materialized view, and the functionality is provided by some databases systems as an extension.|
|Views are useful when the view is accessed infrequently.||Materialized views are efficient when the view is accessed frequently as it saves the computation time by storing the results before hand.|
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Materialized views in Cassandra
- Local Indexing and Materialized views in Cassandra 3.0
- Materialized views with Practical approach in Cassandra
- SQL | Views
- Differences between TCP and UDP
- Differences between JDK, JRE and JVM
- Differences between Web Services and Web API
- What are the differences between C and Embedded C?
- Differences between Data paths
- Differences between RIPv1 and RIPv2
- Differences Between Excel and Tableau
- Differences between POP3 and IMAP
- Differences between IPv4 and IPv6
- What are the differences between HTTP, FTP, and SMTP?
- Differences between Testing and Debugging
- Differences between Bootstrap and JQuery UI
- Similarities and Differences between Ruby and C++
- Differences Between MATLAB and R Programming Language
- Differences between RGB and CMYK color schemes
- Similarities and Differences between Ruby and C language
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.