39 Lecture

CS403

Midterm & Final Term Short Notes

Introduction to Views

A view is a virtual table in a database that displays a subset of data from one or more tables. It is created by defining a SELECT statement as a table. Views provide an additional layer of security, as they allow users to access only the data t


Important Mcq's
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. What is a view in a database? a) A physical table b) A virtual table c) A temporary table d) A backup table Answer: b) A virtual table How is a view created in a database? a) By defining a CREATE TABLE statement b) By defining a SELECT statement as a table c) By defining a DELETE statement as a table d) By defining an ALTER statement as a table Answer: b) By defining a SELECT statement as a table What is the purpose of a view in a database? a) To display data from multiple tables b) To provide an additional layer of security c) To simplify complex queries d) All of the above Answer: d) All of the above Can a view be modified in a database? a) Yes, using the ALTER VIEW statement b) No, once it has been created it cannot be modified c) Yes, using the DROP VIEW statement d) No, it can only be dropped and recreated Answer: a) Yes, using the ALTER VIEW statement How does a view differ from a table in a database? a) A view is a physical table, while a table is a virtual table b) A view is a virtual table, while a table is a physical table c) A view can be modified, while a table cannot d) A view is a backup of a table Answer: b) A view is a virtual table, while a table is a physical table Can a view be used to enforce data constraints in a database? a) Yes, using the CHECK constraint b) No, views cannot enforce data constraints c) Yes, using the FOREIGN KEY constraint d) No, only tables can enforce data constraints Answer: b) No, views cannot enforce data constraints How does a view improve security in a database? a) By allowing users to access only the data they are authorized to see b) By encrypting all data in the database c) By preventing users from accessing any data in the database d) By providing a backup of all data in the database Answer: a) By allowing users to access only the data they are authorized to see Can a view be used in a JOIN operation in a database? a) Yes, views can be used in JOIN operations b) No, views cannot be used in JOIN operations c) Only if the view is created from a single table d) Only if the view is created from multiple tables Answer: a) Yes, views can be used in JOIN operations How does a view affect performance in a database? a) Views can improve performance by simplifying complex queries b) Views can degrade performance by adding an additional layer of complexity c) Views have no impact on performance d) Views can improve performance by speeding up data retrieval Answer: b) Views can degrade performance by adding an additional layer of complexity How is a view dropped in a database? a) By using the DROP TABLE statement b) By using the DELETE VIEW statement c) By using the ALTER VIEW statement d) By using the DROP VIEW statement Answer: d) By using the DROP VIEW statement



Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. What is a view in a database, and how is it different from a table? Answer: A view is a virtual table in a database that displays a subset of data from one or more tables. It differs from a table in that it does not actually store any data, but rather is created by defining a SELECT statement as a table. How can a view be used to simplify complex queries in a database? Answer: Views can be used to simplify complex queries by allowing users to define a SELECT statement that retrieves only the data they need, rather than having to write a more complex query that retrieves data from multiple tables. What is the purpose of creating a view in a database, and how can it improve security? Answer: The purpose of creating a view in a database is to display a subset of data from one or more tables. Views can improve security by allowing users to access only the data they are authorized to see. Can a view be used to enforce data constraints in a database? Answer: No, views cannot be used to enforce data constraints in a database. How can a view be modified in a database? Answer: A view can be modified in a database using the ALTER VIEW statement. Can a view be used in a JOIN operation in a database? Answer: Yes, views can be used in JOIN operations in a database. What is the difference between a simple view and a complex view in a database? Answer: A simple view is a view that is created from a single table, while a complex view is created from multiple tables. How can a view improve performance in a database? Answer: Views can improve performance by reducing the amount of data that needs to be retrieved from the database, and by simplifying complex queries. Can a view be dropped in a database, and if so, how? Answer: Yes, a view can be dropped in a database using the DROP VIEW statement. How does the use of views affect database design and development? Answer: Views can impact database design and development by allowing for a more modular approach, where complex queries are encapsulated in views that can be easily reused and modified.

In a database, a view is a virtual table that displays a subset of data from one or more tables. It is created by defining a SELECT statement as a table, and can be used to simplify complex queries, improve security, and improve performance. Views can be especially useful when dealing with large or complex databases, as they allow users to define a SELECT statement that retrieves only the data they need, rather than having to write a more complex query that retrieves data from multiple tables. This not only simplifies queries, but also improves performance by reducing the amount of data that needs to be retrieved from the database. One of the key benefits of using views in a database is that they can improve security. By using views to limit access to data, database administrators can ensure that users can only access the data they are authorized to see. This can be especially important in industries such as healthcare, where sensitive patient information must be kept confidential. Views can also impact database design and development by allowing for a more modular approach. Instead of writing complex queries over and over again, developers can encapsulate these queries in views that can be easily reused and modified. This not only saves time, but also makes it easier to maintain the database over time. There are two main types of views: simple views and complex views. A simple view is a view that is created from a single table, while a complex view is created from multiple tables. Complex views can be especially useful when dealing with large databases that have multiple tables that need to be joined together. Overall, views are an important tool for anyone working with databases. They can simplify queries, improve security, improve performance, and make database design and development easier and more modular.