DEV Community

Cover image for Introduction to SQL: DDL, DML, and Data Querying
Stephen Omengo
Stephen Omengo

Posted on

Introduction to SQL: DDL, DML, and Data Querying

Structured Query Language (SQL) is used to manage and manipulate databases. In this assignment, I learned how to build and interact with a database from scratch.

DDL vs DML

DDL (Data Definition Language) is used to define the structure of a database. Commands like CREATE, ALTER, and DROP are used to create tables and modify them.

DML (Data Manipulation Language) is used to work with the data inside the database. Commands such as INSERT, UPDATE, and DELETE help in adding, modifying, and removing data.

Practical Usage

I used CREATE to build tables such as students, subjects, and exam_results. I then used INSERT to populate them with data. UPDATE helped correct mistakes, and DELETE removed unwanted records.

Filtering Data

The WHERE clause is used to filter records. I used operators such as:

  • = (equals)
  • > (greater than)
  • BETWEEN (range filtering)
  • IN (multiple values)
  • LIKE (pattern matching)

These made it easy to retrieve specific data from the database.

CASE WHEN

CASE WHEN allows us to transform data into meaningful categories. For example, I used it to classify student performance into Distinction, Merit, Pass, and Fail.

Reflection

This assignment was both challenging and interesting. Understanding relationships between tables and writing correct queries required attention to detail. However, it improved my confidence in working with databases and SQL queries.

Top comments (0)