Structured Query Language (SQL) William Klingelsmith

Slides:



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

Introduction to Structured Query Language (SQL)
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
1 IT420: Database Management and Organization SQL: Structured Query Language 25 January 2006 Adina Crăiniceanu
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
ASP.NET Programming with C# and SQL Server First Edition
Intro to JDBC To effectively use Java Data Base Connectivity we must understand: 1.Relational Database Management Systems (RDBMS) 2.JDBC Drivers 3.SQL.
LOGO 1 Lab_02: Basic SQL. 2 Outline  Database Tables  SQL Statements  Semicolon after SQL Statements?  SQL DML and DDL  SQL SELECT Statement  SQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
FEN  Data Definition: CREATE TABLE, ALTER TABLE  Data Manipulation: INSERT, UPDATE, DELETE  Queries: SELECT SQL: Structured Query Language.
M1G Introduction to Database Development 5. Doing more with queries.
Oracle & SQL Introduction. Database Concepts Revision DB? DBMS? DB Application? Application Programs? DBS? Examples of DBS? Examples of DBMS? 2Oracle.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
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,
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Aliya Farheen October 29,2015.
WEEK# 12 Haifa Abulaiha November 02,
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
# 1# 1 QueriesQueries How do we ask questions of the data? What is SELECT? What is FROM? What is WHERE? What is a calculated field? Spring 2010 CS105.
Lecture Access – Queries. What’s a Query? A question you ask a database –ie: “Who are my Stockton customers?” –ie: “How much did Bob sell on the 14th?”
Manipulating Data Lesson 3. Objectives Queries The SELECT query to retrieve or extract data from one table, how to retrieve or extract data by using.
SQL Introduction to database and SQL. Chapter 1: Databases and Database Users 6 Introduction to Databases Databases touch all aspects of our lives. Examples:
1 CS 430 Database Theory Winter 2005 Lecture 13: SQL DML - Modifying Data.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
 MySQL  DDL ◦ Create ◦ Alter  DML ◦ Insert ◦ Select ◦ Update ◦ Delete  DDL(again) ◦ Drop ◦ Truncate.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
Fundamentals of DBMS Notes-1.
Rob Gleasure robgleasure.com
Web Systems & Technologies
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Chapter 5 Introduction to SQL.
Rob Gleasure robgleasure.com
Oracle & SQL Introduction
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
SQL 101.
Teaching slides Chapter 8.
Insert, Update, Delete Manipulating Data.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
مقدمة في قواعد البيانات
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Rob Gleasure robgleasure.com
Chapter 2 Views.
Data Management Innovations 2017 High level overview of DB
Introduction To Structured Query Language (SQL)
Contents Preface I Introduction Lesson Objectives I-2
Structured Query Language
Rob Gleasure robgleasure.com
DATABASE Purpose of database
Database SQL.
Manipulating Data Lesson 3.
Use of SQL – The Patricia database
Presentation transcript:

Structured Query Language (SQL) William Klingelsmith

Access Supplemental Content Supplemental Content Document: http://cs101.wvu.edu/resources/supplemental-content/ Or on the web site under “Student Resources” & “Supplemental Content” Structured Query Language (p12 – 14)

Structured Query Language (SQL) Standard computer language for retrieving and updating data within database systems. Database applications like MS Access, MS SQL, Oracle, DB2, Sybase, MySQL, etc. use SQL. We have been using graphical tools to develop and manipulate database objects thus far…

SQL Continued… Access has written the SQL statements behind the scenes for us. The SQL language can be separated into two sub sets: Data Manipulation Language (DML) and the Data Definition Language (DDL). We will look mostly at DML aspects.

Data Definition Language (DDL) The DDL are the SQL commands that define the structure of a database: CREATE TABLE – creates a database table DROPT TABLE – deletes a database table ALTER TABLE – modifies a database table 11/13/2018Date CS101 Sample Presentation

Data Manipulation Language (DML) The DML is SQL Queries (or commands) that will manipulate the data within a database: SELECT– extends or “selects” data from a database table(s) UPDATE– changes or “updates” data from a database table DELETE – removes or “deletes” row(s) from a database table INSERT INTO – adds or “inserts” row(s) of data into a database table 11/13/2018Date CS101 Sample Presentation

SELECT <columns> FROM<tables> SELECT Statement Retrieves all of the data in the fields specified from the specified database table. Syntax is: SELECT <columns> FROM<tables> <columns> is a comma separated list of column names to be returned (AKA Fields) <tables> is the tables where the <columns> are located…

Let’s try it the old way first… Obtain and open Customer_orders.accdb Create a query in design view Add the Customer table only Add all fields Run the query Click “View” and change to “SQL View” to see what was done behind the scenes…

SELECT Exercise Close the Query without saving changes Create a new query in design view. Don’t add any tables Change to “SQL View” Type SELECT * FROM customer Run the query by clicking “!”… Words in capital are “reserved words”

SELECT Exercise Now, let’s revise our SQL SELECT… Go back to SQL View and make it read: SELECT first_name, last_name FROM customer Run the Query We are shown only the fields we requested from the table we told it to use…

One more… Say we wanted to have it ALIAS a column for us which combined first and last name field values and separated them with a space… SELECT (First_Name + “ ” +Last_Name) AS [Full Name] FROM customer Run it! We are presented a field that does not actually exist in the table as we gave it as alias.

WHERE Clause for Criteria This allows us to specify criteria at the command line so that only things matching will be returned. The following are legal operators: = <> < > <= >= Between Like

WHERE Clause Let’s modify our last select to add criteria to it… Run it. SELECT (First_Name + " " + Last_Name) AS [Full Name] FROM customer WHERE Last_Name=“Doe” Have a look in regular Design View and widen out the first field. See the alias name and the criteria

CS101 Sample Presentation JOIN Clause Links tables together to form relationships through the tables’ primary and foreign keys There are three main types of joins: INNER JOIN LEFT JOIN RIGHT JOIN 11/13/2018Date CS101 Sample Presentation

CS101 Sample Presentation INNER JOIN Returns all rows from both tables where there is a match and will exclude the rows where a match is NOT made We will now do an INNER JOIN for customer and address tables. These tables are relational based on primary and foreign keys. 11/13/2018Date CS101 Sample Presentation

CS101 Sample Presentation INNER JOIN Exercise We will use the syntax as table.field to specify what tables to pull field values from. Let’s look at the customer and address tables to see the fields called “address_id” in each. . . “address_id” is a primary key to address table and foreign key to customer table. 11/13/2018Date CS101 Sample Presentation

CS101 Sample Presentation INNER JOIN Exercise Let’s say we wanted to join the customers with their addresses to make a multi-table query . . . We would like the following fields [Customer] table first_name last_name [Address] table Street zipcode 11/13/2018Date CS101 Sample Presentation

CS101 Sample Presentation INNER JOIN Exercise We need to create an inner join on the customer and address tables on the address_id common field When expressing the Join, the syntax will include “customer.address_id” and “address.address_id” . . . 11/13/2018Date CS101 Sample Presentation

CS101 Sample Presentation Create the SQL Command Create a query without adding any tables Flip to SQL view and create this command: SELECT customer.first_name, customer.last_name, address.street, address.zipcode FROM customer INNER JOIN address ON Customer.address_id = address.address_id; 11/13/2018Date CS101 Sample Presentation