Relational Databases: Tables, SQL Queries, and DDL Simplified
Relational Databases: An Overview
Introduction
A relational database organizes data into tables, making it one of the most widely used database models today. It represents data and their relationships using structured tables and supports manipulation and definition through SQL (Structured Query Language). This approach simplifies data organization, retrieval, and management.
1. Tables in Relational Databases
Tables, also known as relations, are the fundamental building blocks of a relational database. Each table comprises rows and columns:
Key Features:
- Columns (Attributes): Define the type of data stored (e.g., Name, Salary).
- Rows (Records): Contain the actual data entries (e.g., Einstein, Physics, 95000).
Instructor Table:
ID | Name | Department | Salary |
---|---|---|---|
22222 | Einstein | Physics | 95000 |
45565 | Katz | Computer Science | 75000 |
2. SQL: The Query Language
SQL (Structured Query Language) is the standard language for interacting with relational databases. It supports querying, inserting, updating, and deleting data.
Example SQL Queries:
SELECT name FROM instructor WHERE dept_name = 'History';
Result: The query will return a single-column table with names like “El Said” and “Califieri.”
SELECT instructor.ID, department.dept_name FROM instructor, department WHERE instructor.dept_name = department.dept_name AND department.budget > 95000;
Result: The query will return rows such as (12121, Finance) and (45565, Computer Science).
3. Data-Definition Language (DDL)
DDL allows database administrators to define schemas, constraints, and tables. For instance:
CREATE TABLE department ( dept_name CHAR(20), building CHAR(15), budget NUMERIC(12, 2) );
Explanation: This statement creates a table with three columns: department name, building, and budget.
4. Database Access via Application Programs
Relational databases often interact with application programs written in languages like C, C++, or Java. These programs use SQL queries to retrieve and manipulate data.
Access Methods:
- ODBC: A standard for connecting databases with C applications.
- JDBC: Java Database Connectivity for Java programs.
Conclusion
Relational databases are a cornerstone of modern data management. Understanding tables, SQL queries, and the role of DDL is essential for competitive exams like GATE, UGC NET, and ISRO. Mastering these concepts equips students and professionals to design efficient databases and solve real-world problems.