SQL: DDL vs DML vs Query for Creating and Deleting Relations
In the relational model, “relations” (tables) have a structure determined by the relational schema. SQL statements that create or modify that structure—and also statements that delete relations—are generally classified as Data Definition Language (DDL).2
By contrast, Data Manipulation Language (DML) changes the data within existing relations (e.g., inserting rows), while [query] operations are typically SELECT statements used to read data rather than define structure.2
Therefore, for tasks like creating the structure of relations or deleting relations, the correct choice is: (iv) DDL. (i.e., DDL governs CREATE TABLE and DROP TABLE.)2
A compact classification:
Key terms introduced above:
- relational schema
- DDL
- DML
- query
Footnotes
-
Wikipedia - Database schema (https://en.wikipedia.org/wiki/Database_schema) - Explains database schema/relational schema as the structure definition. ↩ ↩2
-
Wikipedia - Data definition language (https://en.wikipedia.org/wiki/Data_definition_language) - Defines DDL as SQL for defining/modifying structure and gives typical examples (CREATE/ALTER/DROP). ↩ ↩2 ↩3
-
Wikipedia - Data manipulation language (https://en.wikipedia.org/wiki/Data_manipulation_language) - Describes DML as operations like INSERT/UPDATE/DELETE on data. ↩
Exam shortcut
If the question mentions creating structure or deleting relations/tables, think DDL (e.g., CREATE TABLE, DROP TABLE). If it mentions changing row data, think DML (e.g., INSERT/UPDATE/DELETE).
Common confusion: DELETE vs DROP
SQL DELETE is DML (removes rows). SQL DROP TABLE is DDL (removes the relation/table structure). Always distinguish the verbs’ targets.
Decide which SQL category a task belongs to
- 1Step 1
If you are changing the schema/structure (tables, attributes, constraints, indexes), it is DDL. If you are changing data values in rows, it is DML.
- 2Step 2
Examples: structure changes →
CREATE TABLE,ALTER TABLE,DROP TABLE. Data changes →INSERT,UPDATE,DELETE. - 3Step 3
If the task is about retrieving data (e.g.,
SELECT), it is generally treated as query/reading, not DDL or DML. - 4Step 4
For “creating the structure of the relations” or “deleting relations,” choose (iv) DDL.
Typical SQL lifecycle perspective
Define schema
Design timeUse DDL to define relations (e.g., table definitions)."
Manipulate data
Operation timeUse DML to add/update/remove rows."
Query data
Analysis timeUse queries (often SELECT) to retrieve results; this focuses on reading rather than structure."
Answer mapping to the provided options
- (i) DML: generally for operations on data rows, such as
INSERT,UPDATE,DELETE.2 - (ii) Query: generally for retrieving data (e.g.,
SELECT). - (iii) Relational schema: not a command category; it is the concept/definition of table structure.
- (iv) DDL: generally for defining/modifying/deleting relations and their structures, e.g.,
CREATE TABLEandDROP TABLE.2
Correct option: (iv) DDL.
Footnotes
-
Wikipedia - Data definition language (https://en.wikipedia.org/wiki/Data_definition_language) - Defines DDL as SQL for defining/modifying structure and gives typical examples (CREATE/ALTER/DROP). ↩ ↩2
-
Wikipedia - Data manipulation language (https://en.wikipedia.org/wiki/Data_manipulation_language) - Describes DML as operations like INSERT/UPDATE/DELETE on data. ↩ ↩2
-
Wikipedia - Database schema (https://en.wikipedia.org/wiki/Database_schema) - Explains database schema/relational schema as the structure definition. ↩ ↩2
Knowledge Check
Which SQL category is generally used to create the structure of relations (tables) or delete relations (tables)?