0% found this document useful (0 votes)
3 views

databases

The document provides an overview of relational databases and SQL, explaining the structure and key concepts such as tables, records, and keys. It details the advantages of relational databases, including data consistency and reduced redundancy, and introduces basic SQL commands for retrieving, inserting, updating, and deleting data. Additionally, it covers how to work with multiple tables using SQL joins.

Uploaded by

oSAHILp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

databases

The document provides an overview of relational databases and SQL, explaining the structure and key concepts such as tables, records, and keys. It details the advantages of relational databases, including data consistency and reduced redundancy, and introduces basic SQL commands for retrieving, inserting, updating, and deleting data. Additionally, it covers how to work with multiple tables using SQL joins.

Uploaded by

oSAHILp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

AQA GCSE Computer Science

Databases and SQL (3.7)

1 Relational Databases (3.7.1)


1.1 Concept of a Database
• A database is an organized collection of data that can be easily accessed, managed, and updated.
• Databases allow data to be stored in a structured way, enabling efficient retrieval and management.
• Examples: A library system storing information about books, authors, and borrowers.

1.2 Concept of a Relational Database


• A relational database organizes data into tables that are related to each other.
• Data is stored in tables, and relationships are established using keys.
• This structure helps maintain data consistency and reduces redundancy.

1.3 Key Database Concepts


• Table: A collection of related data organized in rows and columns.
• Record: A single row in a table, representing one item of data.
• Field: A single column in a table, representing one attribute of the data.
• Data Type: Defines the kind of data a field can store (e.g., INTEGER, TEXT, DATE).
• Primary Key: A unique identifier for each record in a table.
• Foreign Key: A field in one table that links to the primary key in another table.

1.4 Advantages of Relational Databases


• Data Consistency: Reduces data inconsistency by storing related data in linked tables.
• Data Redundancy: Minimizes duplicate data by linking tables through keys.

2 Structured Query Language (SQL) (3.7.2)


2.1 Retrieving Data from a Database
Basic Commands:
• SELECT: Specifies the columns to retrieve.
• FROM: Indicates the table to retrieve data from.
• WHERE: Filters data based on conditions.
• ORDER BY: Sorts data in ascending (ASC) or descending (DESC) order.
Examples:

1
1 SELECT * FROM students ;
2 SELECT first_name , last_name FROM students ;
3 SELECT * FROM students WHERE grade = 9;
4 SELECT * FROM students ORDER BY last_name ASC ;
5 SELECT * FROM students ORDER BY grade DESC ;

2.2 Inserting Data into a Database


INSERT INTO Command:
1 INSERT INTO students ( first_name , last_name , grade )
2 VALUES ( ’ Irene ’ , ’ Smith ’ , 9) ;

2.3 Editing Data in a Database


UPDATE Command:
1 UPDATE students
2 SET grade = 10
3 WHERE first_name = ’ Irene ’ AND last_name = ’ Smith ’;

2.4 Deleting Data from a Database


DELETE Command:
1 DELETE FROM students
2 WHERE grade < 5;

2.5 Working with Multiple Tables


1 SELECT students . first_name , classes . class_name
2 FROM students
3 JOIN classes ON students . class_id = classes . id
4 WHERE classes . class_name = ’ Math ’;

You might also like