Study Notes (Beginner to Advanced
Foundation)
1. Introduction to Databases
A database is an organized collection of structured data stored electronically. It allows
efficient storage, retrieval, and management of data.
Databases are essential in modern applications such as banking systems, e-commerce
platforms, and enterprise software.
Relational databases store data in tables consisting of rows and columns.
Each table represents an entity, and relationships can exist between multiple tables.
SQL is used to interact with these databases in a standardized manner.
2. What is SQL?
SQL stands for Structured Query Language and is used to communicate with relational
databases.
It allows users to perform operations such as querying data, inserting records, updating
information, and deleting entries.
SQL is declarative, meaning users specify what they want rather than how to achieve it.
It is supported by popular systems like MySQL, PostgreSQL, Oracle, and SQL Server.
Understanding SQL is essential for developers, analysts, and data professionals.
3. SQL Command Categories
SQL commands are divided into categories based on functionality.
DDL (Data Definition Language) defines database structure using CREATE, ALTER, and
DROP.
DML (Data Manipulation Language) modifies data using INSERT, UPDATE, DELETE.
DQL (Data Query Language) retrieves data using SELECT.
DCL (Data Control Language) controls permissions using GRANT and REVOKE.
TCL (Transaction Control Language) manages transactions using COMMIT and ROLLBACK.
, 4. Creating and Managing Databases
Databases are created using CREATE DATABASE statement.
Example: CREATE DATABASE company;
Switching databases is done using USE command.
Deleting a database is done using DROP DATABASE.
Database design should consider normalization and relationships.
5. Table Creation in Detail
Tables define the structure of data with columns and data types.
Each column has a data type such as INT, VARCHAR, DATE, or FLOAT.
Primary keys uniquely identify each row in a table.
Example:
CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(100),
salary FLOAT,
hire_date DATE
);
6. Data Types in SQL
INT is used for integers.
VARCHAR is used for variable-length text.
DATE stores date values.
FLOAT stores decimal values.
Choosing correct data type improves performance and storage efficiency.
7. Inserting Data (Advanced)
INSERT INTO is used to add records.
Example: INSERT INTO employees (id, name, salary) VALUES (1, 'Amit', 50000);
Multiple rows can be inserted in one query.
Example: INSERT INTO employees VALUES (2, 'Rahul', 60000), (3, 'Neha', 55000);
Always ensure correct column order.