IST359 M005 Yang Wang 342 Hinds SQL Programming And The External Model.

Slides:



Advertisements
Similar presentations
Transact-SQL. 1. Declare float = 10 select * from customers where discnt
Advertisements

Murach’s Java SE 6, C21© 2007, Mike Murach & Associates, Inc.Slide 1.
The Database Environment IST359 M005 Yang Wang 342 Hinds
IST359: Introduction to DBMS IST359 Fall 2012 Instructor : Yang Wang 342 Hinds M005: 9:30a-10:50a Lecture: Tuesdays.
©Silberschatz, Korth and Sudarshan4.1Database System Concepts Modification of the Database – Deletion Delete all account records at the Perryridge branch.
Fundamentals, Design, and Implementation, 9/e Chapter 7 Using SQL in Applications.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
Structured Query Language SQL: An Introduction. SQL (Pronounced S.Q.L) The standard user and application program interface to a relational database is.
Module 9 Designing an XML Strategy. Module 9: Designing an XML Strategy Designing XML Storage Designing a Data Conversion Strategy Designing an XML Query.
Structured Query Language SQL IST359 M005 Yang Wang 342 Hinds
Security and Integrity
Sql Server Advanced Features MIS 424 Professor Sandvig.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
IMS 4212: Application Architecture and Intro to Stored Procedures 1 Dr. Lawrence West, Management Dept., University of Central Florida
Introduction. 
 CONVENIENT  HELPS YOU KEEP TRACK OF MONEY: USING THE CHECK REGISTER OR ONLINE BANKING  SAVES YOU MONEY – EXPENSES ARE LESS THAN MONEY ORDERS.
CSIS 4310 – Advanced Databases Virtual Private Databases.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
Company LOGO 1 Database Creation and Maintenance Jorge G. Martinez.
Module 1: Introduction to Transact-SQL
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
Chapter 9 Selecting, Updating, and Deleting Data Syed Rizvi.
Stored Procedure. Objective At the end of the session you will be able to know :  What are Stored Procedures?  Create a Stored Procedure  Execute a.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
06 | Modifying Data in SQL Server Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program Manager.
IMS 4212: Data Manipulation 1 Dr. Lawrence West, MIS Dept., University of Central Florida Additional Data Manipulation Statements INSERT.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
CS 338The Relational Model2-1 The Relational Model Lecture Topics Overview of SQL Underlying relational model Relational database structure SQL DDL and.
Slide 1 of 19Session 13 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 In this session, you will learn to: Implement stored procedures Implement.
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
G. Green 1.  Options include:  Script Files  already covered  APIs  last course topic  Database-Stored Code  our focus 2.
Oracle11g: PL/SQL Programming Chapter 3 Handling Data in PL/SQL Blocks.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
Copyright © 2013 Curt Hill Triggers The Generation of Indirect Actions.
SQL PROGRAMMING AND THE EXTERNAL MODEL Fact of the Week: According to the 2010 outlook from the BLS 286,600 new Computer, Network, and Database administrator.
Relational Database Model & Database Development Process IST359 M005 Yang Wang 342 Hinds
SQL Select Statement IST359 M005 Yang Wang 342 Hinds
Slide 1 Chapter 7 – Part 3 Stored Procedure, Function &Trigger.
SQL Server 2012 Session: 1 Session: 12 Triggers Data Management Using Microsoft SQL Server.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Ch 5. Introducing More Database Objects. Database Objects Table (ch2) View (ch3) Stored Procedure Trigger Function User-defined types.
IMS 4212: Application Architecture and Intro to Stored Procedures 1 Dr. Lawrence West, Management Dept., University of Central Florida
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
IT420: Database Management and Organization Triggers and Stored Procedures 24 February 2006 Adina Crăiniceanu
ASET 1 Amity School of Engineering & Technology B. Tech. (CSE/IT), III Semester Database Management Systems Jitendra Rajpurohit.
Module 10 Merging Data and Passing Tables. Module Overview Using the MERGE Statement Implementing Table Types Using Table Types As Parameters.
There’s a particular style to it… Rob Hatton
 CONACT UC:  Magnific training   
