Show understanding that the DBMS carries out all queries and maintenance of data using its DML

8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)

What is DDL? 🏗️

DDL (Data Definition Language) is like the blueprint for a house. It tells the DBMS how the data should look – the tables, columns, data types, and relationships. Think of it as the architect’s plan that defines the structure before any furniture is added.

What is DML? 🛠️

DML (Data Manipulation Language) is the day‑to‑day work inside the house. It moves, adds, updates, or deletes the furniture (records) that live in the rooms (tables). DML lets you interact with the data once the structure is set up.

How the DBMS Uses DDL and DML

The DBMS is the construction crew that follows the blueprint and then runs the daily operations. When you issue a CREATE TABLE command, the DBMS builds the table structure. When you issue SELECT, INSERT, UPDATE, or DELETE, the DBMS moves the data around, keeps it consistent, and ensures that all rules (constraints) are respected.

Common DDL Statements

  • CREATE TABLE – Build a new table.
  • ALTER TABLE – Modify an existing table (add/drop columns, change types).
  • DROP TABLE – Remove a table entirely.
  • CREATE INDEX – Speed up searches.

Common DML Statements

  1. SELECT – Retrieve data.
  2. INSERT – Add new rows.
  3. UPDATE – Change existing data.
  4. DELETE – Remove rows.

Example: Creating a Student Table

Statement Purpose Example
DDL Define the table structure. CREATE TABLE Student ( id INT PRIMARY KEY, name VARCHAR(50), age INT, grade CHAR(1) );
DML Add a new student. INSERT INTO Student VALUES (1, 'Alice', 15, 'A');
DML Retrieve all students. SELECT * FROM Student;

Why the DBMS Does All the Work

Think of the DBMS as a super‑smart robot that follows your commands. When you write SELECT, the robot:

  1. Parses the query to understand what you want.
  2. Checks the table structure (DDL) to ensure the columns exist.
  3. Optimises the search (using indexes if available).
  4. Fetches the data and returns it to you.
All this happens instantly, so you don’t need to worry about the underlying mechanics.

Quick Quiz 🎓

1. Which statement creates a new table? CREATE TABLE or INSERT? 2. What does SELECT do? 3. Which language (DDL or DML) would you use to change a column name? Answers: 1) CREATE TABLE, 2) Retrieve data, 3) DDL (ALTER TABLE).

Revision

Log in to practice.

2 views 0 suggestions