Databases and SQL Basics
SQL selects, inserts, updates and deletes data in tables.
About this topic
A database is an organised collection of data that can be stored, searched and updated efficiently. In a relational database, data sits in tables made of rows (records) and columns (fields). Each row is identified by a primary key, and tables are linked using foreign keys, which avoids repeating information. For example, a Students table and a Courses table can be linked through an Enrolments table.
SQL (Structured Query Language) is used to work with such data. SELECT name FROM Students WHERE age greater than 15 retrieves names, INSERT adds rows, UPDATE changes them and DELETE removes them. ORDER BY sorts results, and JOIN combines related tables. Databases also provide validation and transactions, so that a set of changes either all happens or none does, as in transferring money between bank accounts.
Websites, banks, hospitals and games all depend on databases. A common mistake is forgetting the WHERE clause in an UPDATE or DELETE, which changes every row. Another is storing the same data in many places, causing inconsistencies. Beware of SQL injection, where attackers type commands into forms, which is prevented by using parameterised queries.
Key ideas
- SELECT ... FROM ... WHERE
- Primary keys
- Joins combine tables
Quick check
Use cases: where Databases and SQL Basics helps
- Homework: review the key idea behind Databases and SQL Basics before you start a problem set.
- Exam revision: use the quick check to test whether you can recall Databases and SQL Basics without notes.
- Visual learning: play with the interactive lab to see how Databases and SQL Basics changes when you adjust its inputs.
- Teaching a friend: explain Databases and SQL Basics in your own words, then compare your version with the key ideas.
Computing ideas run phones, search engines, games and the wider internet.
Frequently asked questions
What is Databases and SQL Basics?
SQL selects, inserts, updates and deletes data in tables.
What will I learn in Databases and SQL Basics?
SELECT ... FROM ... WHERE. Primary keys. Joins combine tables.
Is Databases and SQL Basics part of Computer Science?
Yes. It is one of 80 Computer Science topics on LearnViz HighSchoolEdu, with 3 key ideas, a live animation and a quick check.
Does the Databases and SQL Basics lab work on a phone or tablet?
Yes. The animation resizes to fit your screen and supports touch, so you can drag, tap and slide with your finger.
How should I study Databases and SQL Basics?
Read the summary and key ideas first, play with the interactive lab to see the idea in motion, then answer the quick check. If you get a question wrong, go back to the key idea it tests.
Do I need an account, and is my progress saved?
No account is needed. Marking a topic as learned is saved in your own browser, so it stays on that device and is not sent to a server.