This tutorial explores the fundamental concepts of databases, focusing on relational databases and the crucial process of normalization.
Relational databases are structured to store data in tables with rows representing individual records and columns representing specific attributes. They offer several advantages:
ERM is a visual approach to designing relational databases. It involves identifying entities (things of interest) and relationships between them. These are represented using:
Normalization is the process of organizing data in a relational database to minimize redundancy and improve data integrity. It involves transforming tables into a series of smaller, well-structured tables. Here's a breakdown of the normalization process:
Example:
Consider a "Students" table with attributes "Student ID," "Name," "Address," and "Course ID." This table is not normalized:
Student ID | Name | Address | Course ID |
---|---|---|---|
1 | John | 123 Main St | CS101 |
2 | Jane | 456 Oak Ave | CS101 |
1NF: Separate the "Courses" information into a separate table:
Students:
Student ID | Name | Address |
---|---|---|
1 | John | 123 Main St |
2 | Jane | 456 Oak Ave |
Courses:
Course ID | Course Name |
---|---|
CS101 | Introduction to CS |
2NF: Add a "Student-Course" table to link students to courses:
Student-Course:
Student ID | Course ID |
---|---|
1 | CS101 |
2 | CS101 |
3NF: The tables are now in 3NF, with no redundant data and dependencies only on primary keys.
SQL is the standard language for interacting with relational databases. It offers commands for:
Data Definition Language (DDL):
Data Manipulation Language (DML):
Example SQL Statements:
-- Creating a table
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
Name VARCHAR(255),
Address VARCHAR(255)
);
-- Inserting data into the table
INSERT INTO Students (StudentID, Name, Address)
VALUES (1, 'John', '123 Main St');
-- Retrieving data from the table
SELECT * FROM Students;
Transactions ensure data consistency and integrity in high-stakes database operations. They follow the ACID properties:
NoSQL databases are designed for handling large volumes of unstructured or semi-structured data. They offer:
Examples of NoSQL Databases:
This tutorial has provided a comprehensive overview of databases and normalization, focusing on relational databases, SQL, and the ACID properties for ensuring data integrity. Understanding these concepts is essential for developing robust and secure database systems in various applications. As you progress in your OCR A-level Computer Science journey, you'll delve deeper into specific database technologies and their applications.