Learn SQL - Day 1 of 10DaysOfSQL
Learn SQL - Day 1 of 10DaysOfSQL
Understanding SQL
Day 1 of #10DaysOfSQL
@talhakhan 1
But first, you need to
understand
THE BASICS
Let’s start with databases
@talhakhan 2
A database is a collection
of RELATED information
@talhakhan 3
Databases can be very large, and
databases touch all aspects of our
lives
Banking: transactions
Airlines: reservations, schedules
Universities: registration, grades
Sales: customers, products, purchases
Online retailers: order tracking, customized
recommendations
Manufacturing: production, inventory, orders,
supply chain
Human resources: employee records, salaries,
tax deductions
@talhakhan 4
DBMS is Database
Management System (DUH!)
@talhakhan 5
CREATE. READ. UPDATE.
DELETE
@talhakhan 6
Relational Databases (SQL) and
Non-Relational Databases
(NoSQL)
@talhakhan 7
A relational database stores and
organizes data into tables linked
together based on common
columns.
Department Table
DepartmentID DepartmentName
1 HR
2 Sales
3 IT
6 Finance
@talhakhan 8
Relational Database
Management System
(RDBMS)
▪ MySQL
▪ Oracle
▪ PostgreSQL
▪ Microsoft SQL Server (MSS)
@talhakhan 9
SQL (structured query
language) is a standardized
language for interacting with
RDBMS
1. DQL
• Data Query Language
• Used to query (request) the database for
information
• Get information that is already there
• SELECT Statements
2. DDL
• Data Definition Language
• Used for defining database schemas
• CREATE, ALTER, DROP, TRUNCATE,
RENAME
@talhakhan 11
A hybrid language with 4
different types of language
combined into one
3. DCL
• Data Control Language
• Used for controlling access to the data in
the database
• User access and permission management
• GRANT, REVOKE
4. DML
• Data Manipulation Language
• Used for inserting, updating, and deleting
data from the database
• INSERT, DELETE, UPDATE
@talhakhan 12
A data type specifies the
kind of data that can be
stored in a column
Some examples:
• INT – Whole Numbers
• DECIMAL(M,N) / FLOAT – Decimal Numbers
• VARCHAR(32) – String of text of length 32
• BLOB – Binary Large Objects, Stores large
data
• DATE – ‘YYYY-MM-DD’
• TIMESTAMP – ‘YYYY’MM’DD HH:MM:SS’
used for recording different events,
transactions, continuous values etc.
@talhakhan 13
Data is logically stored in rows
and columns in a table – but
where is it physically stored?
Stay tuned
@talhakhan 16