Advanced SQL – Session 1
#LifeKoKaroLift
26-02-2023
1
Edit Master text styles
Edit Master text styles
26-02-2023 2
Lecture On : Advanced
SQL
Instructor : Edwin R. Das
26-02-2023 3
Today’s Agenda
What is an RDBMS? Review of key concepts
Using MySQL Workbench
Cascading and referential integrity
Types of keys – Primary, Unique and Foreign keys
Data Science Certification
26-02-2023
What is a Relational Database?
• A collection of inter-related data.
• It is organised in the form of schema, tables and views.
• It is efficient to retrieve, insert and delete data from a database.
4
Databases – An Overview
What is a RDBMS?
• It is a software that is used to manage a database.
• It helps in the following:
• Defining the way in which data is organised
• Updating and retrieving data
• User access management
SQL Statements
Structured Query Language (SQL):
• It is a way to communicate with database.
• All operations on a database are performed through SQL statements.
• Queries to the database can be expressed using logical statements.
• SQL statements allows one to express complex queries using a very simple language.
• It is very easy to read and comprehend for humans.
26-02-2023 5
Your mentor will share career advice and can help expand your professional network.
6
SQL Statements
26-02-2023 6
Data Definition Language (DDL) Statements:
ALTER, CREATE, DROP, RENAME, TRUNCATE
Data Manipulation Language (DML) Statements:
SELECT, UPDATE, DELETE, ALTER, INSERT
Data Control Language (DCL) Statements:
GRANT, REVOKE
Transaction Control Language (TCL) Statements:
COMMIT, ROLLBACK, SAVEPOINT
Inner Join
Only common data from both tables
7
Joins
26-02-2023
Outer Join
All data from both tables
Left Outer Join
All rows from left table, only matching from right
Right Outer Join
All rows from right table, only matching ones from left
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
8
Poll 1
26-02-2023 11
Which of the following statements is used to fetch data
from database table?
1. INSERT
2. UPDATE
3. SELECT
4. FETCH
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
9
Poll 1(Answer)
26-02-2023 11
Which of the following statements is used to fetch data
from database table?
1. INSERT
2. UPDATE
3. SELECT
4. FETCH
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
10
Poll 2
26-02-2023 11
What is the main difference between UPDATE and INSERT?
1. UPDATE and INSERT work in the same way
2. UPDATE modifies existing records while INSERT adds
new records
3. UPDATE adds new columns while INSERT adds new
rows
4. None of the above
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
11
Poll 2(Answer)
26-02-2023 11
What is the main difference between UPDATE and INSERT?
1. UPDATE and INSERT work in the same way
2. UPDATE modifies existing records while INSERT adds
new records
3. UPDATE adds new columns while INSERT adds new
rows
4. None of the above
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
12
Poll 3
26-02-2023 11
What is the difference between DROP and TRUNCATE?
1. DROP deletes the table but TRUNCATE is not a valid SQL
statement
2. TRUNCATE deletes table while DROP only deletes
records but keeps table structure
3. DROP deletes table while TRUNCATE only deletes
records but keeps table structure
4. None of the above
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
13
Poll 3(Answer)
26-02-2023 11
What is the difference between DROP and TRUNCATE?
1. DROP deletes the table but TRUNCATE is not a valid SQL
statement
2. TRUNCATE deletes table while DROP only deletes
records but keeps table structure
3. DROP deletes table while TRUNCATE only deletes
records but keeps table structure
4. None of the above
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
14
Poll 4
26-02-2023 11
If Table A has 40 rows and Table B has 20 rows and both the
tables are combined using a CROSS join, how many rows
will the result set have:
1. 40
2. 800
3. 20
4. 400
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
15
Poll 4(Answer)
26-02-2023 11
If Table A has 40 rows and Table B has 20 rows and both the
tables are combined using a CROSS join, how many rows
will the result set have:
1. 40
2. 800
3. 20
4. 400
26-02-2023 16
• MySQL is a relational database management system.
• MySQL workbench is a visual database design and modelling access tool.
• It is useful for creating a visual model of a database which can be easily
translated into a database.
• It has a in built sql editor which can be used to create and query MySQL
server databases.
• The data can be exported easily to commonly used formats.
• Using tabs, one can work on multiple databases at a time.
• It is also an administration tool which can be used for user access control,
backup and restore and configuring the MySQL server.
MySQL Workbench
26-02-2023 17
MySQL Workbench
• This the first screen
you see when
opening MySQL
Workbench.
• The first step would
be to create a
connection by
clicking on the ‘+’
sign next to MySQL
Connections.
26-02-2023 18
MySQL Workbench
• Enter the name of
the connection in
the ‘Connection
Name’ field.
• Use the default
values for the rest
of the fields.
Enter the name for
the connection here.
26-02-2023 19
MySQL Workbench
Existing
Databases
Editor
Output
26-02-2023 20
Constraints are rules or conditions for the data in a table. Constraints may be at the column level or
table level. The following are common constraints in MySQL.
NOT NULL - Ensures that a column cannot have null values
UNIQUE - Ensures that all values in a column are distinct
PRIMARY KEY - A column that uniquely identifies each row in a table
FOREIGN KEY - A column that references the primary key of another table
CHECK - Imposes specific conditions on a column
DEFAULT - Sets a default value for a column if unspecified
INDEX - A column can be set as an index. Used to speed up data retrieval
Constraints
26-02-2023 21
Keys are used to maintain referential integrity in a database. Keys are also indexes for a table in
MySQL. Indexes speed up data retrieval from database tables.
PRIMARY KEY – A unique identifier for each row in a table. Eg: Student Id, Employee Code, etc. It
can also be a combination of multiple columns. In this case it is also know as a composite key.
UNIQUE KEY – A column which allows only unique values. Eg: Phone number, email id, etc.
FOREIGN KEY - A column that references the primary key of another table. Primarily used to
maintain referential integrity
KEYS
26-02-2023 22
• Foreign keys are not just used to refer to the primary key of another table.
• It is also used to control delete and update actions on the table which contains the primary
key.
• This helps in maintaining referential integrity.
• When implemented, any changes made to the table containing the primary key will also
correspondingly DELETE or UPDATE the same on any foreign keys referencing that table.
Cascading
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
23
Poll 5
26-02-2023 11
Which of following are true?
1. Primary keys cannot have null values
2. Foreign Keys can have duplicate values
3. Unique keys cannot have null values
4. A foreign key cannot be composite
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
24
Poll 5(Answer)
26-02-2023 11
Which of following are true?
1. Primary keys cannot have null values
2. Foreign Keys can have duplicate values
3. Unique keys cannot have null values
4. A foreign key cannot be composite
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
25
Poll 6
26-02-2023 11
Which of the following constraints provides a value in column even if no value
is entered by the user?
1. CHECK
2. DEFAULT
3. UNIQUE
4. NOT NULL
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
26
Poll 7
26-02-2023 11
Cascading delete implies that:
1. Deleting a row in the parent table will also delete the corresponding row in the
child table
2. Deleting a row in the child table will also delete the corresponding row in the
parent table
3. One cannot delete a row in the child table without deleting the corresponding
row in the parent table
4. None of the above
Click to add Title
26-02-2023 Footer
Practice in teams of 4 students
Industry expert mentoring to learn better
Get personalised feedback for improvements
27
Poll 7
26-02-2023 11
Cascading delete implies that:
1. Deleting a row in the parent table will also delete the corresponding row in the
child table
2. Deleting a row in the child table will also delete the corresponding row in the
parent table
3. One cannot delete a row in the child table without deleting the corresponding
row in the parent table
4. None of the above
26-02-2023 28
Key Takeaway
1. A relational database is a collection of inter related data.
2. MySQL is an RDBMS which is used to manage a database.
3. MySQL workbench is a software that can be used to design databases
visually.
4. Constraints impose restrictions on the data that can be entered into a
database.
5. Keys are indexes which can be used speed up data retrieval and
maintain referential integrity.
6. Cascading is a type of constraint that helps maintain referential
integrity with foreign keys.
Data Science Certification
26-02-2023 29
Next Class
SQL Functions
Data Science Certification

More Related Content

PPTX
Database Overview
PPTX
PDF
Chapter8 my sql revision tour
PPT
UNIT 2 Structural Query Language UPDATED
PPTX
Microsoft SQL 000000000000000000001.pptx
PPTX
lec02-data-models-sql-basics.pptx
PPT
MY SQL
PPTX
SQL.pptx for the begineers and good know
Database Overview
Chapter8 my sql revision tour
UNIT 2 Structural Query Language UPDATED
Microsoft SQL 000000000000000000001.pptx
lec02-data-models-sql-basics.pptx
MY SQL
SQL.pptx for the begineers and good know

Similar to Advanced_SQL_Presentation_Template.pptx (20)

PDF
SQL for data scientist And data analysist Advanced
PPT
Mysql 120831075600-phpapp01
PDF
Interview Questions.pdf
PPTX
session_2_sqlpptxfhfhfhfdhfdhkkfdhfdhfdh
PPTX
Lesson 2_Working_with_Tables_and_SQL_Commands.pptx
PPTX
PPT SQL CLASS.pptx
PDF
Session 1 - Databases-JUNE 2023.pdf
PDF
Intruduction to SQL.Structured Query Language(SQL}
PPT
Introduction to structured query language (sql)
PPT
PPT
Introduction to Structured Query Language (SQL).ppt
PPT
Introduction to Structured Query Language (SQL) (1).ppt
PPTX
Relational Database Management System
PPTX
Introduction to structured query language (sql) (1)
PDF
Relational database management system
PPTX
Creating database using sql commands
PPTX
Getting Started with MySQL I
PPTX
MS SQL - Database Programming Concepts by RSolutions
PPTX
sql.pptx
PPTX
SQL Sort Notes
SQL for data scientist And data analysist Advanced
Mysql 120831075600-phpapp01
Interview Questions.pdf
session_2_sqlpptxfhfhfhfdhfdhkkfdhfdhfdh
Lesson 2_Working_with_Tables_and_SQL_Commands.pptx
PPT SQL CLASS.pptx
Session 1 - Databases-JUNE 2023.pdf
Intruduction to SQL.Structured Query Language(SQL}
Introduction to structured query language (sql)
Introduction to Structured Query Language (SQL).ppt
Introduction to Structured Query Language (SQL) (1).ppt
Relational Database Management System
Introduction to structured query language (sql) (1)
Relational database management system
Creating database using sql commands
Getting Started with MySQL I
MS SQL - Database Programming Concepts by RSolutions
sql.pptx
SQL Sort Notes
Ad

