April 2002 Information Systems Design John Ogden & John Wordsworth 1 Database Design SQL (1) John Wordsworth Department of Computer Science The University.

Slides:



Advertisements
Similar presentations
TURKISH STATISTICAL INSTITUTE 1 /34 SQL FUNDEMANTALS (Muscat, Oman)
Advertisements

Basic SQL Introduction Presented by: Madhuri Bhogadi.
Virtual training week 4 structured query language (SQL)
COMP 3715 Spring 05. Working with data in a DBMS Any database system must allow user to  Define data Relations Attributes Constraints  Manipulate data.
Database Systems: Design, Implementation, and Management Tenth Edition
Structure Query Language (SQL) COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, VEHARI.
Information Resources Management February 27, 2001.
Introduction to Structured Query Language (SQL)
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
Introduction to Structured Query Language (SQL)
Structured query language This is a presentation by JOSEPH ESTRada on the beauty of Structured Query Language.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
SQL SQL stands for Structured Query Language SQL allows you to access a database SQL is an ANSI standard computer language SQL can execute queries against.
Introduction to Structured Query Language (SQL)
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 7 Introduction to Structured Query Language (SQL)
Chapter 7: SQL, the Structured Query Language Soid Quintero & Ervi Bongso CS157B.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
1 IT420: Database Management and Organization SQL: Structured Query Language 25 January 2006 Adina Crăiniceanu
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
Introduction to SQL J.-S. Chou Assistant Professor.
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
1 IT420: Database Management and Organization SQL - Data Manipulation Language 27 January 2006 Adina Crăiniceanu
Final Review Dr. Bernard Chen Ph.D. University of Central Arkansas.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Fundamentals, Design, and Implementation, 9/e CPE 481 Database Processing Chapter 6 Structured Query Language (SQL) Instructor:Suthep Madarasmi, Ph.D.
Association of Computing Activities Computer Science and Engineering Indian Institute of Technology Kanpur.
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
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Oracle DML Dr. Bernard Chen Ph.D. University of Central Arkansas.
Nitin Singh/AAO RTI ALLAHABAD 1 SQL Nitin Singh/AAO RTI ALLAHABAD 2 OBJECTIVES §What is SQL? §Types of SQL commands and their function §Query §Index.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 6/1 Copyright © 2004 Please……. No Food Or Drink in the class.
BTM 382 Database Management Chapter 7 Introduction to Structured Query Language (SQL) Chitu Okoli Associate Professor in Business Technology Management.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 7 Introduction to Structured.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
Chapter 8: SQL. Data Definition Modification of the Database Basic Query Structure Aggregate Functions.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
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 Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 7 Introduction to Structured Query Language (SQL)
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Database UpdatestMyn1 Database Updates SQL is a complete data manipulation language that can be used for modifying the data in the database as well as.
1/18/00CSE 711 data mining1 What is SQL? Query language for structural databases (esp. RDB) Structured Query Language Originated from Sequel 2 by Chamberlin.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
An Introduction to SQL For CS Overview of SQL  It is the standard language for relational systems, although imperfect  Supports data definition.
1 MySQL and SQL. 2 Topics  Introducing Relational Databases  Terminology  Managing Databases MySQL and SQL.
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
April 2002Information Systems Design John Ogden & John Wordsworth SQL2: 1 Database Design SQL (2) John Wordsworth Department of Computer Science The University.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
SQL LANGUAGE TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
Advanced Accounting Information Systems Day 12 Understanding the SQL Language September 21, 2009.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
SQL, the Structured Query Language
Insert, Update and the rest…
Chapter 3 Introduction to SQL(3)
Working with Tables: Join, Functions and Grouping
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Database systems Lecture 3 – SQL + CRUD
Database Management System
Contents Preface I Introduction Lesson Objectives I-2
Section 4 - Sorting/Functions
Chapter Name SQL: Data Manipulation
Presentation transcript:

April 2002 Information Systems Design John Ogden & John Wordsworth 1 Database Design SQL (1) John Wordsworth Department of Computer Science The University of Reading Room 129, Ext 6544

