Prepstellar

SQL Fundamentals · Practice set 3 of 5

A SQL Workflow from Question to Result: 10 practice questions

10 questions · Untimed · Free

10 free SQL Fundamentals practice questions on A SQL Workflow from Question to Result, with an explanation for every answer. Untimed. The full mock exam and the timed version are in the app.

Set 3 · A SQL Workflow from Question to Result · 10 questions Read the lesson
  1. Question 1 of 10

    The shop asks which bands it sells. The artists table holds artist_id and name, the genres table holds genre_id and name, and the albums table holds album_id, title and artist_id. Which table do you read?

    1. Agenres, because that table also has a name column
    2. Balbums, because the artist id is stored in that table
    3. Cartists, because one row of it is one band
    4. Dalbums, because the shop sells records and not bands
    Show the answer

    Each table is a named collection of rows. One row of artists is one band, so the band names the question asks for are the name column of that table.

    Next → 1 / 10
  2. Question 2 of 10

    In the statement SELECT title FROM albums; which part is the select list?

    1. Atitle, the column the result will contain
    2. Balbums, the table the rows come from
    3. CFROM albums, the whole second line of the statement
    4. Dthe semicolon, which closes the statement
    Show the answer

    A SELECT statement has a select list, which names the columns to return, and a table list, which names the table they come from. Here title is the select list.

    Next → 2 / 10
  3. Question 3 of 10

    You type a finished statement into a SQL client and send it. What does the client do with it?

    1. AIt rewrites the statement into a private format first
    2. BIt sends the statement on and shows you the answer
    3. CIt runs the statement itself and stores the rows
    4. DIt holds the statement until more work is asked for
    Show the answer

    The client is the program you type SQL into, and its job does not change from one tool to the next: it gives you a work space, it sends the finished statement on to the database, and it shows you the answer that comes back.

    Next → 3 / 10
  4. Question 4 of 10

    The genres table holds five rows: 1 Rock, 2 Jazz, 3 Metal, 4 Alternative and 5 Blues. What does SELECT name FROM genres; return?

    1. AOne column with the five ids, since name is the label
    2. BOne row, holding the number of kinds in the table
    3. CTwo columns, the id and the kind name, for five rows
    4. DOne column, with the five kind names in it
    Show the answer

    You get one column because you named one column in the select list, and five rows because the table holds five rows and nothing was left out.

    Next → 4 / 10
  5. Question 5 of 10

    You send SELECT albm_id, title FROM albums; and the database answers that it cannot find a column called albm_id. What came back from the albums table?

    1. ANothing: the statement was refused and no row was read
    2. BOne row, saying how many columns the table has
    3. CThe six rows, with albm_id filled from album_id
    4. DThe six titles, with the unknown column left empty
    Show the answer

    Every row of albums carries the same named columns: album_id, title and artist_id. There is no column called albm_id, so there is nothing to return and not one row is read.

    Next → 5 / 10
  6. Keep the ones you got wrong

    In the app, every question you miss comes back exactly when you’re about to forget it.

    Opens in your browser. Nothing to install.

    Start studying

    On your phone, with the same account

    Get it on Google Play Download on the App Store
  7. Question 6 of 10

    The albums table has the columns album_id, title and artist_id. The statement SELECT albm_id, title FROM albums; came back as an error. Which single change repairs it?

    1. AAdd a second semicolon after the name albm_id
    2. BPut the two column names the other way round
    3. CWrite album_id in place of albm_id
    4. DReplace the albums table with the artists table
    Show the answer

    The message names the exact thing the database could not find. The fix is one thing: the misspelt name becomes album_id, which is a real column of the table.

    Next → 6 / 10
  8. Question 7 of 10

    You need the id of each kind of music first and its label second, but your result shows Rock in the first column. Which statement gives the order you need?

    1. ASELECT genre_id, name FROM genres;
    2. BSELECT name, genre_id FROM genres;
    3. CSELECT genres FROM genre_id, name;
    4. DSELECT genre_id FROM genres;
    Show the answer

    The result shows the columns in the order you named them in the select list. Naming genre_id first and name second puts the id in the first column and Rock in the second.

    Next → 7 / 10
  9. Question 8 of 10

    You open your client, run `SELECT title FROM albums;` and the database answers that there is no table called `albums`. The name is spelled correctly and the music store does hold that table. What do you check first?

    1. AWhether somebody deleted the six rows of albums
    2. BWhether the select list is missing a second column
    3. CWhether the statement needs its closing semicolon
    4. DWhich database this client connection points at
    Show the answer

    A client runs your SQL against the connection it is pointing at, and a name is looked up in that database alone. When the spelling is right and the table exists in the music store, the first thing to rule out is a connection to another database.

    Next → 8 / 10
  10. Question 9 of 10

    Accept is a band in the artists table, where its artist_id is 2. The albums table holds album_id, title and artist_id. Which statement lists the records Accept made?

    1. ASELECT title FROM albums WHERE artist_id = 2;
    2. BSELECT title FROM artists WHERE artist_id = 2;
    3. CSELECT name FROM artists WHERE album_id = 2;
    4. DSELECT title FROM albums WHERE title = 'Accept';
    Show the answer

    The records and their titles are rows of albums, and albums stores the same artist id. Keeping the rows whose artist_id is 2 leaves the records that Accept made.

    Next → 9 / 10
  11. Question 10 of 10

    The report needs one row for each of the five kinds of music. Your statement came back without an error, but the result has forty rows. What does that tell you?

    1. AThe result is wrong even though no error was raised
    2. BThe database added rows of its own to fill the table
    3. CThe kinds of music were counted twice by the client
    4. DNothing: a result without an error is the right answer
    Show the answer

    Read the answer as well as the error. The report asked for five rows, one per kind of music, so a result eight times that size answers some other question and the statement has to be read again.

    Next → 10 / 10
  12. You’ve finished this set

    That’s 10 questions on A SQL Workflow from Question to Result. In the app the ones you miss come back exactly when you’re about to forget them.

    Back to the course Next lesson: What You Will Learn in This SQL Course

    Opens in your browser. Nothing to install.

    Start studying

    On your phone, with the same account

    Get it on Google Play Download on the App Store

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

On your phone, with the same account

Get it on Google Play Download on the App Store

“This app is the ‘One Lake’ for preparing the certification exams. Really worth it.”

Abdelhak Y. Google Play review