Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University

Slides:



Advertisements
Similar presentations
© Abdou Illia MIS Spring 2014
Advertisements

A Guide to SQL, Seventh Edition. Objectives Use joins to retrieve data from more than one table Use the IN and EXISTS operators to query multiple tables.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
What is a Database By: Cristian Dubon.
Virtual training week 4 structured query language (SQL)
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data
Database Systems More SQL Database Design -- More SQL1.
Introduction to Structured Query Language (SQL)
Microsoft Access 2010 Chapter 7 Using SQL.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Introduction to Databases Chapter 7: Data Access and Manipulation.
CSE314 Database Systems More SQL: Complex Queries, Triggers, Views, and Schema Modification Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
ITBIS373 Database Development
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Using Special Operators (LIKE and IN)
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 6/1 Copyright © 2004 Please……. No Food Or Drink in the class.
CpSc 3220 The Language of SQL The Language of SQL Chapters
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
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.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
 CONACT UC:  Magnific training   
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.
LEC-8 SQL. Indexes The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Fundamentals of DBMS Notes-1.
Web Systems & Technologies
SQL Query Getting to the data ……..
More SQL: Complex Queries,
Chapter 5 Introduction to SQL.
CpSc 3220 The Language of SQL
Relational Database Design
Insert, Update and the rest…
SQL Creating and Managing Tables
Database Systems: Design, Implementation, and Management Tenth Edition
SQL Creating and Managing Tables
SQL Creating and Managing Tables
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Chapter 2 Views.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Chapter 7 Introduction to Structured Query Language (SQL)
SQL DATA CONSTRAINTS.
A Guide to SQL, Eighth Edition
Chapter 2 Views.
Structured Query Language – The Fundamentals
Contents Preface I Introduction Lesson Objectives I-2
Chapter 8 Advanced SQL.
CSC 453 Database Systems Lecture
Database Systems: Design, Implementation, and Management Tenth Edition
IST 318 Database Administration
Shelly Cashman: Microsoft Access 2016
Presentation transcript:

Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University Ch5 Summary Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University

Subquery or Nested query Subquery or Nested query is one of the most powerful features of SQL Select command This feature enables you to ask complex questions that entail retrieving different types of data or data from different sources A subquery can contain another subquery and so on The DBMS generally evaluates the innermost query first and passes results back to the higher level

Subqueries and Sets of Data IN, ALL, ANY, EXISTS IN Operator Use the IN operator to match values in a list The match is based on equality E.g. WHERE ItemID IN (1,2,30,32,33). This means that the ItemID number must be in this list ANY & ALL Any & All operators combine comparison of numbers with subsets. ANY & ALL work with > or < operators and compare the test value to a list of values Using All operator the test value must be greater than all of the values in the list.

Subtraction: NOT IN As the name suggests, this operator is the opposite of IN operator. It gets the rows that are NOT in the defined list

Correlated Subqueries A subquery that refers to data rows in the main query, in which the calculation is recomputed for each entry In other words, the main query and the subquery are both referring to the same table. Therefore for each row in the main query the subquery will re-run

Union, Intersect, Except Union combines data from two tables. All searches and operations performed will treat the two tables as one large table The most important thing to remember when creating a Union, is that data from both tables must match (e.g. EID to EID, Name to Name) The basic version of the command automatically eliminates duplicate rows of data. If you want to keep all rows – even the duplications- use UNION ALL

Intersect Operator Except Operator Returns the rows that appear in both tables Except Operator Returns rows that appear in the first table only. Notice that the result of Except operator depends on which table is listed first

Multiple Join Columns The syntax for multiple joins is simple, we expand the on statement by listing both column connections The two sets of columns must be equal at the same time, so they are connected with an AND

Reflexive Join or self-join A Reflexive join means that a table is joined to itself One column in a table is used to match values in a second column in the same table The key to self-joins is to make sure that the columns contain the same type of data, and to create an alias for the second copy of the table

Inequality Joins (Theta Join) Most join statements are simple equality conditions using = sign When comparisons are made with inequality operators (less than, greater than) instead of an equals sign, it is called Inequality or theta join

SQL Data Definition Commands Create Schema A schema is a collection of tables SYNTAX : CREATE SCHEMA AUTHORIZATION DBname Password

Create Table This command defines a new table and all of the columns that it will contain Not NULL command is used to identify the key columns for the table DEFAULT assign default values SYNTAX : CREATE TABLE Customer (CustomerID INTEGER NOT NULL, LastName VARCHAR(10), );

Constraints Constraints are rules that are enforced by the database system Each constraint is given a name e.g. pkorder You can choose any name, but you should pick one that you will recognize later The primary key constraint list the column or columns that make up the primary key Note that each column in the primary key should also be marked as NOT NULL The foreign key lists the column in the current table that is linked to (reference) a column in the second table

Alter Table & Drop Table These commands enable you to modify the structure of an existing table. Drop command will remove the entire table from the database, including its data and structural definition Alter table is used to ADD or DELETE columns from a table When you drop an entire column, all the data stored in that column will be deleted When you add a new column, it will contain NULL values for any existing rows

SQL Data Manipulation Commands Data manipulation commands are used to change the data within the tables They are used to : Insert data Delete rows Update (change) the values of specific cells Remember that these commands : Operate on sets of data at one time Utilize the power of SELECT and WHERE statements

Insert into Insert has 2 versions: Insert into target values ….. This is used to insert one row of data at a time, and is found to be not very useful SELECT ………. FROM……. This is used to select rows and insert them in one time into another table This is very useful in the case of copying data from one table into another based on a certain WHERE condition

Delete Delete From table Where Condition Delete command deletes rows within a table based on WHERE condition, Drop command removes an entire table

Update Update command is used to change an entire collection of rows at one time. You use the WHERE clause to specify which set or rows need to be changed SYNTAX: UPDATE TABLE SET COLUMN = NEW COLUMN VALUE WHERE CONDITION