Submit Search
Upload
Relational Databases - Lecture 4 - SQL language
•
0 likes
•
127 views
Karina Sokolova
Follow
SQL language syntax
Read less
Read more
Technology
Report
Share
Report
Share
1 of 59
Recommended
Introduction to databases
Introduction to databases
Dr Timothy Osadiya CITP., FIfL., ACII
RDBMS
RDBMS
PriyangaRajaram
Basic Concept Of Database Management System (DBMS) [Presentation Slide]
Basic Concept Of Database Management System (DBMS) [Presentation Slide]
Atik Israk
Lesson 1: Introduction to DBMS
Lesson 1: Introduction to DBMS
Amrit Kaur
Query processing
Query processing
Dr. C.V. Suresh Babu
Normalization
Normalization
meet darji
Review of theory of database
Review of theory of database
Anne Lee
ADO.NET difference faqs compiled- 1
ADO.NET difference faqs compiled- 1
Umar Ali
Recommended
Introduction to databases
Introduction to databases
Dr Timothy Osadiya CITP., FIfL., ACII
RDBMS
RDBMS
PriyangaRajaram
Basic Concept Of Database Management System (DBMS) [Presentation Slide]
Basic Concept Of Database Management System (DBMS) [Presentation Slide]
Atik Israk
Lesson 1: Introduction to DBMS
Lesson 1: Introduction to DBMS
Amrit Kaur
Query processing
Query processing
Dr. C.V. Suresh Babu
Normalization
Normalization
meet darji
Review of theory of database
Review of theory of database
Anne Lee
ADO.NET difference faqs compiled- 1
ADO.NET difference faqs compiled- 1
Umar Ali
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Biplap Bhattarai
Temporal database
Temporal database
Hussain Azmee
The relational database model
The relational database model
Dhani Ahmad
Normalization
Normalization
Salman Memon
Introduction to Relational Databases
Introduction to Relational Databases
Research Support Team, IT Services, University of Oxford
ADBMS Object and Object Relational Databases
ADBMS Object and Object Relational Databases
Jayanthi Kannan MK
17-NoSQL.pptx
17-NoSQL.pptx
levichan1
1. Introduction to DBMS
1. Introduction to DBMS
koolkampus
Database Normalization
Database Normalization
Arun Sharma
database Normalization
database Normalization
Harsiddhi Thakkar
Nested Queries Lecture
Nested Queries Lecture
Felipe Costa
CHAPTER-4_RELATIONAL-DATABASE.pptx
CHAPTER-4_RELATIONAL-DATABASE.pptx
RiaBago
normaliztion
normaliztion
Ramadhani S. Zuberi
Data models
Data models
Usman Tariq
Lesson 2 network database system
Lesson 2 network database system
GiO Friginal
Mapa mental BD y DBMS
Mapa mental BD y DBMS
Benjamín Joaquín Martínez
The Database Environment and Development Process
The Database Environment and Development Process
Dr. Rosemarie Sibbaluca-Guirre
Different type of databases
Different type of databases
Shwe Yee
Data Dictionary
Data Dictionary
Vishal Anand
Bases de Datos NoSQL
Bases de Datos NoSQL
Isabel Gómez
Relational Databases - Lecture 5 - SQL injection
Relational Databases - Lecture 5 - SQL injection
Karina Sokolova
Relational Databases - Lecture 2 - Entity-relationship diagram
Relational Databases - Lecture 2 - Entity-relationship diagram
Karina Sokolova
More Related Content
What's hot
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Biplap Bhattarai
Temporal database
Temporal database
Hussain Azmee
The relational database model
The relational database model
Dhani Ahmad
Normalization
Normalization
Salman Memon
Introduction to Relational Databases
Introduction to Relational Databases
Research Support Team, IT Services, University of Oxford
ADBMS Object and Object Relational Databases
ADBMS Object and Object Relational Databases
Jayanthi Kannan MK
17-NoSQL.pptx
17-NoSQL.pptx
levichan1
1. Introduction to DBMS
1. Introduction to DBMS
koolkampus
Database Normalization
Database Normalization
Arun Sharma
database Normalization
database Normalization
Harsiddhi Thakkar
Nested Queries Lecture
Nested Queries Lecture
Felipe Costa
CHAPTER-4_RELATIONAL-DATABASE.pptx
CHAPTER-4_RELATIONAL-DATABASE.pptx
RiaBago
normaliztion
normaliztion
Ramadhani S. Zuberi
Data models
Data models
Usman Tariq
Lesson 2 network database system
Lesson 2 network database system
GiO Friginal
Mapa mental BD y DBMS
Mapa mental BD y DBMS
Benjamín Joaquín Martínez
The Database Environment and Development Process
The Database Environment and Development Process
Dr. Rosemarie Sibbaluca-Guirre
Different type of databases
Different type of databases
Shwe Yee
Data Dictionary
Data Dictionary
Vishal Anand
Bases de Datos NoSQL
Bases de Datos NoSQL
Isabel Gómez
What's hot
(20)
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Temporal database
Temporal database
The relational database model
The relational database model
Normalization
Normalization
Introduction to Relational Databases
Introduction to Relational Databases
ADBMS Object and Object Relational Databases
ADBMS Object and Object Relational Databases
17-NoSQL.pptx
17-NoSQL.pptx
1. Introduction to DBMS
1. Introduction to DBMS
Database Normalization
Database Normalization
database Normalization
database Normalization
Nested Queries Lecture
Nested Queries Lecture
CHAPTER-4_RELATIONAL-DATABASE.pptx
CHAPTER-4_RELATIONAL-DATABASE.pptx
normaliztion
normaliztion
Data models
Data models
Lesson 2 network database system
Lesson 2 network database system
Mapa mental BD y DBMS
Mapa mental BD y DBMS
The Database Environment and Development Process
The Database Environment and Development Process
Different type of databases
Different type of databases
Data Dictionary
Data Dictionary
Bases de Datos NoSQL
Bases de Datos NoSQL
Similar to Relational Databases - Lecture 4 - SQL language
Relational Databases - Lecture 5 - SQL injection
Relational Databases - Lecture 5 - SQL injection
Karina Sokolova
Relational Databases - Lecture 2 - Entity-relationship diagram
Relational Databases - Lecture 2 - Entity-relationship diagram
Karina Sokolova
Relational Databases - Lecture 3 - Logical and physical models (UML)
Relational Databases - Lecture 3 - Logical and physical models (UML)
Karina Sokolova
Relational Databases - Lecture 1 - Introduction
Relational Databases - Lecture 1 - Introduction
Karina Sokolova
shake! 2017 예선 문제 풀이
shake! 2017 예선 문제 풀이
HYUNJEONG KIM
Cdma basics
Cdma basics
uday joshi
Intro to Biodesign: Working with Living Things
Intro to Biodesign: Working with Living Things
Leticia Oxley
Andrew Baum - ArborGen President and CEO
Andrew Baum - ArborGen President and CEO
Arkansas Forestry Association
Traffic light Controller Design
Traffic light Controller Design
Ivan Tim Oloya
Not Dead Yet: Designing Great Experiences with Bad Data
Not Dead Yet: Designing Great Experiences with Bad Data
Sonia Koesterer
X1
X1
Maxim Petrov
In-silico study of ToxCast GPCR assays by quantitative structure-activity rel...
In-silico study of ToxCast GPCR assays by quantitative structure-activity rel...
Kamel Mansouri
Similar to Relational Databases - Lecture 4 - SQL language
(12)
Relational Databases - Lecture 5 - SQL injection
Relational Databases - Lecture 5 - SQL injection
Relational Databases - Lecture 2 - Entity-relationship diagram
Relational Databases - Lecture 2 - Entity-relationship diagram
Relational Databases - Lecture 3 - Logical and physical models (UML)
Relational Databases - Lecture 3 - Logical and physical models (UML)
Relational Databases - Lecture 1 - Introduction
Relational Databases - Lecture 1 - Introduction
shake! 2017 예선 문제 풀이
shake! 2017 예선 문제 풀이
Cdma basics
Cdma basics
Intro to Biodesign: Working with Living Things
Intro to Biodesign: Working with Living Things
Andrew Baum - ArborGen President and CEO
Andrew Baum - ArborGen President and CEO
Traffic light Controller Design
Traffic light Controller Design
Not Dead Yet: Designing Great Experiences with Bad Data
Not Dead Yet: Designing Great Experiences with Bad Data
X1
X1
In-silico study of ToxCast GPCR assays by quantitative structure-activity rel...
In-silico study of ToxCast GPCR assays by quantitative structure-activity rel...
Recently uploaded
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
Pooja Nehwal
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Puma Security, LLC
Key Features Of Token Development (1).pptx
Key Features Of Token Development (1).pptx
LBM Solutions
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
XfilesPro
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
Padma Pradeep
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Rafal Los
Slack Application Development 101 Slides
Slack Application Development 101 Slides
praypatel2
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Katpro Technologies
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
HostedbyConfluent
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Maria Levchenko
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Radu Cotescu
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Delhi Call girls
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
Paola De la Torre
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Pixlogix Infotech
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
Mark Billinghurst
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Safe Software
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
HampshireHUG
Recently uploaded
(20)
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Key Features Of Token Development (1).pptx
Key Features Of Token Development (1).pptx
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Slack Application Development 101 Slides
Slack Application Development 101 Slides
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Relational Databases - Lecture 4 - SQL language
1.
1 0 0 1 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 1 0 1 ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ ✑ ✐ ✐ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 0 1 0 0 1 ✑ 1 0 0 1 0 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 0 1 0 0 1 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✑ Database management SQL
2.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 SQL • Developed in
1970 by IBM as SEQUEL (Structured English QUEry Language) • Structured Query Language • data definition • data manipulation • data control • Based on relational algebra but not strictly following • Helps managing data held in a relational database management system (RDBMS)
3.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Create table CREATE TABLE
Student ( stdId int NOT NULL PRIMARY KEY, unvName varchar(50), stdName varchar(30) NOT NULL, stdSurname varchar(30), stdNat varchar(20) NOT NULL, FOREIGN KEY (unvName) REFERENCES University(unvName) ); CREATE TABLE University ( unvName varchar(50) NOT NULL PRIMARY KEY, unvCountry varchar(20) NOT NULL, unvAddress varchar(90) NOT NULL ); STD_ID: INTEGER UNV_NAME: VARCHAR (50) STD_NAME: VARCHAR (30) STD_SURNAME: VARCHAR (30) STD_NAT: VARCHAR (20) STUDENT UNIVERSITY UNV_NAME: VARCHAR (50) UNV_COUNTRY: VARCHAR (20) UNV_ADDRESS: VARCHAR (90)
4.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Fill in a
table INSERT INTO University VALUES ('UTT', 'France', 'Troyes'), ('PSB', 'France', 'Paris'); INSERT INTO Student VALUES (123, 'UTT', 'Mike', 'Wazowski', 'Polish' ), (345, 'PSB', 'Mary', 'Wazowski', 'Polish' ); STD_ID: INTEGER UNV_NAME: VARCHAR (50) STD_NAME: VARCHAR (30) STD_SURNAME: VARCHAR (30) STD_NAT: VARCHAR (20) STUDENT UNIVERSITY UNV_NAME: VARCHAR (50) UNV_COUNTRY: VARCHAR (20) UNV_ADDRESS: VARCHAR (90)
5.
1 0 0 1 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 1 0 1 ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ ✑ ✐ ✐ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 0 1 0 0 1 ✑ 1 0 0 1 0 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 0 1 0 0 1 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✑ Querying language SQL
6.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Set theory Set of
Columns SetofRows
7.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Rules • Sets -
collections of objects • Tables -> smallest logical subset of data • Column -> unique category of information • Row -> must be unique • Order of columns or rows doesn’t matter
8.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Operations on sets Union
A ∪ B Intersection A ∩ B Difference A - B Subset
9.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Basics Subset
10.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Projection • Choose columns
from the full table • The result table have <= attributes than the original
11.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Projection SELECT * FROM database.table1 attribute1
attribute2 attribute3 attribute4 1 ab 12.01 # 2 bc 25.06 @ table1 attribute2 attribute4 ab # bc @ table1 SELECT attribute2, attribute4 FROM table1
12.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Projection SELECT * FROM Student StdId
StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 18.2 95000 Student mean 12.01 18.2 Temp SELECT StdMean AS mean FROM Student
13.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Projection SELECT * FROM Student StdId
StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 18.2 95000 Student StdMean*1000 1201 1820 Temp SELECT StdMean * 1000 FROM Student
14.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Restriction • Choose rows
from the full table • The result table have <= tuples than the original • Conditions on attributes: =, >, <, like, in, between, etc. SELECT * FROM database.table1 WHERE condition
15.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Restriction = SELECT StdName FROM
Student WHERE StdZip = 10000 StdId StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 19.9 95000 3 Mary 18.2 10000 4 Toad 10.8 40000 5 Stan 15.34 10000 6 Franc 13.6 41000 7 Aude 17.9 18000 Student StdName Stan Mary Stan Temp
16.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Restriction BETWEEN SELECT StdName FROM
Student WHERE StdZip BETWEEN 10000 AND 20000 StdId StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 19.9 95000 3 Mary 18.2 10000 4 Toad 10.8 40000 5 Stan 15.34 10000 6 Franc 13.6 41000 7 Aude 17.9 18000 Student StdName Stan Mary Stan Aude Temp
17.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Restriction LIKE SELECT StdName FROM
Student WHERE StdName LIKE ‘Ma%’ OR StdName LIKE ‘%e’ StdId StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 19.9 95000 3 Mary 18.2 10000 4 Toad 10.8 40000 5 Stan 15.34 10000 6 Franc 13.6 41000 7 Aude 17.9 18000 Student StdName Marc Mary Aude Temp
18.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Duplicates SELECT DISTINCT StdName FROM
Student WHERE StdZip = 10000 StdId StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 19.9 95000 3 Mary 18.2 10000 4 Toad 10.8 40000 5 Stan 15.34 10000 6 Franc 13.6 41000 7 Aude 17.9 18000 Student StdName Stan Mary Temp
19.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 NULL SELECT StdName FROM Student WHERE
StdMean IS null StdId StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc NULL 95000 3 Mary NULL 10000 4 Toad 10.8 40000 5 Stan 15.34 10000 6 Franc 13.6 41000 7 Aude NULL 18000 Student StdName Marc Mary Aude Temp
20.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Order • The results
are not ordered • ORDER BY attribute is used to order the result • The default order is ASC - ascending (or alphabetical) • Add DESC to make in descending
21.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Order by SELECT DISTINCT
StdZip FROM Student ORDER BY StdZip ASC StdId StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 19.9 95000 3 Mary 18.2 10000 4 Toad 10.8 40000 5 Stan 15.34 10000 6 Franc 13.6 41000 7 Aude 17.9 18000 Student StdZip 10000 18000 40000 41000 95000 Temp
22.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Order by SELECT DISTINCT
StdZip FROM Student ORDER BY StdZip DESC StdId StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 19.9 95000 3 Mary 18.2 10000 4 Toad 10.8 40000 5 Stan 15.34 10000 6 Franc 13.6 41000 7 Aude 17.9 18000 Student StdZip 95000 41000 40000 18000 10000 Temp
23.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Limit SELECT DISTINCT StdZip FROM
Student ORDER BY StdZip DESC LIMIT 3 StdId StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 19.9 95000 3 Mary 18.2 10000 4 Toad 10.8 40000 5 Stan 15.34 10000 6 Franc 13.6 41000 7 Aude 17.9 18000 Student StdZip 95000 41000 40000 Temp
24.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Aggregation • MIN, MAX,
SUM, AVG, COUNT • SELECT min(attribute) • FROM table • WHERE condition • Group by columns • Having condition
25.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Min SELECT MIN(StdMean) FROM Student StdId
StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 19.9 95000 3 Mary 18.2 10000 4 Toad 10.8 40000 5 Stan 15.34 10000 6 Franc 13.6 41000 7 Aude 17.9 18000 Student min(Mean) 10.8 Temp
26.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Count SELECT COUNT(StudentID) FROM Apply WHERE
University = ‘UTT’ StudentID Date University 123 2013 UTT 234 2015 UTT 123 2014 UTT 678 2016 PSB 345 2015 UTT 234 2015 EPF 123 2013 EPF Apply count(StudentID) 4 Temp
27.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Count distinct StudentID Date
University 123 2013 UTT 234 2015 UTT 123 2014 UTT 678 2016 PSB 345 2015 UTT 234 2015 EPF 123 2013 EPF Apply count(StudentID) 3 Temp SELECT COUNT(distinct StudentID) FROM Apply WHERE University = ‘UTT’
28.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Count by StudentID Date
University 123 2013 UTT 234 2015 UTT 123 2014 UTT 678 2016 PSB 345 2015 UTT 234 2015 EPF 123 2013 EPF Apply University student UTT 3 PSB 1 EPF 2 Temp SELECT University, COUNT(distinct StudentID) as student FROM Apply GROUP BY University
29.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Count by StudentID Date
University 123 2013 UTT 234 2015 UTT 123 2014 UTT 678 2016 PSB 345 2015 UTT 234 2015 EPF 123 2013 EPF Apply University student id UTT 3 234 PSB 1 678 EPF 2 123 Temp SELECT University, COUNT(distinct StudentID) as student, StudentID as id FROM Apply GROUP BY University Random
30.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Having StudentID Date University 123
2013 UTT 234 2015 UTT 123 2014 UTT 678 2016 PSB 345 2015 UTT 234 2015 EPF 123 2013 EPF Apply University PSB EPF Temp SELECT University FROM Apply GROUP BY University HAVING count(*) < 4
31.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Combine relations
32.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Cartesian product • Obtain
all combinations of two sets a b c d x y a x a y b x b y c x c y d x d y { { { { } } } } {
33.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Cartesian product SELECT StdName,
UnvName FROM Student, University StdId StdName StdMean StdZip 1 Stan 12.01 10000 2 Marc 19.9 95000 3 Mary 18.2 10000 Student StdName UnvName Stan PSB Marc UTT Mary PSB Stan UTT Marc PSB Mary UTT Temp UnvId UnvName UnvLocation 1 PSB Paris 2 UTT Troyes University
34.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Join • Combine tuples
of two tables based on certain condition
35.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Simple Join EmpId Name 1
Stan 2 Marc 3 Mary Employee ParentId Name Age 1 Sara 7 1 Amy 10 3 Pole 2Child Employee.Name Child.Name Stan Sara Stan Amy Mary Pole Temp { { SELECT e.Name, c.Name FROM Employee e, Child c WHERE e.EmpId = c.ParentId
36.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Inner Join EmpId Name 1
Stan 2 Marc 3 Mary Employee ParentId Name Age 1 Sara 7 1 Amy 10 3 Pole 2Child Employee.Name Child.Name Stan Sara Stan Amy Mary Pole Temp { { SELECT Employee.Name, Child.Name FROM Employee INNER JOIN Child ON EmpId = ParentId
37.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Join EmpId Name 1 Stan 2
Marc 3 Mary Employee ParentId Name Age 1 Sara 7 1 Amy 10 3 Pole 2Child Employee.Name Child.Name Stan Sara Stan Amy Mary Pole Temp { { SELECT Employee.Name, Child.Name FROM Employee JOIN Child ON EmpId = ParentId
38.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Natural Join ParentId ParentName 1
Stan 2 Marc 3 Mary Employee ParentId ChildName Age 1 Sara 7 1 Amy 10 3 Pole 2Child ParentName ChildName Stan Sara Stan Amy Mary Pole Temp { { SELECT ParentName, ChildName FROM Employee NATURAL JOIN Child key is found automatically
39.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Natural Join ParentId ParentName 1
Stan 2 Marc 3 Mary Employee ParentId ChildName Age 1 Sara 7 1 Amy 10 3 Pole 2Child ParentName ChildName Stan Sara Stan Amy Mary Pole Temp { { SELECT ParentName, ChildName FROM Employee JOIN Child USING(ParentId) good practice to define a key
40.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Simple Join StdId StdName
StdZip 1 Stan 10000 2 Marc 95000 3 Mary 10000Student UnvId UnvName UnvLocation 1 PSB Paris 2 UTT Troyes 3 EPF TroyesUniversity StdId UnvId Date 1 1 01.01.15 2 2 05.05.15 3 1 14.03.15Apply StdName UnvName Stan PSB Mary PSB Temp { { {{ SELECT StdName, UnvName FROM Student, Apply, University WHERE Student.StdId=ApplyStdID AND University.UnvID=Apply.UnvID AND Apply.UnvId=1
41.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Simple Join StdId StdName
StdZip 1 Stan 10000 2 Marc 95000 3 Mary 10000Student UnvId UnvName UnvLocation 1 PSB Paris 2 UTT Troyes 3 EPF TroyesUniversity StdId UnvId Date 1 1 01.01.15 2 2 05.05.15 3 1 14.03.15Apply StdName UnvName Stan PSB Mary PSB Temp { { {{ SELECT StdName, UnvName FROM Student JOIN Apply ON Student.StdId=Apply.StdID JOIN University ON University.UnvID=Apply.UnvID WHERE Apply.UnvId=1
42.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Self Join • Combine
tuples of two tables based on certain condition • Used when the same type of information presented as two attributes • Classical example: employee and its manager id name surname manager 1 John Smith 3 2 Mike Wazowski 3 3 Bill Gates NULL 4 Crazy Frog 2 Employee
43.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Self Join id name
surname manager 1 John Smith 3 2 Mike Wazowski 3 3 Bill Gates NULL 4 Crazy Frog 2 name surname m.name m.surname John Smith Bill Gates Mike Wazowski Bill Gates Crazy Frog Mike Wazowski SELECT e1.name, e1.surname, e2.name as m.name, e2.surname as m.surname FROM Employee e1, Employee e2 WHERE e1.manager = e2.id Employee
44.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Join
45.
1 0 0 1 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ ✑ ✐ ✐ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 0 1 0 0 1 ✑ 0 0 1 0 0 1 0 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 0 1 0 0 1 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 ✑ ✐ ✐ ✑ ✑ Create and query
46.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Sets and subqueries
47.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Intersect • Returns only
common tuples of two queries • Removes duplicate rows from the final result set • Two results must: • Have the same number of attributes • Have attributes of the same type
48.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Intersect SELECT * FROM sales2015 INTERSECT SELECT
* FROM sales2016 Person Amount Alex 1000 Piter 3000 Mary 500 Aude 5600 Person Amount Alex 5000 Piter 3000 John 3500 Aude 5600 Person Amount Piter 3000 Aude 5600 sales2015 sales2016 temp
49.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Intersect ALL SELECT person,
amount FROM sales2015 INTERSECT ALL SELECT person, amount FROM sales2016 id person amount 1 Alex 1000 2 Piter 3000 3 Mary 500 4 Aude 5600 id person amount 1 Piter 3000 2 Piter 3000 3 John 3500 4 Aude 5600 person amount Piter 3000 Aude 5600 Piter 3000 sales2015 sales2016 temp
50.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 IN SELECT * FROM sales2015 WHERE
person IN ( SELECT person FROM sales2016 ) Person Amount Alex 1000 Piter 3000 Mary 500 Aude 5600 Person Amount Alex 5000 Piter 3000 John 3500 Aude 5600 Person Amount Piter 3000 Aude 5600 Alex 1000 sales2015 sales2016 temp
51.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 EXISTS SELECT person, amount FROM
sales2015 s1 WHERE EXISTS (SELECT * FROM sales2016 s2 WHERE s2.person=s1.person) id person amount 1 Alex 1000 2 Piter 3000 3 Mary 500 4 Aude 5600 id person amount 1 Piter 3000 2 Piter 3000 3 John 3500 4 Aude 5600 person amount Piter 3000 Aude 5600 sales2015 sales2016 temp
52.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Except • Returns tuples
all tuples from the first query that are not present in the second query • EXCEPT ALL does not remove duplicate rows from the final result • Two results must: • Have the same number of attributes • Have attributes of the same type
53.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Except SELECT * FROM sales2015 EXCEPT SELECT
* FROM sales2016 Person Amount Alex 1000 Piter 3000 Mary 500 Aude 5600 Person Amount Alex 5000 Piter 3000 John 3500 Aude 5600 Person Amount Alex 1000 Mary 500 sales2015 sales2016 temp
54.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 NOT IN SELECT * FROM
sales2015 WHERE person IN ( SELECT person FROM sales2016 ) Person Amount Alex 1000 Piter 3000 Mary 500 Aude 5600 Person Amount Alex 5000 Piter 3000 John 3500 Aude 5600 Person Amount Mary 500 sales2015 sales2016 temp
55.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 NOT EXISTS SELECT person,
amount FROM sales2015 s1 WHERE NOT EXISTS (SELECT * FROM sales2016 s2 WHERE s2.person=s1.person) id person amount 1 Alex 1000 2 Piter 3000 3 Mary 500 4 Aude 5600 id person amount 1 Piter 3000 2 Piter 3000 3 John 3500 4 Aude 5600 person amount Alex 1000 Mary 500 sales2015 sales2016 temp
56.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Union • Combine the
results of two queries into one • Two results must: • Have the same number of attributes • Have attributes of the same type
57.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Union SELECT * FROM sales2015 UNION SELECT
* FROM sales2016 Person Amount Alex 1000 Piter 3000 Mary 500 Aude 5600 Person Amount Alex 5000 Piter 3000 John 3500 Aude 5600 Person Amount Alex 5000 Piter 3000 John 3500 Aude 5600 Alex 1000 Mary 500 sales2015 sales2016 temp
58.
1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 ✑ ✑ 1 ✑ ✑ 1 0 1 Union ALL SELECT * FROM
sales2015 UNION ALL SELECT * FROM sales2016 Person Amount Alex 1000 Piter 3000 Mary 500 Aude 5600 Person Amount Alex 5000 Piter 3000 John 3500 Aude 5600 Person Amount Alex 5000 Piter 3000 John 3500 Aude 5600 Alex 1000 Piter 3000 Mary 500 Aude 5600sales2015 sales2016 temp
59.
1 0 0 1 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ ✑ ✐ ✐ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✑ ✑ ✐ ✑ ✐ ✑ ✐ ✐ ✑ ✐ ✐ ✑ ✐ ✑ ✑ 0 1 0 0 1 ✑ 0 0 1 0 0 1 0 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 0 1 0 0 1 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 ✑ ✐ ✐ ✑ ✑ Queries