This set of Database Multiple Choice Questions & Answers (MCQs) focuses on “Views”.
1. Which of the following creates a virtual relation for storing the query?
a) Function
b) View
c) Procedure
d) None of the mentioned
View Answer
Explanation: Any such relation that is not part of the logical model, but is made visible to a user as a virtual relation, is called a view.
2. Which of the following is the syntax for views where v is view name?
a) Create view v as “query name”;
b) Create “query expression” as view;
c) Create view v as “query expression”;
d) Create view “query expression”;
View Answer
Explanation: <query expression> is any legal query expression. The view name is represented by v.
3.
SELECT course_id FROM physics_fall_2009 WHERE building= ’Watson’;
Here the tuples are selected from the view. Which one denotes the view?
a) Course_id
b) Watson
c) Building
d) physics_fall_2009
View Answer
Explanation: In this SQL query, physics_fall_2009 is the name of the view from which tuples are selected. A view in SQL is a virtual table which can be used to access the data in the same way as a table.
4. Materialised views make sure that
a) View definition is kept stable
b) View definition is kept up-to-date
c) View definition is verified for error
d) View is deleted after specified time
View Answer
Explanation: None.
5. Updating the value of the view
a) Will affect the relation from which it is defined
b) Will not change the view definition
c) Will not affect the relation from which it is defined
d) Cannot determine
View Answer
Explanation: None.
6. SQL view is said to be updatable (that is, inserts, updates or deletes can be applied on the view) if which of the following conditions are satisfied by the query defining the view?
a) The from clause has only one database relation
b) The query does not have a group by or having clause
c) The select clause contains only attribute names of the relation and does not have any expressions, aggregates, or distinct specification
d) All of the mentioned
View Answer
Explanation: All of the conditions must be satisfied to update the view in sql.
7. Which of the following is used at the end of the view to reject the tuples which do not satisfy the condition in where clause?
a) With
b) Check
c) With check
d) All of the mentioned
View Answer
Explanation: Views can be defined with a with check option clause at the end of the view definition; then, if a tuple inserted into the view does not satisfy the view’s where clause condition, the insertion is rejected by the database system.
8. Consider the two relations instructor and department
Instructor:
ID | Name | Dept_name | Salary |
1001 | Ted | Finance | 10000 |
1002 | Bob | Music | 20000 |
1003 | Ron | Physics | 50000 |
Department:
Dept_name | Building | Budget |
Biology | Watson | 40000 |
Chemistry | Painter | 30000 |
Music | Taylor | 50000 |
Which of the following is used to create view for these relations together?
a)
CREATE VIEW instructor_info AS SELECT ID, name, building FROM instructor, department WHERE instructor.dept name= department.dept name;
b)
CREATE VIEW instructor_info SELECT ID, name, building FROM instructor, department;
c)
CREATE VIEW instructor_info AS SELECT ID, name, building FROM instructor;
d)
CREATE VIEW instructor_info AS SELECT ID, name, building FROM department;
Explanation: None.
9. For the view Create view instructor_info as
SELECT ID, name, building FROM instructor, department WHERE instructor.dept name= department.dept name;
If we insert tuple into the view as insert into instructor info values (’69987’, ’White’, ’Taylor’);
What will be the values of the other attributes in instructor and department relations?
a) Default value
b) Null
c) Error statement
d) 0
View Answer
Explanation: The values take null if there is no constraint in the attribute else it is an Erroneous statement.
10.
CREATE VIEW faculty AS SELECT ID, name, dept name FROM instructor;
Find the error in this query.
a) Instructor
b) Select
c) View …as
d) None of the mentioned
View Answer
Explanation: Syntax is – create view v as <query expression>;.
Sanfoundry Global Education & Learning Series – Database Management System.
- Practice Programming MCQs
- Practice Computer Science MCQs
- Check Programming Books
- Apply for Computer Science Internship
- Practice RDBMS MCQ