CS-GY 6083: Principles of Database Systems
main
main
  • Introduction
  • DBMS Basics
    • Introduction to DBMS
    • Why use a DBMS instead of a File System?
    • Levels of Abstraction
    • Instances and Schemas
  • Data Models
    • Introduction to Data Models
    • Database Languages
    • Database Design
  • DBMS Internals
    • Introduction to DBMS Internals
    • Storage Manager
    • Query Processor
    • Transaction Management
    • Database Users
    • Database Architecture
  • DBMS History
  • Some Popular Database Systems
  • OLTP, OLAP, and Data Mining
  • Databases vs. Information Retrieval
  • The Entity-Relationship Model - Details
    • Introduction
    • Cardinality Constraints
    • ER Diagram Components
    • ER Diagram to Relational Schema
    • Design Issues
  • The Relational Model - Details
    • Relations
    • Keys
    • Relational Query Languages
      • Relational Algebra
      • Relational Calculus
      • Relative Expressive Power
    • Relational Operators
  • SQL
    • Introduction to SQL
    • Domain Types in SQL
    • DDL Commands
      • Creating a Table
      • Alter and Drop
    • DML Commands
      • Basic Query Structure
      • Select
      • From
      • Where
      • Joins
      • Rename
      • String Operations
      • Ordering
      • Set Operations
      • Group By and Having
      • Nested Subqueries
      • Test for Empty Relations
      • Test for Duplicate Tuples
      • Derived Relations
      • With
      • Database Modification
    • Intermediate SQL
      • Joins Revisited
      • Views
      • Transactions
      • Integrity Constraints
      • More SQL Data Types and Schemas
        • Other Features
      • Authorization
    • Advanced SQL
      • Accessing SQL From a Programming Language
        • ODBC and JDBC
        • Embedded SQL
        • PHP
        • Some Security Issues
      • Accessing Metadata
      • Text Operations
        • Like
        • Contains
      • Cursors
      • Functions and Procedures
        • Procedural Constructs
        • External Language Routines
      • Triggers
      • Ranking
      • Windowing
      • OLAP
Powered by GitBook
On this page

Was this helpful?

  1. SQL
  2. Intermediate SQL

Views

A view provides a mechanism to hide certain data from the view of certain users. Any relation that is not in the conceptual model but is made visible to a user as a “virtual relation” is called a view.

A view is defined using the create view statement which has the form:

create view v as <query expression>

where <query expression> is any legal SQL expression. The view name is represented by v.

Example: A view of instructors without their salary:

create view faculty as
select ID, name, dept_name
from instructor

Once a view is defined, the view name can be used to refer to the virtual relation that the view generates.

Note that updates made to a view will reflect in the relation from which the view was created. Since the view may not have all attributes of the relation, the remaining attributes will be given null values.

In the above example, if a new record is inserted into the view faculty, a new record will be inserted into instructor as well, but salary will be null.

PreviousJoins RevisitedNextTransactions

Last updated 4 years ago

Was this helpful?