Bank Reconciliation Chapter 4. PAGE REF #CHAPTER 4: Bank Reconciliation SLIDE # 2 Objectives Reconcile your checking Create bank reconciliation reports.
Create Stored Procedures and Functions Database Management Fundamentals LESSON 2.4.
Dynamic SQL Writing Efficient Queries on the Fly ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
1. Advanced SQL Functions Procedural Constructs Triggers.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Dynamic SQL Writing Efficient Queries on the Fly
© 2016, Mike Murach & Associates, Inc.
Introduction to PL/SQL Programing
Views, Stored Procedures, Functions, and Triggers
Dynamic SQL Writing Efficient Queries on the Fly
PL/SQL Programing : Triggers
Query Optimization Techniques
Database Processing: David M. Kroenke’s Chapter Seven:
SQL Fundamentals in Three Hours
Information Management
Handling Data in PL/SQL Blocks
IST 318 Database Administration
Query Optimization Techniques
Presentation transcript:

IST359 M005 Yang Wang 342 Hinds SQL Programming And The External Model

Acknowledgements and caveat These slides draw liberally, with permission, from the following sources: IST359 materials by Prof. Michael Fudge Jr. Slides from Murach’s SQL Server 2008 book Caveat (beware): At best, PowerPoint slides are only a pale limitation of the entirety of a class meeting. In IST359 in particular, the lectures will cover topics beyond what appears in these slides. Don’t rely on them as a substitute for attending class.

Learning Objectives Understand the rationale and purpose of SQL programming Understand and explain the external data model Learn how to create views, stored procedures, and functions Learn how to perform program flow control in T-SQL

Where are we?

Internal –vs- External Data Models INTERNAL Optimal design for storing data Complex & atomic in nature Implemented with Tables, keys, constraints EXTERNAL Mimics user functionality Abstracted & simplified in nature Implemented with views, stored procedures, functions

The External Model == Abstractions Views – abstractions for the SELECT statement. Simplifies complex queries with joins, etc. Stored Procedures – abstractions for DML. Simplifies a complex series of INSERTS, UPDATES or DELETES. User-defined Functions – abstractions for custom program logic where values need to be returned.

The External Model

Create and set a variable as DATETIME = getdate()

Create a procedure CREATE PROCEDURE dbo.p_add_zipcode as as as char(2) ) AS BEGIN INSERT INTO zipcodetable ( ZIPCD, CITY, ST) @state); RETURN END

Call a procedure EXECUTE p_add_zipcode ‘13039’, ‘Cicero’, ‘NY’ = p_add_zipcode ‘90210’, ‘Bev Hills’, ‘CA’ PRINT ‘Zip code Added!’

Create a function CREATE FUNCTION as as char(2) ) RETURNS char(5) AS BEGIN RETURN (SELECT ZIPCD FROM zipcodetable WHERE AND END

Call a function SELECT lookup_zip(‘Clay’,’NY’) as ‘zip code’

FUDGE FICTITIOUS CREDIT UNION Let’s explore the external data model and T-SQL programming by example. QUICK DEMO

Basic Data Model (Internal Model)

FFCU – Simplified User Stories 1.When a person signs up, then they become a new customer. All new customers have an opening balance in their savings account. 2.A customer can deposit funds into their account. 3.A customer can withdrawal funds from their account 4.A customer can have view balances their 2 types of accounts, Checking and Savings 5.A customer can transfer funds between their accounts. (checking to savings and vice-versa)

External Model p_signup – sign a user up for an account p_deposit – deposit funds into user’s account p_withdrawl – take out funds from a user’s account p_transfer – transfer funds from one user account to another v_myaccounts – show balances for the user’s account

p_signup INSERT INTO Customers... INSERT INTO Accounts… – (Savings with initial starting amount) INSERT INTO Accounts… – (Checking)

p_transfer UPDATE Accounts… – (Remove amount from account) UPDATE Accounts… – (Add amount to account)

v_myaccounts Show detailed account information for Customer, Account(s), and Type(s) of Accounts. Create a view ffcu_vMyAccounts Read the view select * from ffcu_vMyAccounts