Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL 101 – Class 1 Lee Turner. Agenda 1. This is your life – SQL A brief history of SQL What SQL is and what it is not Normalization 2. Some Super Simple.

Similar presentations


Presentation on theme: "SQL 101 – Class 1 Lee Turner. Agenda 1. This is your life – SQL A brief history of SQL What SQL is and what it is not Normalization 2. Some Super Simple."— Presentation transcript:

1 SQL 101 – Class 1 Lee Turner

2 Agenda 1. This is your life – SQL A brief history of SQL What SQL is and what it is not Normalization 2. Some Super Simple Selection Strategies Create a simple table Create a simple select query 3. Just a Rebel without a Where Clause Using simple where clauses to filter results Examining more complex where clauses 4. A SQL Query walks up to two tables in a restaurant and says: “Mind if I join you?” Inner Joins Outer Joins

3 This is your life - SQL SQL (Pronounced “si kwel”) stands for Structured Query Language. It is a special- purpose programming language designed for managing data held in a relational database management system (RDBMS). Initially developed in the early 1970s by IBM, it was picked up by Relational Software, Inc. (now Oracle Corporation) and offered commercially in 1979 as Oracle V2. SQL was one of the first commercial languages to use the relational model and has become the most widely used database language. SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the International Organization for Standardization (ISO) in 1987.[12] Since then, the standard has been enhanced several times with added features. Despite these standards, code is not completely portable among different database systems, which can lead to vendor lock-in. The different makers do not perfectly adhere to the standard, for instance by adding extensions, and the standard itself is sometimes ambiguous. Source: http://en.wikipedia.org/wiki/SQL

4 What SQL Is and Is Not Computer Language Considered a 4GL Data Definition Data Manipulation Standard Vendors typically deviate from the standard slightly. Language that is pretty simple to grasp the basics, yet capable of performing very complex tasks. SQL Is ASQL Is Not A program owned by any one company. The only way to retrieve data. Synonymous with “Relational”

5 Normalization A relational database stores data in tables that “relate” to other tables. For instance you may have a customer table with information about your customer and an orders table with information about your orders. Within the orders table there is a field that contains the “Customer ID” relating the orders table back to the customer table. The purpose of normalization is to reduce redundant data within the database. Normalized databases typically have fewer data integrity issues, faster index creation and updates as well improved database locking.

6 CREATE A SIMPLE TABLE Go to Database, right-click on “Tables” and select “New Table” Click “New Query” Type Table DDL statement For now, lets stick with int and varchar data types. We will pick up more in future classes. Identity – Automagically created sequential number that ensures every record has a unique value (kinda:) Click on “New Query” Type in Select statement “Select * from Foo;” Select “Query”, “Design Query In Editor…” Right-Click on Table “Select Top 1000 Rows” “Edit Top 200 Rows” CREATE A SIMPLE QUERY Some Super Simple Select Strategies

7 Just a Rebel without a Where Clause Predicates =, <>, >, >=, <, <=, IN, BETWEEN, LIKE, IS NULL or IS NOT NULL Simple “Select * from Foo where customer_name = ‘Google’;” “Select * from Foo where customer_name LIKE ‘Goo%’;” The Where clause is used to limit the returned results to only those that meet a specific criteria. Complex - The keywords AND and OR can be used to combine two predicates into a new one. If multiple combinations are applied, parentheses can be used to group combinations to indicate the order of evaluation. Without parentheses, the AND operator has a stronger binding than OR.

8 Table Joins The SQL JOIN clause is used to join two or more tables using a common field between them. A JOIN can either be an “INNER” or “OUTER” (Just like belly buttons! :) INNER – Only rows that match up. This may bite you when you are doing analysis. OUTER – Left – Returns all rows from the left table, and matched rows from the right. Right – Returns all rows from the right table, and matched rows from the left. Full – Return all rows when there is a match in one of the tables.


Download ppt "SQL 101 – Class 1 Lee Turner. Agenda 1. This is your life – SQL A brief history of SQL What SQL is and what it is not Normalization 2. Some Super Simple."

Similar presentations


Ads by Google