Introduction to SQL and Databases
Sabudh Foundation
17/03/2025
Section 1
Understanding Databases and Their Importance
● Introduction to Databases and RDBMS
● Types of Databases: Relational vs Non-Relational
● Basic SQL Syntax and Structure
● Hands-on Practice with SQL Commands
What is a Database?
Database Fundamentals
● A structured collection of data organized for efficient storage, retrieval, and
management
● Solves problems with traditional file systems:
○ Data redundancy and inconsistency
○ Data isolation (scattered across files)
○ Integrity issues
○ Security concerns
○ Concurrent access problems
● Examples: Library catalog, online shopping inventory, student records
Types of Databases
Relational Databases (SQL-based)
NoSQL Databases
Hierarchical Databases
Object-Oriented Databases
What is RDBMS?
Relational Database Management System
● Software system that manages relational databases
● Based on the relational model proposed by E.F. Codd (IBM) in 1970
● Uses tables (relations) to store data
● Data organized in rows (records) and columns (fields)
● Establishes relationships between tables using keys
● Examples: MySQL, PostgreSQL, Oracle, SQL Server, SQLite
RDBMS Key Concepts
Core Components of RDBMS
● Tables: Structured data stored in rows and columns (like spreadsheets)
● Fields: Columns in a table (attributes that describe the entity)
● Records: Rows in a table (individual data entries)
● Keys:
○ Primary Key: Unique identifier for each record
○ Foreign Key: References a primary key in another table
○ Candidate Key: Could potentially be a primary key
● Relationships: Connections between tables
○ One-to-one: One record relates to exactly one other record
○ One-to-many: One record relates to multiple records
○ Many-to-many: Multiple records relate to multiple records
● Constraints: Rules that enforce data integrity
○ NOT NULL, UNIQUE, CHECK, DEFAULT
Types of Databases: Relational
Relational Databases
● Based on relational model (tables with relationships)
● Data organized in tables with rows and columns
● Uses SQL for querying and management
● Strong emphasis on data integrity and ACID properties:
○ Atomicity: Transactions are all-or-nothing
○ Consistency: Data remains in a valid state
○ Isolation: Transactions don't interfere with each other
○ Durability: Completed transactions persist
● Best for: Structured data, complex queries, transactions
● Real-world applications: Banking systems, ERP systems, CRM systems,
e-commerce platforms
SQL Syntax Categories
Standard language for interacting with relational databases
Pronounced either as "S-Q-L" or "sequel"
Created in the 1970s at IBM, standardized by ANSI/ISO
Used for:
● Creating and modifying database structures
● Inserting, updating, and retrieving data
● Defining access permissions
● Managing database transactions
Different SQL dialects exist (MySQL, PostgreSQL, T-SQL, PL/SQL)
Declarative language: you specify WHAT data you want, not HOW to get it
Why Do We Use SQL?
Easy to learn and use.
Helps in organizing and managing data efficiently.
Ensures data consistency and security.
Works with most database management systems (DBMS).
Real-World Use Cases of SQL
E-commerce websites (Amazon, Flipkart)
Banking and finance (Credit card transactions)
Healthcare (Patient records)
Social media platforms (User profiles, messages)
Layman Explanation – SQL in Everyday Life
Example: SQL is like asking a librarian to fetch books for you.
Librarian = Database
Query (Your request) = SQL
Books = Data
SQL Commands Categories
DDL (Data Definition Language) – CREATE, ALTER, DROP
DML (Data Manipulation Language) – INSERT, UPDATE, DELETE
DQL (Data Query Language) – SELECT
DCL (Data Control Language) – GRANT, REVOKE
TCL (Transaction Control Language) – COMMIT, ROLLBACK
Understanding Relational Databases
DDL (Data Definition Language)
● CREATE: Create database objects (tables, indexes)
● ALTER: Modify existing database objects
● DROP: Delete database objects
● TRUNCATE: Remove all records from a table
DML (Data Manipulation Language)
● SELECT: Retrieve data from tables
● INSERT: Add new records
● UPDATE: Modify existing records
● DELETE: Remove records
DCL (Data Control Language)
● GRANT: Give privileges to users
● REVOKE: Remove privileges from users
TCL (Transaction Control Language)
● COMMIT: Save transactions permanently
● ROLLBACK: Undo transactions
● SAVEPOINT: Create points to rollback to
How NoSQL is Used in the Real World
Facebook & Instagram: Storing user-generated content.
Netflix & YouTube: Managing recommendation algorithms.
Google Maps: Handling geographical data.
Conclusion & Summary
SQL is essential for structured data management.
NoSQL is useful for large-scale and dynamic applications.
Both are widely used in modern tech solutions.
"The right database depends on the use case!"