Structured Query Language (SQL)

Содержание

Слайд 2

Lesson objectives: Understand what is SQL and how it’s used. Understand

Lesson objectives:
Understand what is SQL and how it’s used.
Understand what

the syntax commands do.
Be able to write SQL commands.

Learning objective:
11.4.2.1 explain the purpose of data dictionary
11.4.2.2 compare the data definition language (DDL), and the data manipulation language (DML)

Слайд 3

Success criteria Be able to use the SELECT, UPDATE, INSERT, DELETE

Success criteria

Be able to use the SELECT, UPDATE, INSERT, DELETE
Be able

to create queries in SQL
Слайд 4

Lesson 1 Discussed question «what is a query in the database?»

Lesson 1

Discussed question «what is a query in the database?»

Слайд 5

Research work. Students research “Data dictionary” Activity. Pair work. From the

Research work.

Students research “Data dictionary”
Activity. Pair work.
From the table, students define

a data dictionary
Слайд 6

Group work. Students create a data dictionary for the database, create

Group work. Students create a data dictionary for the database, create

poster

automobile salon
tourist company
pizza delivery

protection of posters and evaluation

Слайд 7

Слайд 8

lesson 2 What is SQL?

lesson 2 What is SQL?

Слайд 9

Слайд 10

Слайд 11

SQL stands for Structured Query Language (Structured Query Language). SQL allows

SQL stands for Structured Query Language (Structured Query Language).
SQL allows you

to work with the database.
SQL - this language, which is the ANSI standard.
SQL allows you to query the database.
SQL allows you to extract data from the database.
SQL allows you to insert new records in the database.
SQL allows you to delete records from the database.
SQL allows you to update records in the database.
SQL is easy to learn.
Слайд 12

SQL statements are divided into: Operators of data definition (Data Definition

SQL statements are divided into:

Operators of data definition (Data Definition Language,

DDL):
CREATE creates a database object (database itself, tables, views, user, and so on. D.)
ALTER modifies the object
DROP deletes an object;
Operators of data manipulation (Data Manipulation Language, DML):
SELECT selects the data that meet certain conditions,
INSERT adds new data,
UPDATE modifies existing data,
DELETE deletes the data;
Слайд 13

Data Manipulation Language, DML: SELECT field_name FROM table_name WHERE condition SELECT

Data Manipulation Language, DML:

SELECT field_name FROM table_name WHERE condition
SELECT - defines the

fields that contain the necessary data
FROM - specifies the tables that contain the fields specified in the the SELECT
WHERE - specifies the conditions of selection fields, which must comply with all the records included in the results
Слайд 14

Data Manipulation Language, DML Example: SELECT * FROM Customers; Output all

Data Manipulation Language, DML

Example:
SELECT * FROM Customers;

Output all fields and records

the Customers table
Слайд 15

Example: SELECT CustomerName, Country FROM Customers; Shows records CustomerName , Country

Example:
SELECT CustomerName, Country FROM Customers;

Shows records CustomerName , Country fields

from Customers table

Data Manipulation Language, DML

Слайд 16

Example: SELECT CustomerName, City FROM Customers WHERE City=‘Berlin'; Shows records CustomerName,

Example:
SELECT CustomerName, City FROM Customers
WHERE City=‘Berlin';

Shows records CustomerName,

City fields, from Customers table where the City field value is equal to the word ‘Berlin’

Data Manipulation Language, DML

Слайд 17

Activity Go to this link http://sqlzoo.net/wiki/SELECT_from_Nobel_Tutorial perform the task of 1,

Activity

Go to this link
http://sqlzoo.net/wiki/SELECT_from_Nobel_Tutorial
perform the task of 1, 2, 5, 8,

12
Show your answers for teacher
Слайд 18

Data Manipulation Language, DML To change the values in one or

Data Manipulation Language, DML

To change the values in one or more columns

of the table used UPDATE statement.
UPDATE table_name SET Field = new_Value
WHERE selection condition;
Слайд 19

Data Manipulation Language, DML Example: UPDATE Customers SET ContactName=‘Student’, City=‘Taraz’ WHERE

Data Manipulation Language, DML

Example:
UPDATE Customers SET ContactName=‘Student’, City=‘Taraz’ WHERE CustomerID=2;

After UPDATE statements,

records fields CustomerName, City in Customers table has changed
Слайд 20

Activity Go to this link http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all Update London to Berlin for

Activity

Go to this link
http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
Update London to Berlin for CustomerID =

4
Perform the task. Show your answers for teacher
Слайд 21

Data Manipulation Language, DML To add records to the table, use

Data Manipulation Language, DML

To add records to the table, use the INSERT

statement
INSERT INTO table_name (field1, field2, field3, ...)
VALUES (value1, value2, value3, ...);
Слайд 22

Data Manipulation Language, DML: Example: INSERT INTO Customers (CustomerName, ContactName, Address,

Data Manipulation Language, DML:

Example:
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)

VALUES (‘Student', ‘Anuar Samatov', ‘Satpayev 2', ‘Taraz', ‘000000', 'Kazakhstan');

After the INSERT INTO proposals at the end of the table create a new record with the given values.

Слайд 23

Activity Go to this link http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all INSERT VALUES ('Bala', 'Askar Nagay', 'Abai 1', 'Taraz', '200000', 'Kazakhstan');

Activity

Go to this link
http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
INSERT VALUES ('Bala', 'Askar Nagay', 'Abai 1',

'Taraz', '200000', 'Kazakhstan');
Слайд 24

Data Manipulation Language, DML: To delete rows from a table, use

Data Manipulation Language, DML:

To delete rows from a table, use a DELETE

statement
DELETE FROM table-name
WHERE selection condition
Слайд 25

Data Manipulation Language, DML Example: DELETE FROM Customers WHERE CustomerID=3; After

Data Manipulation Language, DML

Example:
DELETE FROM Customers WHERE CustomerID=3;

After the proposal DELETE FROM,

the third record with values completely delete.
Слайд 26

Activity Go to this link http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all Delete row where CustomerID=12 Perform

Activity

Go to this link
http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
Delete row where CustomerID=12
Perform the task.

Show your answers for teacher
Слайд 27

Practical work Table: actor_info

Practical work

Table: actor_info

Слайд 28

INSERT Query INSERT INTO actor_info VALUES (1, ’Leonardo’ , ’DiCaprio’ ,35),

INSERT Query

INSERT INTO actor_info VALUES
(1, ’Leonardo’ , ’DiCaprio’ ,35),
(2, ’Matt’ ,

’Damon’ ,61),
(3, ’Jack’ , ’Nicholson’ ,75),
(4, ’Mark’ , ’Wahlberg’ ,37),
Слайд 29

SELECT Query SELECT * FROM actor_info;

SELECT Query
SELECT * FROM actor_info;

Слайд 30

SELECT Query SELECT actor_id, total_films FROM actor_info;

SELECT Query
SELECT actor_id, total_films
FROM actor_info;

Слайд 31

UPDATE Query UPDATE actor_info SET total_films = 36 WHERE actor_id = 1;

UPDATE Query

UPDATE actor_info
SET total_films = 36
WHERE actor_id = 1;

Слайд 32

DELETE Query DELETE FROM actor_info WHERE total_films > 70

DELETE Query

DELETE FROM actor_info
WHERE total_films > 70

Слайд 33

DELETE Query DELETE FROM actor_info

DELETE Query

DELETE FROM actor_info

Слайд 34

Did you learn useful information for yourself? Where did you have

Did you learn useful information for yourself?
Where did you have difficulties?
What

would like to explore in the next lesson?