🗊Презентация Data Modeling and Databases Lab 3: Introduction to SQL

Категория: Информатика
Нажмите для полного просмотра!
Data Modeling and Databases Lab 3: Introduction to SQL, слайд №1Data Modeling and Databases Lab 3: Introduction to SQL, слайд №2Data Modeling and Databases Lab 3: Introduction to SQL, слайд №3Data Modeling and Databases Lab 3: Introduction to SQL, слайд №4Data Modeling and Databases Lab 3: Introduction to SQL, слайд №5Data Modeling and Databases Lab 3: Introduction to SQL, слайд №6Data Modeling and Databases Lab 3: Introduction to SQL, слайд №7Data Modeling and Databases Lab 3: Introduction to SQL, слайд №8Data Modeling and Databases Lab 3: Introduction to SQL, слайд №9Data Modeling and Databases Lab 3: Introduction to SQL, слайд №10Data Modeling and Databases Lab 3: Introduction to SQL, слайд №11Data Modeling and Databases Lab 3: Introduction to SQL, слайд №12Data Modeling and Databases Lab 3: Introduction to SQL, слайд №13Data Modeling and Databases Lab 3: Introduction to SQL, слайд №14Data Modeling and Databases Lab 3: Introduction to SQL, слайд №15Data Modeling and Databases Lab 3: Introduction to SQL, слайд №16Data Modeling and Databases Lab 3: Introduction to SQL, слайд №17Data Modeling and Databases Lab 3: Introduction to SQL, слайд №18Data Modeling and Databases Lab 3: Introduction to SQL, слайд №19Data Modeling and Databases Lab 3: Introduction to SQL, слайд №20Data Modeling and Databases Lab 3: Introduction to SQL, слайд №21Data Modeling and Databases Lab 3: Introduction to SQL, слайд №22Data Modeling and Databases Lab 3: Introduction to SQL, слайд №23

Вы можете ознакомиться и скачать презентацию на тему Data Modeling and Databases Lab 3: Introduction to SQL. Доклад-сообщение содержит 23 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1





Data Modeling and Databases
Lab 3: Introduction to SQL
Bulat Gabbasov, Albina Sayfeeva
Innopolis University
2016
Описание слайда:
Data Modeling and Databases Lab 3: Introduction to SQL Bulat Gabbasov, Albina Sayfeeva Innopolis University 2016

Слайд 2





Basic SQL query structure
Basic SQL query structure consists of SELECT, FROM, WHERE, GROUP BY and ORDER BY clauses.
SELECT [ALL | DISTINCT] expressions
specifies the columns to appear in the result
distinct keyword can be used to eliminate duplicates
FROM from_items
specifies the relations to be used
WHERE condition
filters the tuples
GROUP BY expression
groups rows with the same column values
the HAVING construct can be used to further filter the groups
ORDER BY expression
defines the order of the resulting tuples
Описание слайда:
Basic SQL query structure Basic SQL query structure consists of SELECT, FROM, WHERE, GROUP BY and ORDER BY clauses. SELECT [ALL | DISTINCT] expressions specifies the columns to appear in the result distinct keyword can be used to eliminate duplicates FROM from_items specifies the relations to be used WHERE condition filters the tuples GROUP BY expression groups rows with the same column values the HAVING construct can be used to further filter the groups ORDER BY expression defines the order of the resulting tuples

Слайд 3





Data manipulation
INSERT
Inserts a tuple into the specified table
INSERT INTO tablename (list of columns) 
VALUES (list of values), ...
UPDATE
Updates all tuples that match specified condition
UPDATE tablename SET column = newvalue, ... 
WHERE condition
DELETE
Deletes all tuples that match specified condition
DELETE FROM tablename WHERE condition
Описание слайда:
Data manipulation INSERT Inserts a tuple into the specified table INSERT INTO tablename (list of columns) VALUES (list of values), ... UPDATE Updates all tuples that match specified condition UPDATE tablename SET column = newvalue, ... WHERE condition DELETE Deletes all tuples that match specified condition DELETE FROM tablename WHERE condition

Слайд 4





Inserting 
Create a new student Harvey Specter:
INSERT INTO students 
(student_id, firstname, lastname) VALUES 
(1, 'Harvey', 'Specter')
Описание слайда:
Inserting Create a new student Harvey Specter: INSERT INTO students (student_id, firstname, lastname) VALUES (1, 'Harvey', 'Specter')

Слайд 5





Updating
Change firstname of all students having student_id = 1 to ‘John’:
UPDATE students 
SET firstname = 'John' 
WHERE student_id = 1
Описание слайда:
Updating Change firstname of all students having student_id = 1 to ‘John’: UPDATE students SET firstname = 'John' WHERE student_id = 1

Слайд 6





Deleting
Delete student having student_id = 1 from table students:
DELETE FROM students WHERE student_id = 1
Описание слайда:
Deleting Delete student having student_id = 1 from table students: DELETE FROM students WHERE student_id = 1

Слайд 7





Expressions
Calculate expression 1 + 1 and name it as two:
SELECT 1 + 1 AS two
Описание слайда:
Expressions Calculate expression 1 + 1 and name it as two: SELECT 1 + 1 AS two

