ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Advance Database Management Systems
    COMP3146
    Progress0 / 18 topics
    Topics
    1. Introduction to advance data models such as object relational, object oriented2. File organizations concepts3. Transactional processing4. Concurrency control techniques5. Recovery techniques6. Query processing and optimization7. Database Programming (PL/SQL)8. Database Programming (T-SQL)9. Database Programming (similar technology)10. Integrity and security11. Database Administration (Role management)12. Database Administration (managing database access)13. Database Administration (views)14. Physical database design and tuning15. Distributed database systems16. Emerging research trends in database systems17. MONGO DB18. NO SQL (or similar technologies)
    COMP3146›Database Administration (views)
    Advance Database Management SystemsTopic 13 of 18

    Database Administration (views)

    3 minread
    440words
    Beginnerlevel

    🛠️ Database Administration: Views


    1. What is a View?

    A View is a virtual table based on the result set of a SQL query. It presents data from one or more tables without storing the data physically.

    • Acts as a stored SELECT query.
    • Provides abstraction and simplified data access.
    • Can restrict access to sensitive data.
    • Can combine data from multiple tables.

    2. Why Use Views?

    • Simplify complex queries by encapsulating them.
    • Provide data security by showing only specific columns or rows.
    • Support data abstraction hiding the underlying table structure.
    • Facilitate data consistency by reusing common queries.
    • Can be used as read-only or updatable views (depending on DBMS and query).

    3. Creating a View

    CREATE VIEW employee_details AS
    SELECT employee_id, first_name, last_name, department, salary
    FROM employees
    WHERE status = 'ACTIVE';
    
    • The view employee_details now acts like a table for querying active employees.

    4. Using Views

    • Query a view just like a table:
    SELECT * FROM employee_details WHERE department = 'Sales';
    
    • Views can be joined with other tables or views.

    5. Types of Views

    Type Description
    Simple View Based on a single table without functions or groups. Often updatable.
    Complex View Based on multiple tables, includes joins, aggregates, group by, etc. Usually read-only.
    Materialized View Stores the result physically for faster access, needs refreshing.

    6. Updating Data Through Views

    • Updatable Views allow INSERT, UPDATE, DELETE through the view if:

      • The view is based on a single table.
      • Does not contain aggregates, DISTINCT, GROUP BY, or joins.
      • Includes all NOT NULL columns required.
    • Otherwise, views are read-only.

    Example of updating through view:

    UPDATE employee_details SET salary = salary * 1.1 WHERE employee_id = 101;
    

    7. Advantages of Views

    • Security: Restrict user access to only required data.
    • Simplicity: Hide complexity of underlying joins or calculations.
    • Consistency: Centralize business logic or calculations.
    • Reusability: Share complex queries without rewriting them.

    8. Managing Views

    • Modify view:
    CREATE OR REPLACE VIEW employee_details AS
    SELECT employee_id, first_name, last_name, department, salary
    FROM employees
    WHERE status = 'ACTIVE' AND department IS NOT NULL;
    
    • Drop view:
    DROP VIEW employee_details;
    

    9. Limitations of Views

    • Performance can be slower than direct table queries (especially with complex views).
    • Updatability is restricted based on the view definition.
    • Materialized views require maintenance to keep data fresh.

    10. Summary Table

    Feature Description Example
    Create View Defines a virtual table CREATE VIEW v AS SELECT...
    Query View Access data through the view SELECT * FROM v;
    Updatable View Allows DML operations if conditions met UPDATE v SET salary =...;
    Materialized View Stores data physically, requires refresh CREATE MATERIALIZED VIEW mv AS...
    Drop View Removes the view definition DROP VIEW v;

    Previous topic 12
    Database Administration (managing database access)
    Next topic 14
    Physical database design and tuning

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time3 min
      Word count440
      Code examples0
      DifficultyBeginner