CAMBRIGDE INTERNATIONAL
DATABASES
AS LEVEL -CS
DATABASES 1
DATABASES
DATABASES
STRUCTURED QUERY
LANGUAGE
DATABASES 2
DATABASES
DATABASES 3
SQL (Structured Query Language)
• SQL (Structured Query Language) is the standard programming language for managing,
manipulating, and retrieving data stored in relational database management systems (RDBMS).
• It is widely used to create, read, update, and delete (CRUD) data across various platforms like
MySQL, Oracle, and PostgreSQL, utilizing structured rows and columns.
DATABASES
Aspects of SQL:
• Data Definition: Defining the structure and schema of the database.
• Data Manipulation: Adding, changing, or removing the actual data records.
• Data Control: Managing who has permission to see or touch the data.
• Data Querying: The most common use—asking the database to find specific information (e.g.,
Show me all customers who bought coffee today).
DATABASES 4
Data Definition Language (DDL)
• DDL is the Architect of the SQL world.
• It deals with the schema (the blueprint) rather than the individual rows of data.
• If you are building the house, DDL is what defines the walls, the roof, and the rooms.
Features of DDL:
• Structural Focus: It creates, modifies, and destroys the containers (tables, indexes, users)
DATABASES
where data lives.
• Auto-Commit: In most databases, DDL changes are permanent the moment you run them;
there is no "undo" button.
• Metadata Impact: It updates the "Data Dictionary"—the internal catalog the database uses to
keep track of its own structure.
• Common DDL Commands:
• CREATE: To make a new table or database.
• ALTER: To change the structure of an existing table (like adding a column).
• DROP: To delete an entire table or database structure.
• TRUNCATE: To wipe all data from a table while keeping the table structure intact.
DATABASES 5
Data Manipulation Language (DML)
• If DDL is the architect, DML is the Interior Decorator.
• It deals with the data inside the structures.
• This is where you spend 90% of your time as a developer or data analyst.
Features of DML:
• Record-Level Operations: It targets specific rows or groups of rows within a table.
DATABASES
• Rollback Capability: Unlike DDL, DML operations can usually be "rolled back" (undone) if they are
part of a transaction that hasn't been finalized yet.
• Immediate Utility: This is the part of SQL used to power apps, websites, and reports by retrieving
or updating user information.
Common DML Commands:
• INSERT: To add new rows of data.
• UPDATE: To modify existing data.
• DELETE: To remove specific rows.
• SELECT: Often grouped here (though sometimes called DQL), it’s used to retrieve and view data.
DATABASES 6
DDL vs. DML: A Quick Comparison
Feature DDL (Data Definition) DML (Data Manipulation)
To define the database To manage/operate on
Purpose
DATABASES
structure. the data.
Target Tables, Schemas, Indexes. Rows and Records.
Effect Changes the "Blueprint." Changes the "Content."
Generally No (Auto-
Undo? Yes (Can be rolled back).
commit).
DATABASES 7
DATABASES
DATABASES 8
DATABASES
DATABASES 9
DATABASES
DATABASES 10
DATABASES
DATABASES 11
DATABASES
DATABASES 12
DATABASES
DATABASES 13
DATABASES
DATABASES 14
DATABASES
DATABASES 15
DATABASES
DATABASES 16
DATABASES
DATABASES 17
DATABASES
DATABASES 18
DATABASES
DATABASES 19
DATABASES
DATABASES 20
DATABASES
DATABASES 21
DATABASES
DATABASES 22
DATABASES
DATABASES 23
DATABASES
DATABASES 24
DATABASES
DATABASES 25
DATABASES
DATABASES 26
DATABASES
DATABASES 27
DATABASES
DATABASES 28
DATABASES
DATABASES 29
DATABASES
DATABASES 30
DATABASES
DATABASES 31
DATABASES
DATABASES 32
References
• [Link]
• [Link]
DATABASES
• [Link]
DATABASES 33