Слайд 8





Tables
Return list of all students:
SELECT * FROM students
Описание слайда:
Tables Return list of all students: SELECT * FROM students

Слайд 9





Exercise
Insert a new department named ‘Machine Learning’ and leaded with professor identified by professor_id = 1
INSERT INTO departments 
VALUES (4, 'Machine Learning', 1)
Change name of the newly created department to ’Advanced Machine Learning’
UPDATE departments 
SET name = 'Advanced Machine Learning' 
WHERE name = 'Machine Learning’
Delete new newly created department
DELETE FROM departments 
WHERE name = 'Advanced Machine Learning'
Описание слайда:
Exercise Insert a new department named ‘Machine Learning’ and leaded with professor identified by professor_id = 1 INSERT INTO departments VALUES (4, 'Machine Learning', 1) Change name of the newly created department to ’Advanced Machine Learning’ UPDATE departments SET name = 'Advanced Machine Learning' WHERE name = 'Machine Learning’ Delete new newly created department DELETE FROM departments WHERE name = 'Advanced Machine Learning'

Слайд 10





Exercise
Find the address of the student with first name "Donna”
SELECT address FROM students 
WHERE firstname = 'Donna'
Описание слайда:
Exercise Find the address of the student with first name "Donna” SELECT address FROM students WHERE firstname = 'Donna'

Слайд 11





Exercise
Find all students who are either male or are from Kazan
SELECT * FROM students 
WHERE gender = 'm' or address = 'Kazan'
Описание слайда:
Exercise Find all students who are either male or are from Kazan SELECT * FROM students WHERE gender = 'm' or address = 'Kazan'

Слайд 12





Exercise
Find all courses that worth at least 9 credits and are given by MSIT department
Hint: department_id for MSIT-SE is 1.
SELECT * FROM courses 
WHERE credits >= 9 AND department_id = 1
Описание слайда:
Exercise Find all courses that worth at least 9 credits and are given by MSIT department Hint: department_id for MSIT-SE is 1. SELECT * FROM courses WHERE credits >= 9 AND department_id = 1

Слайд 13





Exercise
Find names and salaries of professors who earn less than 15 000
SELECT firstname, lastname, salary 
FROM professors WHERE salary < 15000
Описание слайда:
Exercise Find names and salaries of professors who earn less than 15 000 SELECT firstname, lastname, salary FROM professors WHERE salary < 15000

Слайд 14





Exercise
Find students born earlier than 1980
SELECT * FROM students 
WHERE birthdate < '1980-01-01'
Описание слайда:
Exercise Find students born earlier than 1980 SELECT * FROM students WHERE birthdate < '1980-01-01'

Слайд 15





Exercise
List full names of all students living in Moscow
Hint: concatenation operator a || b
SELECT 
  firstname || ‘ ‘ || lastname AS fullname
, address
FROM Students WHERE address = ‘Moscow’
Описание слайда:
Exercise List full names of all students living in Moscow Hint: concatenation operator a || b SELECT firstname || ‘ ‘ || lastname AS fullname , address FROM Students WHERE address = ‘Moscow’

Слайд 16





Exercise
Find students who's address contains "k" letter 
SELECT * FROM students WHERE address LIKE '%k%'
Описание слайда:
Exercise Find students who's address contains "k" letter SELECT * FROM students WHERE address LIKE '%k%'

Слайд 17





Exercise
Find students who's lastname consists of 7 letters and ends with "n”
SELECT * FROM students 
WHERE lastname LIKE '______n'
Описание слайда:
Exercise Find students who's lastname consists of 7 letters and ends with "n” SELECT * FROM students WHERE lastname LIKE '______n'

Слайд 18





Exercise
Order and display students by lastname (alphabetically)
SELECT * FROM students 
ORDER BY lastname
Описание слайда:
Exercise Order and display students by lastname (alphabetically) SELECT * FROM students ORDER BY lastname

Слайд 19





Exercise
Order and display students by lastname and then by firstname  (alphabetically)
SELECT * FROM students 
ORDER BY lastname, firstname
Описание слайда:
Exercise Order and display students by lastname and then by firstname (alphabetically) SELECT * FROM students ORDER BY lastname, firstname

Слайд 20





Exercise
Order by login : first letter of firstname + full lastname in descending order
Hint: use SUBSTRING(column from begin for length)
SELECT SUBSTRING(firstname from 1 for 1) 
       || lastname AS login, * 
FROM students 
ORDER BY 1 DESC
Описание слайда:
Exercise Order by login : first letter of firstname + full lastname in descending order Hint: use SUBSTRING(column from begin for length) SELECT SUBSTRING(firstname from 1 for 1) || lastname AS login, * FROM students ORDER BY 1 DESC

Слайд 21





Exercise
Find names of male students who got more than 50 for any course
Описание слайда:
Exercise Find names of male students who got more than 50 for any course

Слайд 22





Exercise
Which students are enrolled in DMD course?
Описание слайда:
Exercise Which students are enrolled in DMD course?

Слайд 23





QA?
Описание слайда:
QA?



Похожие презентации
Mypresentation.ru
Загрузить презентацию