Recently uploaded (20)

PDF
Introduction to Data Science and Data Analysis
PPTX
sac 451hinhgsgshssjsjsjheegdggeegegdggddgeg.pptx
PPTX
DS-40-Pre-Engagement and Kickoff deck - v8.0.pptx
PPTX
modul_python (1).pptx for professional and student
PPTX
CYBER SECURITY the Next Warefare Tactics
PDF
Microsoft Core Cloud Services powerpoint
PDF
OneRead_20250728_1808.pdfhdhddhshahwhwwjjaaja
PPTX
Pilar Kemerdekaan dan Identi Bangsa.pptx
PPT
Predictive modeling basics in data cleaning process
PPTX
retention in jsjsksksksnbsndjddjdnFPD.pptx
PPTX
Phase1_final PPTuwhefoegfohwfoiehfoegg.pptx
PPTX
SAP 2 completion done . PRESENTATION.pptx
PPTX
Steganography Project Steganography Project .pptx
PPT
lectureusjsjdhdsjjshdshshddhdhddhhd1.ppt
PPT
DU, AIS, Big Data and Data Analytics.ppt
PDF
Global Data and Analytics Market Outlook Report
PDF
Votre score augmente si vous choisissez une catégorie et que vous rédigez une...
PPTX
Introduction to Inferential Statistics.pptx
PDF
Transcultural that can help you someday.
PPTX
SET 1 Compulsory MNH machine learning intro
Introduction to Data Science and Data Analysis
sac 451hinhgsgshssjsjsjheegdggeegegdggddgeg.pptx
DS-40-Pre-Engagement and Kickoff deck - v8.0.pptx
modul_python (1).pptx for professional and student
CYBER SECURITY the Next Warefare Tactics
Microsoft Core Cloud Services powerpoint
OneRead_20250728_1808.pdfhdhddhshahwhwwjjaaja
Pilar Kemerdekaan dan Identi Bangsa.pptx
Predictive modeling basics in data cleaning process
retention in jsjsksksksnbsndjddjdnFPD.pptx
Phase1_final PPTuwhefoegfohwfoiehfoegg.pptx
SAP 2 completion done . PRESENTATION.pptx
Steganography Project Steganography Project .pptx
lectureusjsjdhdsjjshdshshddhdhddhhd1.ppt
DU, AIS, Big Data and Data Analytics.ppt
Global Data and Analytics Market Outlook Report
Votre score augmente si vous choisissez une catégorie et que vous rédigez une...
Introduction to Inferential Statistics.pptx
Transcultural that can help you someday.
SET 1 Compulsory MNH machine learning intro
Ad

Advanced_SQL_Presentation_Template.pptx

  • 1. Advanced SQL – Session 1 #LifeKoKaroLift 26-02-2023 1
  • 2. Edit Master text styles Edit Master text styles 26-02-2023 2 Lecture On : Advanced SQL Instructor : Edwin R. Das
  • 3. 26-02-2023 3 Today’s Agenda What is an RDBMS? Review of key concepts Using MySQL Workbench Cascading and referential integrity Types of keys – Primary, Unique and Foreign keys Data Science Certification
  • 4. 26-02-2023 What is a Relational Database? • A collection of inter-related data. • It is organised in the form of schema, tables and views. • It is efficient to retrieve, insert and delete data from a database. 4 Databases – An Overview What is a RDBMS? • It is a software that is used to manage a database. • It helps in the following: • Defining the way in which data is organised • Updating and retrieving data • User access management
  • 5. SQL Statements Structured Query Language (SQL): • It is a way to communicate with database. • All operations on a database are performed through SQL statements. • Queries to the database can be expressed using logical statements. • SQL statements allows one to express complex queries using a very simple language. • It is very easy to read and comprehend for humans. 26-02-2023 5
  • 6. Your mentor will share career advice and can help expand your professional network. 6 SQL Statements 26-02-2023 6 Data Definition Language (DDL) Statements: ALTER, CREATE, DROP, RENAME, TRUNCATE Data Manipulation Language (DML) Statements: SELECT, UPDATE, DELETE, ALTER, INSERT Data Control Language (DCL) Statements: GRANT, REVOKE Transaction Control Language (TCL) Statements: COMMIT, ROLLBACK, SAVEPOINT
  • 7. Inner Join Only common data from both tables 7 Joins 26-02-2023 Outer Join All data from both tables Left Outer Join All rows from left table, only matching from right Right Outer Join All rows from right table, only matching ones from left
  • 8. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 8 Poll 1 26-02-2023 11 Which of the following statements is used to fetch data from database table? 1. INSERT 2. UPDATE 3. SELECT 4. FETCH
  • 9. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 9 Poll 1(Answer) 26-02-2023 11 Which of the following statements is used to fetch data from database table? 1. INSERT 2. UPDATE 3. SELECT 4. FETCH
  • 10. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 10 Poll 2 26-02-2023 11 What is the main difference between UPDATE and INSERT? 1. UPDATE and INSERT work in the same way 2. UPDATE modifies existing records while INSERT adds new records 3. UPDATE adds new columns while INSERT adds new rows 4. None of the above
  • 11. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 11 Poll 2(Answer) 26-02-2023 11 What is the main difference between UPDATE and INSERT? 1. UPDATE and INSERT work in the same way 2. UPDATE modifies existing records while INSERT adds new records 3. UPDATE adds new columns while INSERT adds new rows 4. None of the above
  • 12. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 12 Poll 3 26-02-2023 11 What is the difference between DROP and TRUNCATE? 1. DROP deletes the table but TRUNCATE is not a valid SQL statement 2. TRUNCATE deletes table while DROP only deletes records but keeps table structure 3. DROP deletes table while TRUNCATE only deletes records but keeps table structure 4. None of the above
  • 13. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 13 Poll 3(Answer) 26-02-2023 11 What is the difference between DROP and TRUNCATE? 1. DROP deletes the table but TRUNCATE is not a valid SQL statement 2. TRUNCATE deletes table while DROP only deletes records but keeps table structure 3. DROP deletes table while TRUNCATE only deletes records but keeps table structure 4. None of the above
  • 14. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 14 Poll 4 26-02-2023 11 If Table A has 40 rows and Table B has 20 rows and both the tables are combined using a CROSS join, how many rows will the result set have: 1. 40 2. 800 3. 20 4. 400
  • 15. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 15 Poll 4(Answer) 26-02-2023 11 If Table A has 40 rows and Table B has 20 rows and both the tables are combined using a CROSS join, how many rows will the result set have: 1. 40 2. 800 3. 20 4. 400
  • 16. 26-02-2023 16 • MySQL is a relational database management system. • MySQL workbench is a visual database design and modelling access tool. • It is useful for creating a visual model of a database which can be easily translated into a database. • It has a in built sql editor which can be used to create and query MySQL server databases. • The data can be exported easily to commonly used formats. • Using tabs, one can work on multiple databases at a time. • It is also an administration tool which can be used for user access control, backup and restore and configuring the MySQL server. MySQL Workbench
  • 17. 26-02-2023 17 MySQL Workbench • This the first screen you see when opening MySQL Workbench. • The first step would be to create a connection by clicking on the ‘+’ sign next to MySQL Connections.
  • 18. 26-02-2023 18 MySQL Workbench • Enter the name of the connection in the ‘Connection Name’ field. • Use the default values for the rest of the fields. Enter the name for the connection here.
  • 20. 26-02-2023 20 Constraints are rules or conditions for the data in a table. Constraints may be at the column level or table level. The following are common constraints in MySQL. NOT NULL - Ensures that a column cannot have null values UNIQUE - Ensures that all values in a column are distinct PRIMARY KEY - A column that uniquely identifies each row in a table FOREIGN KEY - A column that references the primary key of another table CHECK - Imposes specific conditions on a column DEFAULT - Sets a default value for a column if unspecified INDEX - A column can be set as an index. Used to speed up data retrieval Constraints
  • 21. 26-02-2023 21 Keys are used to maintain referential integrity in a database. Keys are also indexes for a table in MySQL. Indexes speed up data retrieval from database tables. PRIMARY KEY – A unique identifier for each row in a table. Eg: Student Id, Employee Code, etc. It can also be a combination of multiple columns. In this case it is also know as a composite key. UNIQUE KEY – A column which allows only unique values. Eg: Phone number, email id, etc. FOREIGN KEY - A column that references the primary key of another table. Primarily used to maintain referential integrity KEYS
  • 22. 26-02-2023 22 • Foreign keys are not just used to refer to the primary key of another table. • It is also used to control delete and update actions on the table which contains the primary key. • This helps in maintaining referential integrity. • When implemented, any changes made to the table containing the primary key will also correspondingly DELETE or UPDATE the same on any foreign keys referencing that table. Cascading
  • 23. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 23 Poll 5 26-02-2023 11 Which of following are true? 1. Primary keys cannot have null values 2. Foreign Keys can have duplicate values 3. Unique keys cannot have null values 4. A foreign key cannot be composite
  • 24. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 24 Poll 5(Answer) 26-02-2023 11 Which of following are true? 1. Primary keys cannot have null values 2. Foreign Keys can have duplicate values 3. Unique keys cannot have null values 4. A foreign key cannot be composite
  • 25. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 25 Poll 6 26-02-2023 11 Which of the following constraints provides a value in column even if no value is entered by the user? 1. CHECK 2. DEFAULT 3. UNIQUE 4. NOT NULL
  • 26. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 26 Poll 7 26-02-2023 11 Cascading delete implies that: 1. Deleting a row in the parent table will also delete the corresponding row in the child table 2. Deleting a row in the child table will also delete the corresponding row in the parent table 3. One cannot delete a row in the child table without deleting the corresponding row in the parent table 4. None of the above
  • 27. Click to add Title 26-02-2023 Footer Practice in teams of 4 students Industry expert mentoring to learn better Get personalised feedback for improvements 27 Poll 7 26-02-2023 11 Cascading delete implies that: 1. Deleting a row in the parent table will also delete the corresponding row in the child table 2. Deleting a row in the child table will also delete the corresponding row in the parent table 3. One cannot delete a row in the child table without deleting the corresponding row in the parent table 4. None of the above
  • 28. 26-02-2023 28 Key Takeaway 1. A relational database is a collection of inter related data. 2. MySQL is an RDBMS which is used to manage a database. 3. MySQL workbench is a software that can be used to design databases visually. 4. Constraints impose restrictions on the data that can be entered into a database. 5. Keys are indexes which can be used speed up data retrieval and maintain referential integrity. 6. Cascading is a type of constraint that helps maintain referential integrity with foreign keys. Data Science Certification
  • 29. 26-02-2023 29 Next Class SQL Functions Data Science Certification