Database Languages and Interfaces
A Database Management System (DBMS) provides tools and languages for defining,
manipulating, and querying data. These tools are divided into database languages for direct
interaction and interfaces for user-friendly access.
Database Languages
1. Data Definition Language (DDL)
• Purpose: Defines the database schema.
• Operations:
• CREATE: Create a new table, database, or other database objects.
• ALTER: Modify existing database structures.
• DROP: Delete database objects.
• Example:
CREATE TABLE Students (
ID INT PRIMARY KEY,
Name VARCHAR(50),
Age INT
);
ALTER TABLE Students ADD Gender VARCHAR(10);
2. Data Manipulation Language (DML)
• Purpose: Manages and manipulates data within the database.
• Operations:
• SELECT: Retrieve data.
• INSERT: Add new data.
• UPDATE: Modify existing data.
• DELETE: Remove data.
• Example:
INSERT INTO Students (ID, Name, Age, Gender) VALUES (1, 'John', 20, 'Male');
SELECT * FROM Students;
UPDATE Students SET Age = 21 WHERE ID = 1;
DELETE FROM Students WHERE ID = 1;
3. Data Control Language (DCL)
• Purpose: Controls access to the database.
• Operations:
• GRANT: Provides access rights to users.
• REVOKE: Removes access rights from users.
• Example:
GRANT SELECT ON Students TO User1;
REVOKE SELECT ON Students FROM User1;
4. Transaction Control Language (TCL)
• Purpose: Manages database transactions to ensure data consistency.
• Operations:
• COMMIT: Saves all changes made during the transaction.
• ROLLBACK: Undoes changes made during the transaction.
• SAVEPOINT: Sets a point within a transaction for partial rollback.
• Example:
BEGIN TRANSACTION;
INSERT INTO Students (ID, Name, Age, Gender) VALUES (2, 'Alice', 22, 'Female');
COMMIT;
Database Interfaces
1. Command-Line Interface (CLI)
• Description: Direct interaction with the DBMS using commands.
• Examples:
• MySQL command-line client.
• Oracle SQL*Plus.
2. Graphical User Interface (GUI)
• Description: Provides a user-friendly visual interface for database operations.
• Features:
• Drag-and-drop tools for schema design.
• Query builders for generating SQL queries.
• Examples:
• phpMyAdmin (for MySQL).
• pgAdmin (for PostgreSQL).
3. Application Program Interface (API)
• Description: Enables applications to interact with the database programmatically.
• Examples:
• JDBC (Java Database Connectivity).
• ODBC (Open Database Connectivity).
4. Query Language Interface
• Description: Allows users to interact with the database using a query language (e.g.,
SQL).
• Example:
• Writing SQL queries to retrieve or manipulate data.
5. Form-Based Interface
• Description: Provides forms to input, update, or retrieve data.
• Features:
• Simplifies interaction for non-technical users.
• Examples:
• MS Access forms.
6. Natural Language Interface
• Description: Allows interaction with the database using natural language commands.
• Examples:
• "Show me all students older than 20."
• AI-driven systems like ChatGPT querying a database.
7. Web-Based Interface
• Description: Enables database interaction over the web using a browser.
• Examples:
• Online database management systems (e.g., Google Firebase Console).