Instructor: Mohamed Eltabakh

Slides:



Advertisements
Similar presentations
Basic SQL Introduction Presented by: Madhuri Bhogadi.
Advertisements

Dec 4, 2003Murali Mani SQL B term 2004: lecture 14.
Murali Mani SQL: Updates (DML) and Views (DDL). Murali Mani SQL DML (Updating the Data) Insert Delete Update.
Cs3431 SQL: Updates (DML) and Views (DDL). cs3431 SQL DML (Updating the Data) Insert Delete Update.
Dec 15, 2003Murali Mani Transactions and Security B term 2004: lecture 17.
Cs3431 Transactions, Logging and Security. cs3431 Transactions: What and Why? A set of operations on a database must appear as one “unit”. Example: Consider.
Advanced SQL: Stored Procedures Instructor: Mohamed Eltabakh 1.
Information systems and databases Database information systems Read the textbook: Chapter 2: Information systems and databases FOR MORE INFO...
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
 Introduction Introduction  Purpose of Database SystemsPurpose of Database Systems  Levels of Abstraction Levels of Abstraction  Instances and Schemas.
Relational Algebra Instructor: Mohamed Eltabakh 1.
1 Session 3 Welcome: To session 3-the 8 th. learning sequence “Relational algebra “ Recap : In the previous learning sequence, we discussed some example.
Advanced SQL: Cursors & Stored Procedures
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh
1 CS3431 – Database Systems I Introduction Instructor: Mohamed Eltabakh
IS 230Lecture 6Slide 1 Lecture 7 Advanced SQL Introduction to Database Systems IS 230 This is the instructor’s notes and student has to read the textbook.
Advanced SQL: Triggers & Assertions
Indexes and Views Unit 7.
1 The Entity- Relationship Model Instructor: Mohamed Eltabakh
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
1 The Entity- Relationship Model Instructor: Mohamed Eltabakh Part-2.
Advanced SQL: Cursors & Stored Procedures Instructor: Mohamed Eltabakh 1.
CS3431: C-Term CS3431 – Database Systems I Introduction Instructor: Mohamed Eltabakh
SQL: Structured Query Language Instructor: Mohamed Eltabakh 1 Part II.
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh Part 2.
SQL Query Getting to the data ……..
More SQL: Complex Queries,
Introduction Instructor: Mohamed Eltabakh
Translating ER Schema to Relational Model
SQL : Query Language Part II CS3431.
The Entity-Relationship Model
SQL Views CS542.
Instructor: Mohamed Eltabakh
Functional Dependencies and Normalization
CSCI 2141 – Intro to Database Systems
Workbench Data Definition Language (DDL)
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Functional Dependencies and Normalization
SQL Views and Updates cs3431.
Advanced SQL: Views & Triggers
Functional Dependencies and Normalization
Instructor: Mohamed Eltabakh
Instructor: Mohamed Eltabakh
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Instructor: Mohamed Eltabakh
SQL: Structured Query Language
The Relational Model Transparencies
Session #, Speaker Name Views 1/2/2019.
Instructor: Mohamed Eltabakh
SQL: Structured Query Language
Creating a Form © EIT, Author Gay Robertson, 2017.
SQL: Structured Query Language
Instructor: Mohamed Eltabakh
Chapter 11 Managing Databases with SQL Server 2000
CPSC-608 Database Systems
SQL: Structured Query Language
Introduction Instructor: Mohamed Eltabakh
CPSC-608 Database Systems
SQL-Views and External Schemas
SQL Views Presented by: Dr. Samir Tartir
Database SQL.
CS561-Spring 2012 WPI, Mohamed eltabakh
The Relational Data Model
Views Base Relation View
Advanced Topics: Indexes & Transactions
SQL: Structured Query Language
Functional Dependencies and Normalization
Functional Dependencies and Normalization
Presentation transcript:

Instructor: Mohamed Eltabakh meltabakh@cs.wpi.edu Advanced SQL: Views Instructor: Mohamed Eltabakh meltabakh@cs.wpi.edu

Views

What is a View An SQL query that we register (store) inside the database Any query can be a view CREATE VIEW <name> AS <select statement>; DROP VIEW <name>; ProfNumStudents is a view with schema (pNumber, CNT) CREATE VIEW ProfNumStudents AS SELECT pNumber, count(*) AS CNT FROM Student GROUP BY pNumber;

Why Need a View Frequent queries: query is used again and again Complex queries: query written once and stored in the database Logical data independence: the base table may change but the the view is still the same Hide information (Security): allow users to see the view but not the original tables CREATE VIEW StudentBasicInfo AS SELECT sNumber, sName FROM Student; See only sNumber and sName

View Schema You can think of a view as a table, but it gets its data during runtime Only the definition is stored without data View Schema Consists of the columns produced from the select statement CREATE VIEW ProfNumStudents AS SELECT pNumber, count(*) AS CNT FROM Student GROUP BY pNumber; ProfNumStudents(pNumber, CNT) CREATE VIEW StudentBasicInfo AS SELECT sNumber, sName FROM Student; StudentBasicInfo(sNumber, sName)

Example Customers who have accounts Customers who have loans

Example (Cont’d) , ‘A’ as type , ‘L’ as type In this example, we added an extra column (constant) to differentiate between the two customer types , ‘A’ as type , ‘L’ as type

Querying a View Exactly as querying a table