Practice Flashcards
What is the difference between DDL and DML?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All Flashcards in Topic 3.3
Below are all 15 flashcards for this topic. Sign up free to track your progress and get personalized review schedules.
3.3.15 cards
What is the difference between DDL and DML?
DDL, data definition language, changes the structure of the database — tables, columns, keys. DML, data manipulation language, reads and changes the rows inside tables that already exist. The test is shape versus contents.
Name the main DDL statements and what each does.
CREATE makes a new table with its columns, types and keys; ALTER changes an existing structure, such as adding a column; DROP removes a table entirely, along with everything in it.
Name the main DML statements and what each does.
SELECT reads rows matching a condition; INSERT INTO adds a new row; UPDATE SET changes values in existing rows; DELETE removes rows from a table.
What is the difference between DELETE and DROP?
DELETE removes rows and the table stays, ready for more data — it is DML. DROP removes the table itself, with its structure and all its contents — it is DDL.
Who runs DDL and who runs DML?
DDL is run rarely, by a database administrator, when the design genuinely changes. DML is run constantly, by the application, every time somebody uses the system.
3.3.25 cards
What does the ON condition in a JOIN do?
It names the two columns that must match — almost always a foreign key and the primary key it points at. Without it, every row of one table pairs with every row of the other.
In what order are SQL clauses applied?
FROM and JOIN decide which rows exist, WHERE filters them, GROUP BY collapses them, HAVING filters the groups, SELECT picks the columns, and ORDER BY sorts. SELECT is written first but applied near the end.
What is the difference between WHERE and HAVING?
WHERE filters individual rows before grouping. HAVING filters groups after grouping, and is the only place a condition on a count or total can go, because that value does not exist until GROUP BY has run.
How does LIKE with the % wildcard work?
% stands for any run of characters. 'Sm%' matches anything starting Sm, '%son' anything ending son, and '%ann%' anything containing ann.
When is DISTINCT needed in a joined query?
When the join can legitimately produce the same row more than once — a student belonging to two clubs would otherwise appear twice in a list of names.
3.3.35 cards
What do INSERT, UPDATE and DELETE each do?
INSERT INTO adds a new row; UPDATE SET changes values in rows that already exist; DELETE removes rows. All three are DML, so the table's structure is untouched.
What happens if an UPDATE or DELETE has no WHERE clause?
It applies to every row in the table, with no warning, no confirmation and no undo once committed. The safe habit is to write the WHERE clause first and test it with a SELECT.
Why does an index make reads fast and writes slow?
It is a separate sorted structure the database can go straight to, instead of reading every row. But every INSERT, UPDATE or DELETE on an indexed column must update that structure as well as the row.
What is index fragmentation, and how is it fixed?
After many changes an index's entries no longer sit in an efficient order, so it gradually stops helping. Reorganising tidies it in place; rebuilding constructs it from scratch. Both are usually scheduled for quiet hours.
Why might indexes be dropped before a bulk load and rebuilt afterwards?
With indexes present, every one of the millions of inserted rows updates every index individually. Building each index once at the end is a single sorted pass, which is far cheaper.
Topic 3.3 study notes
Full notes & explanations for Database programming
Computer Science exam skills
Paper structures, command terms & tips
Want smart review reminders?
Sign up free to track your progress. Our spaced repetition algorithm will tell you exactly which cards to review and when.
Start Free