SQL Fundamentals · SQL Foundations
16 cards
Relational Model and SQL
-
Quick check
Which row describes Bob?
Acustomer_number 20, name Bob
Right. Reading across that row gives Bob's stored values.
BThe name column by itself
A column holds the same kind of fact for many rows; it is not Bob's complete row.
Ccustomer_number 10, name Alice
That row describes Alice, not Bob.
2 / 16
-
Quick check
The customers table already has primary-key value 10. What happens if a new row also uses 10?
ABoth rows become customer 10
Two matching values would no longer identify one row.
BThe database changes the new value
A primary-key rule checks the value; it does not silently replace it.
CThe duplicate insert is rejected
Right. A primary key must remain unique.
4 / 16
-
Quick check
The customers table has keys 10 and 20. Can a new order use non-null customer_number 99?
AYes; 99 creates a customer automatically
A foreign key does not create the missing customer row.
BNo; the order violates the foreign-key rule
Right. The value must match a referenced customer key.
CYes; any non-null number is accepted
NOT NULL only says a value is present; the foreign key also requires a match.
6 / 16
-
Keep your progress in the app
That’s 3 of 8 quick checks. In the app they stay answered, and every lesson remembers where you left off.
Keep reading hereOpens in your browser. Nothing to install.
Start studying -
Quick check
Which line removes rows whose quantity is not greater than 1?
AWHERE quantity > 1
Right. WHERE applies the condition to each input row.
BSELECT price * quantity AS total
The select list calculates an output value after rows are selected.
CFROM order_items
FROM supplies the input table but does not apply this condition.
8 / 16
-
Quick check
What result does SELECT 2 + 3; return?
ATwo result rows, one with 2 and one with 3
The plus sign adds the two values; it does not make a row for each literal.
BAn error because the statement names no table
This value-only SELECT needs no input table in the SQLite/PostgreSQL lab.
COne result cell containing 5
Right. The expression produces 5, and the query returns it in one cell.
10 / 16
-
Quick check
Which totals does the query return for the three input rows?
A30 and 50
Right. Items A and C pass WHERE, then the select-list expression returns 30 and 50.
B20 only
Item B has price 20, but quantity 1 fails the WHERE condition.
C30, 20, and 50
This includes item B even though its quantity is not greater than 1.
12 / 16
-
Quick check
Which design applies all three requirements?
ADeclare customer_number and email as two primary keys
A table can declare only one primary key; email can use a separate unique constraint.
BMake customer_number the primary key, email unique, and orders.customer_number both NOT NULL and a foreign key
Right. NOT NULL requires a customer value and the foreign key checks that this customer exists.
CMake customer_number the primary key, email unique, and orders.customer_number a foreign key
The foreign key alone still accepts an order whose customer column is null, which names no customer.
14 / 16
-
Quick check
For one order row, which combination identifies its customer and calculates an output total?
AA result set used as a primary key
A result set is query output; it does not identify the customer row in this design.
BA semicolon and a NOT NULL rule
A semicolon ends a statement, and NOT NULL alone neither connects rows nor calculates a total.
CA matching foreign key and the value expression price * quantity
Right. The foreign key connects the order to a customer, and the expression calculates one result value.
16 / 16
-
8 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.
Take this lesson’s test →Opens in your browser. Nothing to install.
Start studying
The whole course, on your computer and your phone
Lessons you can read, audio you can listen to on the way to work, and practice that remembers what you got wrong.
Opens in your browser. Nothing to install.
Start studying“This app is the ‘One Lake’ for preparing the certification exams. Really worth it.”
