SlideShare a Scribd company logo
1 of 29
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

Similar to Advanced_SQL_Presentation_Template.pptx

CIS 111 STUDY Education Your Life--cis111study
CIS 111 STUDY Education Your Life--cis111studyCIS 111 STUDY Education Your Life--cis111study
CIS 111 STUDY Education Your Life--cis111studythomashard44
 
CIS 111 STUDY Inspiring Innovation--cis111study.com
CIS 111 STUDY Inspiring Innovation--cis111study.comCIS 111 STUDY Inspiring Innovation--cis111study.com
CIS 111 STUDY Inspiring Innovation--cis111study.comKeatonJennings90
 
CIS 111 STUDY Knowledge Specialist--cis111study.com
CIS 111 STUDY Knowledge Specialist--cis111study.comCIS 111 STUDY Knowledge Specialist--cis111study.com
CIS 111 STUDY Knowledge Specialist--cis111study.comchrysanthemu86
 
Access tips access and sql part 1 setting the sql scene
Access tips  access and sql part 1  setting the sql sceneAccess tips  access and sql part 1  setting the sql scene
Access tips access and sql part 1 setting the sql scenequest2900
 
Intro to SQL for Beginners
Intro to SQL for BeginnersIntro to SQL for Beginners
Intro to SQL for BeginnersProduct School
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredDanish Mehraj
 
Adeshhazra_DBMS_ca1_bca4thsem.pdf
Adeshhazra_DBMS_ca1_bca4thsem.pdfAdeshhazra_DBMS_ca1_bca4thsem.pdf
Adeshhazra_DBMS_ca1_bca4thsem.pdfDwipayanSaha1
 
Bt0066, database management systems
Bt0066, database management systemsBt0066, database management systems
Bt0066, database management systemssmumbahelp
 
ICT-DBA4-09-0811-Monitor-and-Administer-Database.docx
ICT-DBA4-09-0811-Monitor-and-Administer-Database.docxICT-DBA4-09-0811-Monitor-and-Administer-Database.docx
ICT-DBA4-09-0811-Monitor-and-Administer-Database.docxAmanGunner
 
Dbms interview questions
Dbms interview questionsDbms interview questions
Dbms interview questionsambika93
 
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxCharles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxchristinemaritza
 
Using SQL for Data Analysis_ Querying and Manipulating Databases.pdf
Using SQL for Data Analysis_ Querying and Manipulating Databases.pdfUsing SQL for Data Analysis_ Querying and Manipulating Databases.pdf
Using SQL for Data Analysis_ Querying and Manipulating Databases.pdfUncodemy
 
Database solution by m.moses wills
Database solution by m.moses willsDatabase solution by m.moses wills
Database solution by m.moses willsMoses Mwebaze
 
Database solution by m.moses wills
Database solution by m.moses willsDatabase solution by m.moses wills
Database solution by m.moses willsMoses Mwebaze
 
Sql server 2012 tutorials writing transact-sql statements
Sql server 2012 tutorials   writing transact-sql statementsSql server 2012 tutorials   writing transact-sql statements
Sql server 2012 tutorials writing transact-sql statementsSteve Xu
 

Similar to Advanced_SQL_Presentation_Template.pptx (20)

CIS 111 STUDY Education Your Life--cis111study
CIS 111 STUDY Education Your Life--cis111studyCIS 111 STUDY Education Your Life--cis111study
CIS 111 STUDY Education Your Life--cis111study
 
CIS 111 STUDY Inspiring Innovation--cis111study.com
CIS 111 STUDY Inspiring Innovation--cis111study.comCIS 111 STUDY Inspiring Innovation--cis111study.com
CIS 111 STUDY Inspiring Innovation--cis111study.com
 
CIS 111 STUDY Knowledge Specialist--cis111study.com
CIS 111 STUDY Knowledge Specialist--cis111study.comCIS 111 STUDY Knowledge Specialist--cis111study.com
CIS 111 STUDY Knowledge Specialist--cis111study.com
 
MSSQL_Book.pdf
MSSQL_Book.pdfMSSQL_Book.pdf
MSSQL_Book.pdf
 
Access tips access and sql part 1 setting the sql scene
Access tips  access and sql part 1  setting the sql sceneAccess tips  access and sql part 1  setting the sql scene
Access tips access and sql part 1 setting the sql scene
 
Intro to SQL for Beginners
Intro to SQL for BeginnersIntro to SQL for Beginners
Intro to SQL for Beginners
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
Adeshhazra_DBMS_ca1_bca4thsem.pdf
Adeshhazra_DBMS_ca1_bca4thsem.pdfAdeshhazra_DBMS_ca1_bca4thsem.pdf
Adeshhazra_DBMS_ca1_bca4thsem.pdf
 
Bt0066, database management systems
Bt0066, database management systemsBt0066, database management systems
Bt0066, database management systems
 
Module08
Module08Module08
Module08
 
Module08
Module08Module08
Module08
 
ICT-DBA4-09-0811-Monitor-and-Administer-Database.docx
ICT-DBA4-09-0811-Monitor-and-Administer-Database.docxICT-DBA4-09-0811-Monitor-and-Administer-Database.docx
ICT-DBA4-09-0811-Monitor-and-Administer-Database.docx
 
Dbms interview questions
Dbms interview questionsDbms interview questions
Dbms interview questions
 
Database testing
Database testingDatabase testing
Database testing
 
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxCharles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
 
Using SQL for Data Analysis_ Querying and Manipulating Databases.pdf
Using SQL for Data Analysis_ Querying and Manipulating Databases.pdfUsing SQL for Data Analysis_ Querying and Manipulating Databases.pdf
Using SQL for Data Analysis_ Querying and Manipulating Databases.pdf
 
Sppt chap007
Sppt chap007Sppt chap007
Sppt chap007
 
Database solution by m.moses wills
Database solution by m.moses willsDatabase solution by m.moses wills
Database solution by m.moses wills
 
Database solution by m.moses wills
Database solution by m.moses willsDatabase solution by m.moses wills
Database solution by m.moses wills
 
Sql server 2012 tutorials writing transact-sql statements
Sql server 2012 tutorials   writing transact-sql statementsSql server 2012 tutorials   writing transact-sql statements
Sql server 2012 tutorials writing transact-sql statements
 

Recently uploaded

Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...shivangimorya083
 
Data Warehouse , Data Cube Computation
Data Warehouse   , Data Cube ComputationData Warehouse   , Data Cube Computation
Data Warehouse , Data Cube Computationsit20ad004
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...Suhani Kapoor
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxFurkanTasci3
 
Spark3's new memory model/management
Spark3's new memory model/managementSpark3's new memory model/management
Spark3's new memory model/managementakshesh doshi
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 

Recently uploaded (20)

Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
 
Data Warehouse , Data Cube Computation
Data Warehouse   , Data Cube ComputationData Warehouse   , Data Cube Computation
Data Warehouse , Data Cube Computation
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptx
 
Spark3's new memory model/management
Spark3's new memory model/managementSpark3's new memory model/management
Spark3's new memory model/management
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 

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