© Keith Vander Linden, 2005 1 A language that doesn't affect the way you think about programming is not worth knowing. - Alan Perlis, “Epigrams in Computing”,

Slides:



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

Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Greg Riccardi Florida State University. Using SQL to Manipulate Database Content and Structure How to create queries in SQL –Simple select statements.
Java and Databases CS-328 Dick Steflik. Database Drivers Think of a database as just another device connected to your computer like other devices it has.
The SQL Language Presented by Reggie James, Isel Liunoras, and Chris Rollins.
1 Basic DB Terms Data: Meaningful facts, text, graphics, images, sound, video segments –A collection of individual responses from a marketing research.
Introduction to Structured Query Language (SQL)
SQL Basics Based on the relational algebra we just learned. Nonprocedural language – what to be done not how Simple, powerful language Used for both data.
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
1 SQL-Structured Query Language SQL is the most common language used for creating and querying relational databases. Many users can access a database applications.
Introduction to Structured Query Language (SQL)
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
© Keith Vander Linden, Oracle is clinging to the top spot in the multibillion-dollar database software market, despite mounting pressure from IBM.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
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.
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
10/31/2012ISC239 Isabelle Bichindaritz1 SQL Graphical Queries Design Query By Example.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Appendix C Overview of the QBE (Query-By-Example) Language.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
IMS 4212: Intro to SQL 1 Dr. Lawrence West, Management Dept., University of Central Florida Introduction to SQL—Topics Introduction to.
Getting to Know SQL. © Jim Hope 2002 All Rights Reserved Data Manipulation SELECT statement INSERT INTO statement UPDATE statement DELETE statement TRANSFORM.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
DAT602 Database Application Development Lecture 3 Review of SQL Language.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Information Building and Retrieval Using MySQL Track 3 : Basic Course in Database.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
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.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
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.
Introduction to Database SEM I, AY Department of Information Technology Salalah College of Technology Chapter No.3 SQL.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
There’s a particular style to it… Rob Hatton
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
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.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
Fundamentals of DBMS Notes-1.
How to: SQL By: Sam Loch.
Web Systems & Technologies
SQL Query Getting to the data ……..
Structured Query Language
CS320 Web and Internet Programming SQL and MySQL
Structured Query Language (SQL) William Klingelsmith
Chapter 8 Working with Databases and MySQL
Web Services שפת SQL כתבה: זהבה יעקובסון ליווי מקצועי : ארז קלר
RELATIONAL DATABASES AND XML
The Relational Model Textbook /7/2018.
Introduction To Structured Query Language (SQL)
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Database systems Lecture 3 – SQL + CRUD
Access: SQL Participation Project
Introduction To Structured Query Language (SQL)
CS3220 Web and Internet Programming SQL and MySQL
CS3220 Web and Internet Programming SQL and MySQL
Manipulating Data Lesson 3.
Presentation transcript:

© Keith Vander Linden, A language that doesn't affect the way you think about programming is not worth knowing. - Alan Perlis, “Epigrams in Computing”, SIGPLAN, 1982

© Keith Vander Linden, Database Languages ● Database languages provide features for: – Building a database schema – Retrieving data from a database – Manipulating data in a database ● Two common languages: Two common languages: – Query-By-Example (QBE) Query-By-Example (QBE) – Structured Query Language (SQL) (Sections 9.5-8) Structured Query Language (SQL)

© Keith Vander Linden, Image from July, 2001 Moshe M. Zloof Query-by-Example (QBE) ● Introduced by IBM in 1975 ● Graphical interface to SQL ● Has influenced the query interfaces of other DB systems: – Paradox – Access

© Keith Vander Linden, Query-By-Example

© Keith Vander Linden, Edgar F. Codd Relational Algebra/Calculus ● Developed from ● Relational Algebra - a procedural language: – Relations – Relational operators ● Relational Calculus - a declarative language with equivalent power. Image from July, 2001www.computer.org

© Keith Vander Linden, Structured Query Language

© Keith Vander Linden, The Database Schema

© Keith Vander Linden, Access Query Types ● Retrieval queries: – Select queries ● Modification queries: – Make-table queries – Delete queries – Update queries – Append queries

© Keith Vander Linden, Projection Queries

© Keith Vander Linden, Selection Queries

© Keith Vander Linden, Conditions

© Keith Vander Linden, Join Queries

