Click “Download PDF”, then choose “Save as PDF” as the printer.
Quick revision notes
Databases and SQL: Design and Queries
Foundations: Data, Tables and Keys
Lesson 1Why Databases? Files, Codd and the Relational Model
- A database is an organised, shared collection of data; a DBMS is the software that manages it.
- Plain files cause redundancy, inconsistency, clashes and weak safety; a DBMS prevents them with rules, controls and recovery.
- In 1970 E. F. Codd proposed the relational model: data in simple tables, with users saying what they want and the system deciding how.
- SQL is the standard language of relational databases, and MySQL is the free, popular RDBMS used in this course.
Lesson 2Tables, Keys and Relationships
- A table holds one kind of thing: rows are items, columns are properties with data types, and NULL means no value.
- A primary key is unique and never NULL; a foreign key points to the primary key of another table.
- Use a foreign key on the “many” side for one-to-many, and a junction table for many-to-many.
- Referential integrity stops rows from pointing at something that does not exist.
Working with SQL in MySQL
Lesson 3SQL Basics in MySQL: Create, Insert, Select, Update, Delete
- CREATE TABLE sets column names, data types and constraints; INSERT adds rows.
- SELECT ... FROM ... WHERE ... ORDER BY ... LIMIT reads, filters, sorts and trims rows.
- Use IS NULL, not = NULL, and use brackets when AND and OR are mixed.
- UPDATE and DELETE need a WHERE clause; test it with SELECT first.
Lesson 4Aggregates, GROUP BY and HAVING
- Aggregate functions (COUNT, SUM, AVG, MAX, MIN) turn many rows into one value and ignore NULLs, except COUNT(*).
- GROUP BY produces one result row per group; every selected column must be grouped or aggregated.
- WHERE filters rows before grouping; HAVING filters groups after it.
- MySQL evaluates FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY and LIMIT, in that order.
Lesson 5Joins: Combining Tables in the School Database
- A join matches rows of two tables on a condition, normally foreign key = primary key; aliases and qualified names keep it readable.
- INNER JOIN keeps only matches; LEFT JOIN keeps every left row and fills gaps with NULL.
- After a left join, count a right-hand column, not COUNT(*), and use IS NULL to find the unmatched rows.
- A join without a proper ON condition multiplies the rows; check the row count.
Design, Speed and Safety
Lesson 6Normalisation: 1NF, 2NF, 3NF and BCNF
- Bad design causes update, insertion and deletion anomalies; normalisation removes them by splitting tables.
- 1NF: single values in cells. 2NF: no partial dependency on part of a key. 3NF: no non-key column depends on another non-key column.
- BCNF demands that the left side of every dependency be a candidate key.
- Check a split by joining the pieces back; you must get exactly the original rows.
Lesson 7Indexes, Transactions and ACID
- An index is a sorted B-tree that lets MySQL find rows without a full scan; it costs space and slows writes, and EXPLAIN shows whether it is used.
- A function wrapped around an indexed column in WHERE usually prevents the index from being used.
- A transaction groups statements: COMMIT keeps all of them, ROLLBACK undoes all of them.
- ACID stands for atomicity, consistency, isolation and durability.
Lesson 8Views, Subqueries and Prepared Statements
- A view is a saved query; a subquery is a SELECT inside another statement, returning a value, a list or a table.
- SQL injection happens when user input is glued into SQL text and changes its meaning.
- A prepared statement sends the SQL with ? placeholders and the values separately, so input is never run as code.
- Placeholders cannot stand in for table or column names; also use least-privilege accounts and hash passwords.
Important terms
aggregate function · alias · Alternate key · anomalies · backup and recovery · Book · Candidate key · Clashes · column · Composite key · concurrency control · constraints · Data · data independence · data type · database · DBMS · Deletion anomaly · Edgar F. Codd · First normal form (1NF · Foreign key · functional dependency · Hard questions · Inconsistency · inner join · Insertion anomaly · integrity rules · join · left join · lossless · MariaDB · MySQL · natural key · No rules · normal forms · Normalisation · NoSQL · NULL · partial dependency · Primary key · qualified column · query language · RDBMS · Redundancy · Referential integrity · relational database · relations · row · Second normal form (2NF · security · SQL · Super key · surrogate key · table · table alias · Third normal form (3NF · transitive dependency · Update anomaly · Weak safety · XAMPP
© 2026 VJ Classes · vjclasses.in