Published by Patrick Mutisya · 14 days ago
Understand that the Database Management System (DBMS) carries out all creation and modification of the database structure using its Data Definition Language (DDL).
CREATE – creates a new database object (e.g., CREATE TABLE).ALTER – modifies the definition of an existing object (e.g., adding a column).DROP – removes an object permanently.TRUNCATE – deletes all rows from a table while preserving its structure.SELECT – retrieves data from one or more tables.INSERT – adds new rows to a table.UPDATE – modifies existing rows.DELETE – removes rows from a table.When a DDL command is issued, the DBMS performs the following steps:
| Aspect | DDL | DML |
|---|---|---|
| Purpose | Define or modify database schema | Manipulate data stored in the schema |
| Typical Commands | CREATE, ALTER, DROP, TRUNCATE | SELECT, INSERT, UPDATE, DELETE |
| Effect on Data Dictionary | Yes – updates metadata | No – metadata unchanged |
| Transaction Control | Auto‑committed; cannot be rolled back in many DBMS | Can be committed or rolled back explicitly |
| Impact on Database Structure | Creates, alters, or removes structures | Works within existing structures |
Consider a simple student database. The following sequence shows how DDL and DML interact.
-- DDL: Create a table for student records
CREATE TABLE Student (
StudentID INT PRIMARY KEY,
Name \cdot ARCHAR(50) NOT NULL,
DOB DATE,
GPA DECIMAL(3,2)
);
-- DML: Insert a new student record
INSERT INTO Student (StudentID, Name, DOB, GPA)
VALUES (101, 'Alice Smith', '2002-04-15', 3.85);
-- DDL: Add a new column for email address
ALTER TABLE Student
ADD Email \cdot ARCHAR(100);
-- DML: Update the newly added column
UPDATE Student
SET Email = 'alice.smith@example.com'
WHERE StudentID = 101;
The DBMS must maintain a consistent and accurate description of the database structure. This description, stored in the data dictionary, enables the DBMS to: