SQL Server 2008 Core Skills. Gary Young 2011



Similar documents
T-SQL STANDARD ELEMENTS

MOC 20461C: Querying Microsoft SQL Server. Course Overview

SQL SERVER TRAINING CURRICULUM

AV-005: Administering and Implementing a Data Warehouse with SQL Server 2014

Oracle SQL. Course Summary. Duration. Objectives

Querying Microsoft SQL Server

Oracle Database: SQL and PL/SQL Fundamentals

Course ID#: W 35 Hrs. Course Content

Querying Microsoft SQL Server 20461C; 5 days

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Implementing a Data Warehouse with Microsoft SQL Server

IT2304: Database Systems 1 (DBS 1)

East Asia Network Sdn Bhd

ATTACHMENT 6 SQL Server 2012 Programming Standards

Course 20461C: Querying Microsoft SQL Server Duration: 35 hours

Discovering SQL. Wiley Publishing, Inc. A HANDS-ON GUIDE FOR BEGINNERS. Alex Kriegel WILEY

Oracle Database: SQL and PL/SQL Fundamentals NEW

Querying Microsoft SQL Server (20461) H8N61S

Implementing a Data Warehouse with Microsoft SQL Server 2012

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

Implementing a Data Warehouse with Microsoft SQL Server

Instant SQL Programming

Course Outline. Module 1: Introduction to Data Warehousing

Oracle Database: SQL and PL/SQL Fundamentals

Querying Microsoft SQL Server Course M Day(s) 30:00 Hours

Module 1: Getting Started with Databases and Transact-SQL in SQL Server 2008

COURSE 20463C: IMPLEMENTING A DATA WAREHOUSE WITH MICROSOFT SQL SERVER

Implementing a Data Warehouse with Microsoft SQL Server MOC 20463

COURSE OUTLINE MOC 20463: IMPLEMENTING A DATA WAREHOUSE WITH MICROSOFT SQL SERVER

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

MOC QUERYING MICROSOFT SQL SERVER

Oracle Database 10g: Introduction to SQL

Implementing a Data Warehouse with Microsoft SQL Server 2012 MOC 10777

Introduction to Microsoft Jet SQL

Implementing a Data Warehouse with Microsoft SQL Server

Relational Database: Additional Operations on Relations; SQL

SQL Server 2012 Business Intelligence Boot Camp

LearnFromGuru Polish your knowledge

A Comparison of Database Query Languages: SQL, SPARQL, CQL, DMX

Implement a Data Warehouse with Microsoft SQL Server 20463C; 5 days

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

SQL SERVER DEVELOPER Available Features and Tools New Capabilities SQL Services Product Licensing Product Editions Will teach in class room

Introducing Microsoft SQL Server 2012 Getting Started with SQL Server Management Studio

Implementing a Data Warehouse with Microsoft SQL Server 2012 (70-463)

Course Outline: Course: Implementing a Data Warehouse with Microsoft SQL Server 2012 Learning Method: Instructor-led Classroom Learning

Querying Microsoft SQL Server 2012

Oracle Database 12c: Introduction to SQL Ed 1.1

IT2305 Database Systems I (Compulsory)

Course 10774A: Querying Microsoft SQL Server 2012 Length: 5 Days Published: May 25, 2012 Language(s): English Audience(s): IT Professionals

Course 10774A: Querying Microsoft SQL Server 2012

Microsoft. Course 20463C: Implementing a Data Warehouse with Microsoft SQL Server

Course 10777A: Implementing a Data Warehouse with Microsoft SQL Server 2012

Implementing a Data Warehouse with Microsoft SQL Server 2012

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

MS 20467: Designing Business Intelligence Solutions with Microsoft SQL Server 2012

Implementing a Data Warehouse with Microsoft SQL Server 2012

Oracle Database 11g SQL

Microsoft SQL Server 2008 Bible

LEARNING SOLUTIONS website milner.com/learning phone

SQL Server Administrator Introduction - 3 Days Objectives

BCA. Database Management System

Developing Microsoft SQL Server Databases (20464) H8N64S

20464C: Developing Microsoft SQL Server Databases

SQL SELECT Query: Intermediate

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

Oracle Database: Introduction to SQL

DBMS / Business Intelligence, SQL Server

Querying Microsoft SQL Server 2012

Beginning C# 5.0. Databases. Vidya Vrat Agarwal. Second Edition

Oracle Database: Introduction to SQL

Designing Business Intelligence Solutions with Microsoft SQL Server 2012 Course 20467A; 5 Days

Implementing a Data Warehouse with Microsoft SQL Server

Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems

Databases in Engineering / Lab-1 (MS-Access/SQL)

Developing Microsoft SQL Server Databases 20464C; 5 Days

MS 50511A The Microsoft Business Intelligence 2010 Stack

Saskatoon Business College Corporate Training Centre

Microsoft' Excel & Access Integration

COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

Database Programming with PL/SQL: Learning Objectives

Oracle Database: Introduction to SQL

- Eliminating redundant data - Ensuring data dependencies makes sense. ie:- data is stored logically

ETL Tools. L. Libkin 1 Data Integration and Exchange

1. OLAP is an acronym for a. Online Analytical Processing b. Online Analysis Process c. Online Arithmetic Processing d. Object Linking and Processing

TrendWorX32 SQL Query Engine V9.2 Beta III

Oracle Database: SQL and PL/SQL Fundamentals NEW

Optimizing Your Data Warehouse Design for Superior Performance

Implementing Data Models and Reports with Microsoft SQL Server 20466C; 5 Days

ICAB4136B Use structured query language to create database structures and manipulate data

Beta: Implementing a Data Warehouse with Microsoft SQL Server 2012

