DEV Community

Bill Muli
Bill Muli

Posted on

A Practical Introduction to SQL: DDL, DML, and Data Analysis

What are DDL and DML?
DDL (Data Definition Language)

DDL refers to SQL commands used to define and manage the structure of a database. These commands control how data is stored.

Examples:

1.CREATE – used to create tables or databases
2.ALTER – used to modify existing structures
3.DROP – used to delete tables or databases


Table structure after executing CREATE statement.

DML (Data Manipulation Language)
DML deals with the data inside the database. It allows you to insert, update, retrieve, and delete data.

Examples:

1.INSERT – adds new records
2.UPDATE – modifies existing records
3.DELETE – removes records
4.SELECT – retrieves data

Difference
DDL focuses on the structure, while DML focuses on the data itself.

In simple terms,** DDL builds the house*, and* DML manages what’s inside it.**

Application of CREATE, INSERT, UPDATE, and DELETE
In this assignment, I used several SQL commands to build and manage a school database:

I used the CREATE statement to define tables such as students, subjects, and exam_results.

INSERT
The INSERT statement was used to populate tables with data.

UPDATE
I used UPDATE to modify existing data.

DELETE
Used to remove incorrect or unnecessary records.

Filtering Data with WHERE
The WHERE clause is essential for retrieving specific data.

Operators used:

= → exact match

→ greater than
BETWEEN → range filtering
IN → multiple values
LIKE → pattern matching

Using CASE WHEN for Data Transformation
The CASE WHEN statement applies conditional logic.

Example classification:

1.Marks ≥ 80 → Distinction
2.Marks ≥ 60 → Merit
3.Marks ≥ 40 → Pass
4.Below 40 → Fail

Reflection
This week was both challenging and rewarding. Errors like incorrect column names and missing tables helped me understand how strict SQL is and the importance of attention to detail.

Top comments (0)