© Keith Vander Linden, Combining Operations

© Keith Vander Linden, Sorting

© Keith Vander Linden, Grouping & Aggregate Functions

© Keith Vander Linden, Arithmetic

© Keith Vander Linden, SQL ● Structured Query Language: – Specially designed for data queries and updates – Command-line based ● It is the industry standard

© Keith Vander Linden, Access Jet Engine Using SQL Jet DB Interface

© Keith Vander Linden, MSDE EngineSQL ServerJet EngineOracle Engine Using SQL Oracle DBJet DB Access Interface SQL Server DB MSDE DB ODBC Driver ODBC Driver ODBC Driver ODBC Driver VB Application Java Applet JDBC Driver

© Keith Vander Linden, DB Engine Using SQL DB ODBC Driver JDBC Driver Web Browser Network Web Server

© Keith Vander Linden, Basic Query Types ● Single-table queries Single-table queries ● Multiple-table queries Multiple-table queries ● Aggregation and Grouping Aggregation and Grouping ● Set Operations Set Operations ● Database Modifications Database Modifications

© Keith Vander Linden, SELECT Syntax SELECT FROM [WHERE ] [GROUP BY [HAVING ] ] [ORDER BY ]

© Keith Vander Linden, Single-Table Queries Q: Get a list of all the products. SELECT * FROM Products;

© Keith Vander Linden, The SELECT Clause 1 Q: Get names, categories and prices of all the products. SELECT name, unitPrice, category FROM Products;

© Keith Vander Linden, The SELECT Clause 2 Q: Get the total value of each product in stock. SELECT name, (unitPrice * inStock) FROM Products;

© Keith Vander Linden, The SELECT Clause 3 Q: Can SELECT return duplicates or not? SELECT category FROM Products;

© Keith Vander Linden, The SELECT Clause 4 Q: Get a list of the category types for products. SELECT DISTINCT category FROM Products;

© Keith Vander Linden, The WHERE Clause 1 Q: Get the foreign customers. SELECT firstName, lastName, country FROM Customers WHERE country <> 'USA';

© Keith Vander Linden, The WHERE Clause 2 Q: Get the Customers at 100 Main Street, New York. SELECT firstName, lastName, street, city FROM Customers WHERE street='100 Main St.' AND city='New York';

© Keith Vander Linden, The WHERE Clause 3 Q: Get the products without images. SELECT name, image FROM Products WHERE image IS NULL;

© Keith Vander Linden, The ORDER BY Clause Q: Get the Employees in alphabetical order. SELECT lastName+', '+firstName AS fullName FROM Customers ORDER BY lastName, firstName;

© Keith Vander Linden, Multiple-Table Queries Q: Get the list of products for each customer order. SELECT orderId, name, quantity FROM Products, OrderDetails WHERE id=productID;

© Keith Vander Linden, Multiple-Table Queries 2 Q: Get the names of the products and customers that order them. SELECT name, firstName, lastName FROM Products, OrderDetails, Orders, Customers WHERE Products.ID=OrderDetails.productID AND OrderDetails.orderID = Orders.ID AND Orders.customerID = Customers.ID;

© Keith Vander Linden, Grouping and Aggregation 1 Q: Count the products in each category. SELECT category, Count(category) FROM Products GROUP BY category ORDER BY Count(category) DESC;

© Keith Vander Linden, Grouping and Aggregation 2 Q: Get the categories with more than 3 products. SELECT category, Count(category) FROM Products GROUP BY category HAVING Count(category) > 3;

© Keith Vander Linden, Set Operations Q: Get the names of all suppliers and customers. SELECT name FROM Suppliers UNION SELECT firstName+’ ’+lastName FROM Customers;

© Keith Vander Linden, Inserting Data Q: Add Wile E’s alter ego to the customers list. INSERT INTO Customers(id,firstName,lastName) VALUES (14,'Carnivorous','Vulgarus');

© Keith Vander Linden, Updating Data Q: Change Carnivorous’s address. UPDATE Customers SET street = '1 Cave Lane' WHERE id = 14;

© Keith Vander Linden, Deleting Data Q: Remove Carnivorous from the Customers table. DELETE FROM Customers WHERE id = 14;

© Keith Vander Linden, Importing External Data ● Frequently, data from other sources must be imported in bulk. ● Approaches: – an SQL INSERT command file – a specialized import facility