[{"id":"sqliteadvanced-001","courseId":"sqlite-advanced","domain":"schema-and-types","topic":"Database header and page size","prompt":"A database file's header sets the page size to 512 bytes and the reserved-space byte to 40. Which statement about this header is correct?","hint":"The format limits both the reserved bytes and the usable part of each page.","explain":"Each page sets aside some bytes for extensions and keeps the rest for SQLite. The format keeps the usable part above a fixed minimum, which caps the set-aside part for a given page size.","source":"https://www.sqlite.org/fileformat2.html","interaction":{"type":"single"},"options":[{"id":"a","text":"The header is not allowed: a 512-byte page can reserve at most 32 bytes","why":"The usable size of a page can't fall under 480, so a 512-byte page can reserve at most 32 bytes."},{"id":"b","text":"The header is valid, since 472 usable bytes is still a positive size","whyNot":"Usable size may not drop below 480, and 472 is under that floor."},{"id":"c","text":"The header is valid, because reserved space may take up to half the page","whyNot":"No half-page rule exists; for a 512-byte page the reserved limit is 32 bytes."},{"id":"d","text":"The header is valid, since the engine never checks the reserved byte","whyNot":"The reserved value is checked against the usable-size limit, so 40 is rejected."}],"answer":"a","explanation":"The usable size of a page is the page size minus the reserved bytes, and it may not fall below 480, so a 512-byte page can reserve at most 32 bytes.","concept":"The usable size of a page is the page size minus the reserved bytes, and it may not fall below 480, so a 512-byte page can reserve at most 32 bytes.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","takeaways":["Reserved bytes come out of a page's usable size, which has a floor of 480."]},{"id":"sqliteadvanced-002","courseId":"sqlite-advanced","domain":"schema-and-types","topic":"sqlite_schema table","prompt":"In the sqlite_schema table, a WITHOUT ROWID table's PRIMARY KEY gets its own row, just like any other index on that table.","hint":"Think about how a table without a rowid stores its key, and what gets recorded for it.","explain":"The schema table normally holds one row per database object, and constraints create internal indexes with generated names. How a table is stored can change which of these internal pieces get a row.","source":"https://www.sqlite.org/fileformat2.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"A WITHOUT ROWID table has no sqlite_schema row for its PRIMARY KEY; only the generated autoindex name is reserved."},{"id":"b","text":"False","why":"The format keeps no sqlite_schema entry for that key, though its sqlite_autoindex name is still set aside."}],"answer":"b","explanation":"A WITHOUT ROWID table has no sqlite_schema row for its PRIMARY KEY; the autoindex name is only set aside, which shifts the numbering of later UNIQUE constraints.","concept":"A WITHOUT ROWID table has no sqlite_schema row for its PRIMARY KEY; the autoindex name is only set aside, which shifts the numbering of later UNIQUE constraints.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","takeaways":["WITHOUT ROWID changes schema bookkeeping as well as storage, so check sqlite_schema when auditing tables."]},{"id":"sqliteadvanced-003","courseId":"sqlite-advanced","domain":"schema-and-types","topic":"DROP COLUMN restrictions","prompt":"A table has a text column named memo that holds data in many rows. Which TWO of these facts about memo would make ALTER TABLE ... DROP COLUMN memo fail?","hint":"Ask what else in the schema still refers to the column, and what the drop itself has to rewrite.","explain":"Dropping a column is more than a metadata edit, because the stored rows are rewritten. The drop proceeds only when no other part of the schema still depends on that column by name.","source":"https://www.sqlite.org/lang_altertable.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"It is named in the WHERE clause of a partial index","why":"A partial index refers to the column through its WHERE clause, so the column can't be removed while that index exists."},{"id":"b","text":"It has a UNIQUE constraint","why":"A column with a UNIQUE constraint cannot be dropped."},{"id":"c","text":"It holds non-NULL text in many rows","whyNot":"DROP COLUMN rewrites the table's content to purge the column's data, so stored values don't block it."},{"id":"d","text":"It has a DEFAULT value","whyNot":"A default only supplies values for future inserts; it does not stop a column from being dropped."},{"id":"e","text":"The table holds more than a million rows","whyNot":"Large tables make the drop slower, since the data must be rewritten, but size alone does not make it fail."},{"id":"f","text":"It was added later with ALTER TABLE ADD COLUMN","whyNot":"Columns added later are dropped like any other; being appended at the end doesn't block removal."}],"answer":"ab","explanation":"DROP COLUMN fails if the column is in the PRIMARY KEY, has a UNIQUE constraint, is indexed, or is named in a partial index's WHERE clause; stored data alone is not a blocker.","concept":"DROP COLUMN fails if the column is in the PRIMARY KEY, has a UNIQUE constraint, is indexed, or is named in a partial index's WHERE clause; stored data alone is not a blocker.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","takeaways":["Before dropping a column, check indexes, UNIQUE constraints and partial-index WHERE clauses that name it."]},{"id":"sqliteadvanced-004","courseId":"sqlite-advanced","domain":"schema-and-types","topic":"ATTACH and schema-qualified names","prompt":"Two attached databases, sales and archive, each contain a table named orders. The main database has no such table. You run SELECT * FROM orders; with no schema prefix. Which table is read?","hint":"Think about the order in which the two databases joined the connection.","explain":"Attaching a database gives its tables a prefix that keeps them apart. A bare name must still resolve to one table, so SQLite applies a fixed tie-breaking rule based on the connection's history.","source":"https://www.sqlite.org/lang_attach.html","interaction":{"type":"single"},"options":[{"id":"a","text":"The copy in the database attached most recently","whyNot":"Recency works in reverse here: the newest attachment does not win an unqualified name."},{"id":"b","text":"The copy in the database attached least recently","why":"Without a prefix, the name resolves to the table in the database that was attached least recently."},{"id":"c","text":"An error, because the name matches two tables","whyNot":"Duplicate names across attached databases are not an error here; SQLite picks one copy."},{"id":"d","text":"The copy with more rows","whyNot":"Row counts play no part; the choice follows the order in which the databases were attached."}],"answer":"b","explanation":"An unqualified table name that exists in several attached databases resolves to the copy in the database that was least recently attached.","concept":"An unqualified table name that exists in several attached databases resolves to the copy in the database that was least recently attached.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","takeaways":["Qualify table names with their schema prefix whenever two attached databases share a table name."]},{"id":"sqliteadvanced-005","courseId":"sqlite-advanced","domain":"schema-and-types","topic":"Recursive triggers setting","prompt":"Before SQLite 3.6.18, recursive triggers were not supported, and the engine behaved as if the recursive_triggers pragma were always off.","hint":"Consider what the engine did in releases that predate the feature.","explain":"A pragma can only switch on or off a feature the running release provides. Before a feature arrives, the switch has no feature to govern, so think about what the engine does in that case.","source":"https://www.sqlite.org/pragma.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","why":"The feature did not exist before 3.6.18, so behavior matched the pragma being off."},{"id":"b","text":"False","whyNot":"Before 3.6.18 there was no working recursive trigger support to turn on or off."}],"answer":"a","explanation":"Before SQLite 3.6.18 recursive triggers were unsupported, and the engine acted as if recursive_triggers were OFF; support arrived in 3.6.18, initially OFF by default.","concept":"Before SQLite 3.6.18 recursive triggers were unsupported, and the engine acted as if recursive_triggers were OFF; support arrived in 3.6.18, initially OFF by default.","rev":1,"updatedAt":"2026-10-27","kind":"scenario","takeaways":["A pragma's default and the release that added its feature are separate facts; check both for old versions."]}]