EXAMPLE Emp table: SS# Name Age Salary dno 1 Joe Mary 20

Slides:



Advertisements
Similar presentations
Classwork notes. 2 Find the names of all employees whose salary greater than all managers salary.
Advertisements

Database Tuning. Overview v After ER design, schema refinement, and the definition of views, we have the conceptual and external schemas for our database.
ER to Relational Mapping. Logical DB Design: ER to Relational Entity sets to tables. CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER,
4-1 Copyright  Oracle Corporation, All rights reserved. Types of Joins Equijoin Non-equijoin Outer join Self join.
COP-5725 Practice Exercises
6.830/6.814 Lecture 5 Database Internals Continued September 17, 2014.
Fall 2005 ICS184/EECS116 – Notes 08 1 ICS 184/EECS116: Introduction to Data Management Lecture Note 8 SQL: Structured Query Language -- DDL.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Extended SQL & The Relational Calculus.
Recap of Feb 13: SQL, Relational Calculi, Functional Dependencies SQL: multiple group bys, having, lots of examples Tuple Calculus Domain Calculus Functional.
Copyright  Oracle Corporation, All rights reserved. 6 Writing Correlated Subqueries.
Chapter 5 Recursion in SQL. 2 Example. Let Flights(Flight#, Source_Ctiy, Dest_City) be a relational schema DEN CHI SFO DAL NY UA 930 DL 900 UA 1400 UA.
DB performance tuning using indexes Section 8.5 and Chapters 20 (Raghu)
RELATIONAL ALGEBRA Prof. Sin-Min LEE Department of Computer Science.
Query Optimization Example Source: Query Optimization, Y. E. Ioannidis, ACM Computing Surveys, 28(1), March Database Tables: Emp (name, age, sal,
Naveen Ashish Calit2 & ICS UC Irvine SQL. SQL -- historical Perspective Dr. Edgar Codd (IBM) “A Relational Model of Data for Large Shared Data Banks"
Classwork notes Find all departments’ name which have at least five employees whose salary grater than $5000.
RELATIONAL ALGEBRA Prof. Sin-Min LEE Department of Computer Science.
SQL - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Creating a Table Create a table, “emp”, containing: –empno – a 4 digit employee number –ename – up to 10 character string –job – up to 9 character string.
Copyright  Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
Chapter 5 Advanced SQL. 2 Recursion in SQL Example. Let Flights(Flight#, Source_City, Dest_City) be a relational schema DEN CHI SFO DAL NY UA 930 DL 900.
1 ICS 184: Introduction to Data Management Lecture Note 10 SQL as a Query Language (Cont.)
RELATIONAL ALGEBRA and Computer Assignment 1 Prof. Sin-Min LEE Department of Computer Science.
Views. Logical data is how we want to see the current data in our database. Physical data is how this data is actually placed in our database.
New SQL Commands in Oracle. INNER JOINs NATURAL JOIN Perform JOIN based on like columns in two tables. The Like columns must be of the same name and data.
1 ICS 184: Introduction to Data Management Lecture Note 11: Assertions, Triggers, and Index.
2 Writing Basic SELECT Statements. 1-2 Copyright  Oracle Corporation, All rights reserved. Capabilities of SQL SELECT Statements Selection Projection.
STRUCTURED QUERY LANGUAGE Chandra S. Amaravadi 1.
제 2 장 SQL 활용.  SQL 활용 예제 (1) create table student ( id int not null, name char(20) not null, age int, height int, weight float, primary key(id) ); insert.
1 JOIN SUBQUERY Structured Query Language (SQL) - Part III.
SQL SeQueL -Structured Query Language SQL SQL better support for Algebraic operations SQL Post-Relational row and column types,
CSE 6331 © Leonidas Fegaras OODB1 Object-Oriented Databases and the ODMG Standard.
42 Example Join-- File Information 4 Emp( Fn Char(10), Minit Char, LN Char(20), SSN number(9), Bdate Date, Addr char(40), Sex Char, Salary Number(9,2),
Displaying Data from Multiple Tables (SQL99 Syntax with examples)
COMP3030 Database Management System Final Review
Functional dependency: a relationship between two attributes (or sub-sets of attributes) in a relational database, such that the value of the first attribute.
COP-5725 Practice Exercises
ORDER BY clause in SELECT command: Normally, the result of the query will not be in ordered format. If we want to get the result of the query in specific.
1 VIEW Structured Query Language (SQL) - Part IV.
Physical DB Design Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Lecture 2 Joins and sub-queries. 2 Topics zJoins ySimple; Outer zSub-queries yaliases zIN Operator zNULL values zSaving and running files.
Writing Basic SQL Statements. Objectives After completing this lesson, you should be able to do the following: –List the capabilities of SQL SELECT statements.
Object-Oriented Databases and the ODMG Standard
Entity-Relationship Model Cont…..
Introduction to Database Systems, CS420
Data and Applications Security Developments and Directions
SQL-lab Download sql script file sailors.txt
STRUCTURED QUERY LANGUAGE Chandra S. Amaravadi.
Remaining Topics in SQL to be covered…
'. \s\s I. '.. '... · \ \ \,, I.
Interacting with the Oracle Server
Generalization.
CS222: Principles of Data Management Notes #13 Set operations, Aggregation Instructor: Chen Li.
RELATIONAL ALGEBRA (Chapter 2)
الفصل الثاني الصيغة العامة لجمله select*
Joining Tables ضم الجداول وإستخراج مناظر views منها الهدف : 1- استخراج المعلومات من جدولين أو اكثر بالإستفادة من الرابط بينهما وبإستخدام SQL 2- شروط قواعد.
جملة الاستعلام الأساسية
JOINS.
SQL.
' '· \ ·' ,,,,
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
Data and Applications Security Developments and Directions
Data and Applications Security Developments and Directions
SQLPLUS: Oracle SQL Interface
Introduction to Relational databases
Integrity Constraints
Copyright © Ellis Cohen
Database Programming Using Oracle 11g
Physical Database Design and Tuning
Practice Project Practice to know SQL
Presentation transcript:

EXAMPLE Emp table: SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: 2019/2/22

EXAMPLE Select * From Emp Where salary=30,000 Emp table: SS# Name Age dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select * From Emp Where salary=30,000 2019/2/22

EXAMPLE Select * From Emp Where salary=30,000 Emp table: SS# Name Age dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select * From Emp Where salary=30,000 SS# Name Age Salary dno 4 Kathy 30 30000 5 2019/2/22

EXAMPLE Select * From Emp Where age > 22 Emp table: SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select * From Emp Where age > 22 2019/2/22

EXAMPLE Select * From Emp Where age > 22 Emp table: SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select * From Emp Where age > 22 SS# Name Age Salary dno 1 Joe 24 20000 2 4 Kathy 30 30000 5 2019/2/22

EXAMPLE Emp table: SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: 2019/2/22

EXAMPLE Emp table: Select age From Emp SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select age From Emp Age 24 20 22 30 4 2019/2/22

EXAMPLE Emp table: Select name, age From Emp Where Salary = 4000 SS# dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select name, age From Emp Where Salary = 4000 2019/2/22

EXAMPLE Emp table: Select name, age From Emp Where Salary = 4000 SS# dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select name, age From Emp Where Salary = 4000 SS# Name Age Salary dno 5 Shideh 4 4000 1 2019/2/22

EXAMPLE Emp table: Select name, age From Emp Where Salary = 4000 SS# dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Emp table: Select name, age From Emp Where Salary = 4000 Name Age Shideh 4 2019/2/22

Join clause Example: Emp table: Dept table: SS# Name age salary dno 345 John Doe 23 25,000 1 943 Jane Java 25 28,000 2 876 Joe SQL 22 32,000 dno dname floor mgrSS# 1 Toy 345 2 Shoe 943 2019/2/22

Join clause Select * From Emp e, Dept d Where e.dno = d.dno 2019/2/22

Join clause Select * From Emp e, Dept d Where e.dno = d.dno SS# Name age salary e.dno d.dno dname floor mgrSS# 345 John Doe 23 25,000 1 Toy 876 Joe SQL 22 32,000 943 Jane Java 25 28,000 2 Shoe 2019/2/22

EXAMPLE JOIN Select * From Emp e, Dept d Where e.dno = d.dno EMP Dept SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Select * From Emp e, Dept d Where e.dno = d.dno dno dname floor mgrss# 1 Toy 5 2 Shoe EMP Dept 2019/2/22

EXAMPLE JOIN Select * From Emp e, Dept d Where e.dno = d.dno EMP Dept SS# Name Age Salary dno 1 Joe 24 20000 2 Mary 20 25000 3 Bob 22 27000 4 Kathy 30 30000 5 Shideh 4000 Select * From Emp e, Dept d Where e.dno = d.dno dno dname floor mgrss# 1 Toy 5 2 Shoe EMP Dept SS# Name Age Salary e.dno d.dno dname floor mgrss# 1 Joe 24 20000 2 Shoe Mary 20 25000 Toy 5 3 Bob 22 27000 4 Kathy 30 30000 Shideh 4000 2019/2/22

EXAMPLE SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob 23 25000 Shideh 4 40000 Kathy 15 32000 2019/2/22

EXAMPLE SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob 23 25000 Shideh 4 40000 Kathy 15 32000 Select e.name From Emp e, Emp Mgr Where e.mgrSS# = Mgr.SS# and e.salary > Mgr.salary 2019/2/22

EXAMPLE EXECUTION SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob 23 25000 3 Shideh 4 40000 Kathy 15 32000 Select e.name From Emp e, Emp Mgr Where e.mgrSS# = Mgr.SS# and e.salary > Mgr.salary e.SS# e.Name e.Age e.Salary e.mgrSS# Mgr.SS# Mgr.Name Mgr.Age Mgr.Salary Mgr.mgrSS# 2 Bob 23 25000 1 Joe 30 30000 Null 3 Shideh 4 40000 Kathy 15 32000 2019/2/22

EXAMPLE SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob 23 25000 Shideh 4 40000 Kathy 15 32000 Select e.name From Emp e, Emp Mgr Where e.mgrSS# = Mgr.SS# and e.salary > Mgr.salary e.SS# e.Name e.Age e.Salary e.mgrSS# Mgr.SS# Mgr.Name Mgr.Age Mgr.Salary Mgr.mgrSS# 3 Shideh 4 40000 1 Joe 30 30000 Null Kathy 15 32000 2019/2/22

EXAMPLE SS# Name Age Salary mgrSS# 1 Joe 30 30000 Null 2 Bob 23 25000 Shideh 4 40000 Kathy 15 32000 Select e.name From Emp e, Emp Mgr Where e.mgrSS# = Mgr.SS# and e.salary > Mgr.salary e.Name Shideh Kathy 2019/2/22