SQL views and indexing

December 4, 2026 · Team EasyExamNotes · 2 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-502 DBMS June 2026 solved question paper

RGPV CS-502 (GS) | June 2026 | Q3(b) | 7 marks (inferred)

Question (restated): Discuss SQL views and indexing using examples.

Answer

SQL query; View definition; Base table + index
SQL views and indexing

A view is a named query that presents a virtual relation. Ordinary views generally store the query definition rather than its result. They simplify complex joins, expose selected columns and provide a stable interface. A materialized view stores results and needs refresh; support varies by DBMS.

CREATE VIEW CSEStudents AS

SELECT StudentID, Name FROM Student WHERE DeptID = 10;

SELECT * FROM CSEStudents;

A view can hide sensitive columns, but permissions must be configured correctly. Simple views may be updatable; joins, grouping and aggregates often restrict updates. WITH CHECK OPTION can prevent changes through a view that would violate its predicate where supported.

An index is an auxiliary access structure that speeds up searches, joins and sometimes ordering. B-tree indexes support equality and range queries; hash indexes primarily support equality. A composite index on (DeptID, Name) can help queries filtering by DeptID and ordering by Name, depending on the optimizer.

CREATE INDEX idx_student_dept ON Student(DeptID);

SELECT Name FROM Student WHERE DeptID = 10;

Without an index the engine may scan the table; with an index it may locate matching row references directly. Indexes consume storage and add maintenance cost to inserts, updates and deletes. Low-selectivity predicates may still favor scans. A view is a logical interface whereas an index is a physical access aid. Neither guarantees faster execution; inspect execution plans to evaluate actual benefit.

← RGPV CS-502 DBMS June 2026 solved question paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion