Complete SQL
Course
Beginners to Advance
level
by Thoufiq Mohammed (techTFQ)
on Lighthall.co
Welcom
e!
RECORDINGS: Each session will be recorded, and recording will be available within
24hrs in Lighthall under class page.
NOTES: All datasets, scripts, SQL queries, PPT etc will be attached to the class page &
also shared in telegram group.
FORMAT: We start from scratch, and I explain each concept and solve SQL queries
covering each concept.
EXPECTATIONS: Feel free to stop me and ask questions and request for repetition if
something is not clear.
GROUP: You can also post questions in telegram group. Feel free to use the telegram
group for internal discussions related to the course.
ASSIGNMENTS: Assignments will be given in some of the sessions.
Pre-
Requisit • Install a RDBMS such as
e PostgreSQL, MySQL, Oracle,
Microsoft SQL Server etc.
• Install an IDE such as
PgAdmin, MySQL Workbench,
SQL Developer, Microsoft SQL
Server Management Studio etc.
Whom is this SQL course
for?
• Software
Engineer
• Data Engineer
• Data Analyst
• Data Scientist
• SQL Developer
• Business Analyst
• Quality Analyst
• Etc.
Why are you learning
SQL?
Basic
terminolo • Data
• Database (Relational Database)
gies • RDBMS
• SQL
• Table
• Column
• Rows / Record
“Let’s keep the class
interactive”
Ask questions!!!
Data
• Anything & Everything can be considered as data.
• Any information or fact can be considered as data.
• For an insurance company, details related to its
employees, customers, their products or even
their address can be data.
• Data can be in any form such as a text message or
an image or a video or a document or single
character itself.
Databas
e • Container which is filled with data or information
which is electronically stored in a computer system.
• Data in any form can be stored in the database.
• All companies use some sort of database to store
their data.
• Purpose of storing data in the database is:
Easily Accessed
Modified
Protected
Analyzed
RDBMS
vs
Databas
e
SQL
• Structured Query Language (SQL). Also referred to as
“SEQUEL”
• SQL is a programming language used to interact with
Relational Database Management System.
• SQL is primarily used in RDBMS.
• All major RDBMS like Oracle, MySQL, MSSQL, PostgreSQL
etc use SQL.
• Using SQL, you can:
Read data from a RDBMS
Write data into a RDBMS
Create, modify or delete database
Analyze data
Build reports
How • In RDBMS, data is stored in
data is multiple tables.
stored in • Each table can have a set of
rows and columns.
RDBMS • Different tables will be related to
each other through certain
columns forming relationship
between these tables.
Sample RDBMS table data
MySQL
Oracle Is SQL different across
these different
PostgreSQL
RDBMS ?
MSSQL
DDL
Comman • Data Definition Language
• Used to define the structure of a
ds database object such as Table, Views,
Procedure, Function etc.
• Commands include:
CREATE
ALTER
DROP
TRUNCATE
Data Types:
• INT
• VARCHAR
• DATE
• FLOAT
• BOOLEAN
Constrai
nts
• CHECK constraint allows you to control the values that can be inserted into a
column.
• By applying NOT NULL constraint on a column, you make sure that this column
will never have NULL values.
• UNIQUE constraint makes sure that the values in your column are always
unique. It can have NULL values.
• A table can only have one PRIMARY KEY constraint. Primary key constraint can
either be applied to a single column or to a combination of different columns. If a
column (or if a combination of multiple columns) is defined as a primary key,
then this column/columns will always have unique values across all the rows of
that table. Also, primary key column cannot have null values hence primary key
can be treated as a combination of UNIQUE and NOT NULL constraints.
• FOREIGN KEY constraint can be used to form relation between tables. It
basically helps to create a master child relation between 2 tables.
DML
Comman • Data Manipulation Language
• DML commands are used to load,
ds modify and remove data from the
database.
• Commands include:
INSERT
UPDATE
DELETE
MERGE
TCL
Comman
ds • Transaction Control Language
• Includes COMMIT, ROLLBACK and
SAVEPOINT
• Used to save/unsave open transactions in a
database session
DCL
Comman
ds • Data Control Language
• Includes GRANT and REVOKE statements.
• Used to provide or remove permission on a
database object to a database user.
DQL • Data Query Language
• Includes only the SELECT statement
comman • Can be used to read data from one or multiple
tables.
ds • Contains following clauses:
SELECT – list of columns
FROM – list of tables
WHERE – filter conditions and join conditions
• Can also include following clauses:
GROUP BY – Grouping of data based on
specified column(s)
HAVING – Filter condition for the grouped data
Thank you
Questions?