Developing Microsoft SQL Server Databases

Course 20464: Developing Microsoft SQL Server Databases

Inquiry Formulas. student guide

How To Create A Table In Sql (Ahem)

Structured Query Language. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

Oracle 10g PL/SQL Training

For Sales Kathy Hall

Transcription:

SQL Server 2008 Core Skills Gary Young 2011

Confucius I hear and I forget I see and I remember I do and I understand

Core Skills Syllabus Theory of relational databases SQL Server tools Getting help Data warehouses Simple queries Aggregate queries Accreditation

Theory of Relational Databases

Relational Model Edgar Codd, IBM (1969) Based on set theory Normalised structure Related data stored in tables Each table has a primary key Tables linked using foreign keys Data manipulated using Structured Query Language (SQL)

Key Concepts Table Primary Key Unique column or combination of columns Foreign key Primary key of one table stored in another table Index Internal catalogue enabling faster queries Column / Field Column of data items of a specified data type Data Type Text Numeric Date/time Binary

Key Concepts View Stored select query May be used to restrict access to certain fields (eg salary) Used like tables System function Calculations and string manipulation User-defined function Encapsulated logic Input parameters Output value Stored procedure Encapsulated logic or process Input / output parameters May or may not return a value

Key Concepts Parameter A value passed to / from a process Trigger Stored procedure / function Automatic process that happens when data is changed Transaction All or nothing process Cash machine withdrawal Rollback on error

Normalisation: Why Bother? Mirror real world objects Save space Very important 1970s Maximise flexibility of querying Reduce risk of anomalies Minimise ambiguity

Denormalised Data

Normalised Data

SQL Terminology SQL Structured Query Language T-SQL Transact SQL (Microsoft extension) Programming language DML Data Manipulation Language select / insert / update / delete DDL Data Definition Language create / alter / drop

Object Naming Server.Database.Schema.Object [rptdev.nwtis.nhs.uk].minerva.common.date Don't need to specify all parts if using defaults Defaults Server: the current server Database: the current database Schema: the current user's default (usually dbo)

Schema Logical database partition Used to enforce security over groups of objects common All users restricted etl Administrators Administrators / data processors

SQL Server Tools

Key Tools SSMS SQL Server Management Studio 75% of your time spent here! DDL / DML Business Intelligence Development Studio SSAS SQL Server Analysis Services Data cubes SSRS SQL Server Reporting Services 25% of your time spent here Reports / dashboards SSIS SQL Server Integration Services Database level automation

Getting Help

Help Phone a friend Ask an expert (colleague) SQL Server 2008 Books Online Syntax for DDL / DML Examples most helpful But... need to know what you re looking for

EBNF Extended Backus-Naur Form Transact SQL Syntax Conventions <label> ::= label is defined as <A><B> A then B <A> <B> A or B [<A>] A is optional [...n] Repetition n times

Function / Operator Reference Will use time and again... Date and time functions dateadd / datetdiff / datename getdate String functions left / right / substring charindex Data types cast / convert Operators like % _ [xyz] [x-z] [^xyz] [^x-z] in ('x', 'y', 'z')

Data Warehouses

Schemas: Disambiguation Logical partition of a database Server.Database.Schema.Object Model Diagram Textual eg EBNF Plan or design of a database Star schema Snowflake schema

Typical Data Warehouse Structure Fact tables Main data tables SUS IP / OP / AE Dimension tables Look-up tables Admission Method GP

Star Schema

Snowflake Schema

Dimensions Star dimensions Simple look-up tables Admission method Ethnic Category Snowflake dimensions Hierarchies GP - Practice - Cluster - PCT - SHA Postcode - Electoral Ward - Town

Surrogate Keys Combine related dimension tables Natural key PAS / NHS Data Dictionary / OCS code Surrogate key Auto number

Simple Queries

Comments Use to improve readability of a script Ignored by SQL Server parser Single line format --this is a single line comment Everything after "--" ignored Multi line /* this is a multi line comment */

Simple Queries select <columns> from <fact table> <join type> join <dimension table> on <joined columns> where <filters> order by <columns>;

Select Modifiers select top x [percent] Restrict to x results Useful for testing select distinct Unique combinations Similar to group by

Aliasing Renaming objects within a query Table from A_Long_Table_Name a Column select PQRSZ123 as 'Easier_To_Read_Name' select PQRSZ123 as [Easier_To_Read_Name]

The Three Joins inner join Matches from both tables left (outer) join All matches from first table Matches from second (if any) Use left join in most cases union [all] All matches from both tables No duplicates! (unless all)

Filtering where clause and filters All filters in combination or filters Either / or filters in (A,B,C) shorthand for A or B or C Use brackets for clarity if used with and Comparators = < > <= >= like '%s%' (not '*s*')

Subqueries Use view like a table Use a select query like a table select <columns> from <fact table> <join type> join <select query> <view> on <joined columns> where <filters> order by <columns>

Case Statement Create new columns on-the-fly Recoding values case end when Day in ('Saturday','Sunday') then 'Weekend' else 'Working Day'

Aggregate Queries

Aggregate Select Query select <grouped columns> <literal columns> <aggregated columns> from <fact table> <join type> join <dimension table> on <joined columns> where <simple filters> group by <grouped columns> having <aggregate filters> order by <columns>;

Aggregate Functions sum Numeric values summed count Number of records min / max avg Lowest / highest values Mean floor / ceiling Next integer lower / higher

Accreditation

Time-limited Test Simple select Use of filters (where) Join types (inner / outer) Sorting (order by) Union Aggregate select Aggregate functions (count / min / max etc) Aggregate filters (having) Use of system functions Datetime (datediff / dateadd etc) String (left / right etc)