SlideShare a Scribd company logo
4
Most read
6
Most read
9
Most read
Advanced Database
Systems
INSTRUCTOR:
ELLEN GRACE
PORRAS
FIRST SEMESTER 2022-2023
OVERVIEW
Welcome to the first module of this course on the Advanced Database Systems!
Understanding of SQL and its capabilities for querying a single table a prerequisite.
In this subject, you will learn how to retrieve data from multiple tables using one
SQL statement. You will see how tables can be joined together and how similar
results are obtained using different approaches, including the joints and sub queries.
It is important that you understand how to query multiple tables for generating
appropriate reports in the creation of an information system.
Advanced Database Systems
SQL
Statements
3
Most of the actions you need to
perform on a database are done
with SQL statements. The
following SQL statement will
select all the records in the
"Persons" table:
SELECT * FROM Persons
Advanced Database Systems
Semicolon after SQL Statements?
4
Some database systems require a semicolon at the
end of each SQL statement. Semicolon is the
standard way to separate each SQL statement in
database systems that allow more than one SQL
statement to be executed in the same call to the
server.
Advanced Database Systems
5
Advanced Database Systems
SQL can be divided into two parts: The Data Manipulation Language
(DML) and the Data Definition Language (DDL).
SQL DML and DDL
6
Advanced Database Systems
The DDL part of SQL permits database tables to be created or
deleted. It also defines indexes (keys), specifies links between
tables, and imposes constraints between tables. The most
important DDL statements in SQL are:
 CREATE DATABASE - creates a new database
 ALTER DATABASE - modifies a database
 CREATE TABLE - creates a new table
DDL - Data Definition Language:
7
Advanced Database Systems
 ALTER TABLE - modifies a table
 DROP TABLE - deletes a table
 CREATE INDEX - creates an index (search key)
 DROP INDEX - deletes an index
8
Advanced Database Systems
DML - Data Manipulation Language:
The query and update commands form the DML part of SQL:
 SELECT - extracts data from a database
 UPDATE - updates data in a database
 DELETE - deletes data from a database
 INSERT INTO - inserts new data into a database
9
Advanced Database Systems
SQL SELECT Statement
The SELECT statement is used to select data from a database.
The result is stored in a result table, called the result-set.
SQL SELECT Syntax:
SELECT column_name(s)
FROM table_name
And
SELECT * FROM table_name
Note: SQL is not case sensitive. SELECT is the same as select.
10
Advanced Database Systems
Example: SELECT
Table Name: Persons
P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
Now we want to select the content of the columns named "LastName" and
"FirstName" from the table above.
We use the following SELECT statement:
SELECT LastName, FirstName
FROM Persons
11
Advanced Database Systems
The result-set will look like this:
LastName FirstName
Hansen Ola
Svendson Tove
Pettersen Kari
12
Advanced Database Systems
Example: SELECT *
Now we want to select all the columns from the "Persons" table. We use the
following SELECT statement:
SELECT *
FROM Persons
Or
SELECT * FROM Persons
Tip: The asterisk (*) is a quick way of selecting all columns!
13
Advanced Database Systems
The result-set will look like this:
P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
14
Advanced Database Systems
SQL SELECT DISTINCT Statement
In a table, some of the columns may contain duplicate values. This is
not a problem, however, sometimes you will want to list only the
different (distinct) values in a table.
The DISTINCT keyword can be used to return only distinct (different)
values.
15
Advanced Database Systems
SQL SELECT DISTINCT Statement
In a table, some of the columns may contain duplicate values. This is not a
problem, however, sometimes you will want to list only the different (distinct)
values in a table.
The DISTINCT keyword can be used to return only distinct (different) values.
SQL SELECT DISTINCT Syntax:
SELECT DISTINCT column_name(s)
FROM table_name
16
Advanced Database Systems
Example: SELECT DISTINCT
Table Name: Persons
P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
Now we want to select only the distinct values from the column named
"City" from the table above.
17
Advanced Database Systems
We use the following SELECT statement:
SELECT DISTINCT City FROM Persons
The result-set will look like this:
City
Sandnes
Stavanger
18
Advanced Database Systems
We use the following SELECT statement:
SELECT DISTINCT City FROM Persons
The result-set will look like this:
City
Sandnes
Stavanger
Thank you
Presenter name: Ellen Grace D. Porras
Email address: egporras@psu.palawan.edu.ph
This Photo by Unknown Author is licensed under CC BY-SA-NC

More Related Content

