Databases & SQL

HSC Software Engineering · Unit 2: Programming for the web

Databases & SQL notes

Fact-checked by a second, independent AI review.

Core ideas: databases store structured data for web apps, using SQL to query and manipulate data, with tables related by keys. Focus on how to design, query, and safeguard data in web programming tasks.

Database vs DBMS
A database is a structured set of data; the DBMS (e.g., MySQL, PostgreSQL) manages access, storage, and integrity.
Tables, records and fields
Data is organised into tables (relations) with rows (records) and columns (fields) that define data types.
Primary key & foreign key
A primary key uniquely identifies a row; a foreign key links to another table to establish relationships.
SQL basics (CRUD)
Use SELECT, INSERT, UPDATE, DELETE to perform CRUD operations; WHERE filters, ORDER BY sorts results.
Joins & relationships
Joins combine data from related tables; INNER JOIN returns matches, LEFT/RIGHT JOIN handle non-matching records.

Remember it: Remember: CRUD in SQL is the four levers a web app uses to interact with data.

Exam tip: Markers look for clear table design, correct use of keys, proper SELECT with WHERE, and correct JOINs; show you understand data relationships and basic security like avoiding SQL injection.

Syllabus checklist

  • Databases & SQL: core ideas
  • Terms and typical exam questions for "Programming for the web" in NSW HSC Software Engineering

Practice questions

  1. 1. Which SQL clause filters rows in a query?

    Answer checked

    Show answer

    Answer: WHERE. WHERE filters rows based on a specified condition.

  2. 2. SQL stores data in tables on disk.

    Answer checked

    Show answer

    Answer: True. Relational databases persist data on disk by default.

  3. 3. The SQL clause that sorts results is ____.

    Answer checked

    Show answer

    Answer: ORDER BY. ORDER BY sorts the result set by one or more columns.

  4. 4. Which operation combines two tables by matching values?

    Answer checked

    Show answer

    Answer: JOIN. JOIN matches rows from two tables on a related column.

  5. 5. Typed: What is the result of COUNT(*) on a table with 3 rows?

    Answer checked

    Show answer

    Answer: 3. COUNT(*) returns the number of rows; here it is 3.

Practise databases & sql as a game

Hearts, combos, streaks and an AI tutor that explains every answer. Start free.

Start free

More from Unit 2: Programming for the web