April 2002 Information Systems Design John Ogden & John Wordsworth 2 Lecture objectives Outline the history of SQL. Distinguish data definition, data manipulation, and data control languages. Use SQL to perform projections and selections on tables. Use the COUNT, GROUP, and ORDER BY options of SQL SELECT. Use SQL for Cartesian product and equijoin. List the column aggregate functions and their uses.

April 2002 Information Systems Design John Ogden & John Wordsworth 3 Overview of SQL Language invented in IBM in the 1970s to support relational databases, and now an international standard. Three aspects: A Data Definition Language A Data Manipulation Language SELECT UPDATE INSERT DELETE A Data Control Language

April 2002 Information Systems Design John Ogden & John Wordsworth 4 Book Tables used throughout the SQL slides (1)

April 2002 Information Systems Design John Ogden & John Wordsworth 5 Publisher Qty Tables used throughout the SQL slides (2)

April 2002 Information Systems Design John Ogden & John Wordsworth 6 SQL : DDL Most important commands: CREATE TABLE CREATE INDEX ALTER TABLE DROP TABLE DROP INDEX CREATE TABLE Book ( IDINTEGERNOT NULL, TitleCHARACTER (35)NOT NULL, AuthorCHARACTER (25)NOT NULL, SubjectCHARACTER (25)NOT NULL ) ; ALTER TABLE Book ADD Bind CHARACTER (1) NOT NULL;

April 2002 Information Systems Design John Ogden & John Wordsworth 7 SELECT syntax SELECT [ DISTINCT | ALL ] { * | column_expression [ AS newname ] [,... ] } FROM table_name [ alias ] [,... ] [ WHERE condition ] [ GROUP BY column_list ] [ HAVING condition ] [ ORDER BY column_list ] ;

April 2002 Information Systems Design John Ogden & John Wordsworth 8 Projection SELECT * FROM Book ; denotes the whole table Book. SELECT DISTINCT Title FROM Book ; denotes the following table:

April 2002 Information Systems Design John Ogden & John Wordsworth 9 SELECT DISTINCT Title, Author FROM Book WHERE Subject = ‘Databases’; Selection

April 2002 Information Systems Design John Ogden & John Wordsworth 10 Using COUNT and GROUP BY SELECT Subject, COUNT(*) AS SCount FROM Book GROUP BY Subject ;

April 2002 Information Systems Design John Ogden & John Wordsworth 11 Using ORDER BY SELECT ID, Title, Author, Bind FROM Book WHERE Subject = ‘Databases’ ORDER BY ID ;

April 2002 Information Systems Design John Ogden & John Wordsworth 12 Cartesian product SELECT Book.*, Qty.* FROM Book, Qty ; denotes the Cartesian product of Book and Qty, 7 columns and 64 rows.

April 2002 Information Systems Design John Ogden & John Wordsworth 13 Equijoin with projection SELECT Title, Bind, No FROM Book, Qty WHERE Book.ID = Qty.ID ;

April 2002 Information Systems Design John Ogden & John Wordsworth 14 SELECT ID, Title, Author FROM Book, Publisher WHERE Book.ID = Publisher.ID AND Publisher.Pub_Name = ‘Addison Wesley’ ORDER BY Author; Equijoin with selection

April 2002 Information Systems Design John Ogden & John Wordsworth 15 SELECT Pub_Name, SUM(Qty.No) FROM Publisher, Qty WHERE Publisher.ID = Qty.ID GROUP BY Pub_Name HAVING SUM (Qty.No) > 1 Equijoin with other conditions

April 2002 Information Systems Design John Ogden & John Wordsworth 16 COUNT: the number of elements in each group SUM: the sum of the numeric values of an attribute in a group AVG: the average of the numeric valued of an attribute in a group MAX: the greatest numeric value of an attribute in a group MIN: the least numeric value of an attribute in a group Column aggregate functions

April 2002 Information Systems Design John Ogden & John Wordsworth 17 Key points SQL has been developed over many years, and is now an international standard. SQL provides commands for defining databases and tables, for making queries and updates, and for creating views and setting security options. The SELECT statement is used for projection, selection, Cartesian product, and equijoin. The column aggregate functions are COUNT, SUM, AVG, MIN, MAX; they need a GROUP BY clause to fix their scope.