PPTX
Structured Query Language (SQL).pptx
PPT
CE 279 - WRITING SQL QUERIES umat edition.ppt
PPTX
Advanced Database Systems - Presentation 3.pptx
DOCX
DOC
Introduction to sql
DOC
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
PPTX
Introduction to SQL
PDF
Chapter – 6 SQL Lab Tutorial.pdf
Structured Query Language (SQL).pptx
CE 279 - WRITING SQL QUERIES umat edition.ppt
Advanced Database Systems - Presentation 3.pptx
Introduction to sql
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
Introduction to SQL
Chapter – 6 SQL Lab Tutorial.pdf

Similar to Advanced Database Systems - Presentation 2.pptx (20)

DOC
A must Sql notes for beginners
PDF
Sql tutorial
PPTX
SQl data base management and design
DOCX
Learning sql from w3schools
PDF
SQL_BASIC AND ADVANCED.pdf
PDF
SQL Basics and Advanced for analytics.pdf
DOCX
SQL Tutorial for BCA-2
PPTX
PPTX
Sql basics
PDF
CS3481_Database Management Laboratory .pdf
PPTX
PPTX
lovely
PDF
BCS4L1-Database Management lab.pdf
DOC
PDF
SQL Complete Tutorial. All Topics Covered
PPT
chapter 8 SQL.ppt
PPT
Advanced sql injection 1
PPTX
SQL commands in database managemant systems
PPTX
PPTX
introduction to SQL query language beginner.ppt
A must Sql notes for beginners
Sql tutorial
SQl data base management and design
Learning sql from w3schools
SQL_BASIC AND ADVANCED.pdf
SQL Basics and Advanced for analytics.pdf
SQL Tutorial for BCA-2
Sql basics
CS3481_Database Management Laboratory .pdf
lovely
BCS4L1-Database Management lab.pdf
SQL Complete Tutorial. All Topics Covered
chapter 8 SQL.ppt
Advanced sql injection 1
SQL commands in database managemant systems
introduction to SQL query language beginner.ppt
Ad

More from EllenGracePorras (20)

PPTX
Lesson 6 Information Management for BSIT.pptx
PPTX
Information Management for BSIT Students.pptx
PPTX
.Net Technologies MessageBox using Visual basic.pptx
PPTX
5 Laboratory Basic Calculator using Visual basic.pptx
PPTX
.Net Technologies - Visual Basic . Net.pptx
PPTX
Geographic Information System Lesson 6 IT
PPTX
Lesson 6 Introduction to Human Computer Interaction.pptx
PPTX
Lesson 3 Introduction to Human Computer Interaction.pptx
PPTX
Lesson 5 Introduction to Human Computer Interaction
PPTX
Geographic Information Systems GIS for BSIT
PPTX
Lesson 3 Introduction to Human Computer Interaction.pptx
PPTX
Lesson 4 Introduction to Human Computer Interaction.pptx
PPTX
Geographic Information System(GIS).pptx
PPTX
Geographic Information Systems (GIS).pptx
PPTX
Advanced Database Systems.pptx
PPTX
Data Manipulation Language.pptx
PPTX
Advanced Database Systems - Presentation 4.pptx
PPTX
Advanced Database Systems - Presentation 1 with quiz.pptx
PPTX
Structured Query Language (SQL) Part 2.pptx
PPTX
SQL Where Clause.pptx
Lesson 6 Information Management for BSIT.pptx
Information Management for BSIT Students.pptx
.Net Technologies MessageBox using Visual basic.pptx
5 Laboratory Basic Calculator using Visual basic.pptx
.Net Technologies - Visual Basic . Net.pptx
Geographic Information System Lesson 6 IT
Lesson 6 Introduction to Human Computer Interaction.pptx
Lesson 3 Introduction to Human Computer Interaction.pptx
Lesson 5 Introduction to Human Computer Interaction
Geographic Information Systems GIS for BSIT
Lesson 3 Introduction to Human Computer Interaction.pptx
Lesson 4 Introduction to Human Computer Interaction.pptx
Geographic Information System(GIS).pptx
Geographic Information Systems (GIS).pptx
Advanced Database Systems.pptx
Data Manipulation Language.pptx
Advanced Database Systems - Presentation 4.pptx
Advanced Database Systems - Presentation 1 with quiz.pptx
Structured Query Language (SQL) Part 2.pptx
SQL Where Clause.pptx
Ad

Recently uploaded (20)

PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
Tartificialntelligence_presentation.pptx
PDF
Getting Started with Data Integration: FME Form 101
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
A Presentation on Artificial Intelligence
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
August Patch Tuesday
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
OMC Textile Division Presentation 2021.pptx
cloud_computing_Infrastucture_as_cloud_p
1. Introduction to Computer Programming.pptx
Group 1 Presentation -Planning and Decision Making .pptx
Programs and apps: productivity, graphics, security and other tools
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Univ-Connecticut-ChatGPT-Presentaion.pdf
Approach and Philosophy of On baking technology
Tartificialntelligence_presentation.pptx
Getting Started with Data Integration: FME Form 101
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
A Presentation on Artificial Intelligence
NewMind AI Weekly Chronicles - August'25-Week II
A comparative analysis of optical character recognition models for extracting...
Reach Out and Touch Someone: Haptics and Empathic Computing
August Patch Tuesday
A comparative study of natural language inference in Swahili using monolingua...
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Advanced Database Systems - Presentation 2.pptx

  • 2. OVERVIEW Welcome to the first module of this course on the Advanced Database Systems! Understanding of SQL and its capabilities for querying a single table a prerequisite. In this subject, you will learn how to retrieve data from multiple tables using one SQL statement. You will see how tables can be joined together and how similar results are obtained using different approaches, including the joints and sub queries. It is important that you understand how to query multiple tables for generating appropriate reports in the creation of an information system. Advanced Database Systems
  • 3. SQL Statements 3 Most of the actions you need to perform on a database are done with SQL statements. The following SQL statement will select all the records in the "Persons" table: SELECT * FROM Persons Advanced Database Systems
  • 4. Semicolon after SQL Statements? 4 Some database systems require a semicolon at the end of each SQL statement. Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server. Advanced Database Systems
  • 5. 5 Advanced Database Systems SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL). SQL DML and DDL
  • 6. 6 Advanced Database Systems The DDL part of SQL permits database tables to be created or deleted. It also defines indexes (keys), specifies links between tables, and imposes constraints between tables. The most important DDL statements in SQL are:  CREATE DATABASE - creates a new database  ALTER DATABASE - modifies a database  CREATE TABLE - creates a new table DDL - Data Definition Language:
  • 7. 7 Advanced Database Systems  ALTER TABLE - modifies a table  DROP TABLE - deletes a table  CREATE INDEX - creates an index (search key)  DROP INDEX - deletes an index
  • 8. 8 Advanced Database Systems DML - Data Manipulation Language: The query and update commands form the DML part of SQL:  SELECT - extracts data from a database  UPDATE - updates data in a database  DELETE - deletes data from a database  INSERT INTO - inserts new data into a database
  • 9. 9 Advanced Database Systems SQL SELECT Statement The SELECT statement is used to select data from a database. The result is stored in a result table, called the result-set. SQL SELECT Syntax: SELECT column_name(s) FROM table_name And SELECT * FROM table_name Note: SQL is not case sensitive. SELECT is the same as select.
  • 10. 10 Advanced Database Systems Example: SELECT Table Name: Persons P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger Now we want to select the content of the columns named "LastName" and "FirstName" from the table above. We use the following SELECT statement: SELECT LastName, FirstName FROM Persons
  • 11. 11 Advanced Database Systems The result-set will look like this: LastName FirstName Hansen Ola Svendson Tove Pettersen Kari
  • 12. 12 Advanced Database Systems Example: SELECT * Now we want to select all the columns from the "Persons" table. We use the following SELECT statement: SELECT * FROM Persons Or SELECT * FROM Persons Tip: The asterisk (*) is a quick way of selecting all columns!
  • 13. 13 Advanced Database Systems The result-set will look like this: P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger
  • 14. 14 Advanced Database Systems SQL SELECT DISTINCT Statement In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table. The DISTINCT keyword can be used to return only distinct (different) values.
  • 15. 15 Advanced Database Systems SQL SELECT DISTINCT Statement In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table. The DISTINCT keyword can be used to return only distinct (different) values. SQL SELECT DISTINCT Syntax: SELECT DISTINCT column_name(s) FROM table_name
  • 16. 16 Advanced Database Systems Example: SELECT DISTINCT Table Name: Persons P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger Now we want to select only the distinct values from the column named "City" from the table above.
  • 17. 17 Advanced Database Systems We use the following SELECT statement: SELECT DISTINCT City FROM Persons The result-set will look like this: City Sandnes Stavanger
  • 18. 18 Advanced Database Systems We use the following SELECT statement: SELECT DISTINCT City FROM Persons The result-set will look like this: City Sandnes Stavanger
  • 19. Thank you Presenter name: Ellen Grace D. Porras Email address: [email protected] This Photo by Unknown Author is licensed under CC BY-SA-NC