What is a database?
They are structured, persistent collections of data that can be easily accessed, searched, updated and managed.
What is a relational database?
A database that stores data in tables which are linked together using keys.
What is a table?
A structure that stores data in rows and columns.
What is a record?
A single row in a table that stores data about one item/person.
What is a field?
A single column in a table that stores one type of data.
What is a data type?
The type of data a field can store (e.g. integer, text, date, boolean).
What is a primary key?
A field that uniquely identifies each record in a table.
What rules must a primary key follow?
It must be unique and not empty.
What is a foreign key?
A field that links one table to another by referencing a primary key in another table.
What is data redundancy?
When the same data is stored multiple times unnecessarily
What is data inconsistency?
When the same data has different values in different places.
How do relational databases reduce redundancy and inconsistency?
By storing data once and linking tables using primary and foreign keys.
What does SELECT do?
Retrieves (gets) data from a database.
What does FROM do
Specifies which table the data is taken from.
WHERE
Filters records so only rows that meet a condition are shown or affected
What does ORDER BY do?
Sorts the results into a specific order.
: What does ASC mean?
Sort in ascending order (small → big, A → Z).
What does DESC mean?
Sort in descending order (big → small, Z → A).
What does SELECT * do?
Selects all columns from a table.
Write the basic structure of a SELECT query.
SELECT columns
FROM table
WHERE condition
ORDER BY column ASC|DESC;
What does INSERT INTO do?
Adds a new record (row) to a table.
Write the basic structure of INSERT.
INSERT INTO table (columns)
VALUES (values);
What does UPDATE do?
Changes existing data in a table.
Write the basic structure of UPDATE.
UPDATE table
SET column = value
WHERE condition;