SQL Fundamentals · SQL Foundations
20 cards
Relational Model and SQL
-
Quick check
Someone says a database keeps its data in relations, with a fixed set of typed columns. What is being described?
AA declared link joining two tables together
A link between tables is a foreign-key reference, which is a separate idea built on top of tables.
BA table, with the same named columns in every row
Right. Relation is the mathematical term for a table, and every row of a table carries the same named columns, each of one specific data type.
CA grouping of databases managed by one server instance
A collection of databases managed by one server instance is a database cluster, not a single stored structure.
3 / 20
-
Quick check
Users report that two runs of the same unsorted listing showed the stored records in a different sequence, and no data changed in between. What is happening?
AThe column order drifted between runs, so columns must be named
Column order is fixed in each row by the table definition, so it cannot drift between two runs.
BThe session replayed a cached copy of the earlier result
Nothing replays an earlier result, and no cache decides the sequence in which rows come back.
CRow order is not guaranteed, so the query must sort
Right. SQL promises nothing about the order of the rows within a table, and only an explicit sort makes the presentation order dependable.
5 / 20
-
Quick check
A table already carries three separate unique constraints. How many primary keys may it also declare?
AAt most one, whatever the number of unique constraints
Right. Unique constraints can be repeated freely, but only one candidate can be promoted to primary key, and that promotion also forces its columns to be not null.
BOne for every unique constraint whose columns are not null
Unique constraints do not each earn a primary key; the limit of one applies to the table as a whole.
CNone, because those unique constraints already identify a row
Existing unique constraints never block a primary key, and the primary key is still the declared identity of a row.
7 / 20
-
Keep your progress in the app
That’s 3 of 9 quick checks. In the app they stay answered, and every lesson remembers where you left off.
-
Quick check
Which columns of the referenced table can a foreign key legitimately point at?
AAny columns carrying an index that makes the lookup faster in practice
An ordinary index makes lookups faster but still allows duplicate target rows, so the reference would not resolve to one row.
BAny columns declared not null in the referenced table
Rejecting nulls does not prevent duplicate values, so a not-null column is not by itself a valid target.
CA primary key, a unique constraint, or a non-partial unique index
Right. Only those three guarantee uniqueness on the referenced side, so a reference resolves to at most one row.
10 / 20
-
Quick check
A table has two columns that are each unique and never null. Other tables must reference it without naming a column list, and one declared identity must identify a row. Which design works?
ADeclare both columns as unique constraints and name the wanted column in every reference
With no primary key at all, a reference that omits the column list has no default target to resolve to.
BDeclare one column the primary key and leave the other as a unique constraint
Right. A bare reference resolves to the primary key, so exactly one column has to hold that role while the other stays useful as a unique constraint.
CDeclare the two columns together as a single primary key covering both
A two-column primary key identifies rows only by the pair, so a reference would have to supply both columns instead of one identity.
12 / 20
-
Quick check
Which part of a query states which values the output should contain?
AThe select list
Right. The select list is the clause that decides which columns or computed values the statement produces.
BThe sort specification, which arranges the finished output
A sort specification decides presentation order only, and never changes which values are produced.
CThe table expression, which supplies the rows the query works from
The table expression says where the rows come from, whether that is one table or a construct of joins and subqueries.
14 / 20
-
Quick check
A report must show a value computed from two numeric columns, must not change which rows come back, and must expose that value as an output column. Where does the calculation belong?
AIn the sort specification, so the value appears while ordering
A sort specification only arranges rows; it adds no output column to the result.
BIn the table expression, as a source combined with the base table
The table expression decides where rows come from, so adding a source there risks changing which rows return.
CIn the select list, as a computed entry beside the column references
Right. The select list can hold calculations as well as plain column references, so it adds the output column without touching the rows.
16 / 20
-
Quick check
What does a SELECT statement written without any table expression do?
AIt evaluates the expressions in its select list and returns them
Right. Omitting the table expression turns the statement into a calculator over constants and function results.
BIt fails with a syntax error until a source table is supplied
The table expression is optional, so leaving it out is valid rather than an error.
CIt reads every table that the current database contains
No table is read at all when the table expression is absent, so nothing is scanned.
18 / 20
-
Quick check
Which summary keeps the roles straight?
AA sort specification chooses the output values, and a unique index alone can be referenced
A sort specification only orders rows, and a referenced index has to be unique and non-partial rather than any index at all.
BThe select list chooses the values, the table expression supplies the rows, and one primary key per table is the default reference target
Right. Each clause owns one decision, and the single primary key is what a reference written without a column list resolves to.
CAn asterisk selects one column, and a table promises the order of its rows
An asterisk means all the columns the table expression provides, and row order within a table is never guaranteed.
20 / 20
-
9 quick checks · then the test
In the app, finishing the quick checks opens this lesson’s 10-question test, and the ones you miss come back exactly when you’re about to forget them.
The whole course, on your phone
Lessons you can read, audio you can listen to on the way to work, and practice that remembers what you got wrong.