sql for data science with r coursera answers week 6
Final Exam
Final Exam
1. Which of the following displays correct syntax for the SELECT statement that retrieves data from the “MovieName” column in a table named “Movie?”
- SELECT MovieName FROM Movie;
- SELECT MovieName, Movie;
- SELECT Movie FROM MovieName;
- FROM Movie SELECT MovieName;
2. What is wrong with the following INSERT statement?
INSERT INTO Movie (MOVIE_ID, MOVIE TITLE, RELEASE_YEAR) VALUES (52, ‘Princess Bride’, 1987), (‘When Harry Met Sally’, 1989);
- It is missing the keyword “COLUMNS.”
- The column names are in the incorrect order.
- The word “INTO” should be removed.
- It is missing a value.
3. Which of the following would be attributes in an entity-relationship (ER) diagram for an entity named “Dog?”
- German Shepherd, Fido, green, short-haired, female
- German Shepherd, Malamute, Chihuahua, Labrador, Golden Retriever
- breed, fur type name, eye color, gender
- breed, German Shepherd, Fido, name, eye color
4. Which two statements are true regarding data manipulation language (DML) operations?
- They are used to define, change, or drop database objects such as tables.
- They are often referred to as create, read, updates, and delete (CRUD) operations.
- They are used to read and modify data in tables.
- They are used to define relationships among tables.
5. Which of the following SQL statements is equivalent to “SELECT title, pages FROM Book WHERE pages >= 290 AND pages <= 300;”?
- SELECT title, pages FROM Book WHERE pages BETWEEN 290 AND 300;
- SELECT pages BETWEEN 290 AND 300 FROM Book;
- SELECT title, pages FROM Book WITH pages BETWEEN 290 AND 300;
- None of the above. There is not another equivalent form of that SQL statement.
6. Which would be the result of the SQL statement
SELECT TeamName, COUNT(*) FROM Roster GROUP BY TeamName;
- Return a list of all players on each team
- Counts the total number of players on a team listed in the “Roster” table and displays the results by “TeamName”.
- Counts the total number of players on all teams listed in the “Roster” table
- Lists a specific count associated with each team.
7. Which statement describes a schema?
- It is a collection of observations.
- It is similar in structure to an R dataframe.
- It groups a set of tables together in a database.
- It is a subset of a table’s attributes.
8. How should dates and times be mapped from R to a relational database management system (RDBMS)?
- As integers
- As strings
- Using the toDate() method
- As objects
9. Which RODBC method is most closely associated with the SQL TRUNCATE statement?
- sqlRemove()
- sqlDrop()
- sqlClear()
- sqlTrim()
10. What is the purpose of the sqlFetch() function?
- To select all the data in a table
- To get data from the RDBMS and create a histogram in R
- To get data from the R object database management system (RODBMS) and create a box plot in R
- Converts character data into vector data
11. Which statement is the correct way to retrieve the player who scored the most points per game on each basketball team?
- SELECT TeamName, PlayerName, MAX(GamePoints) FROM Scores;
- SELECT TeamName, PlayerName FROM Scores WHERE MAX(GamePoints);
- SELECT TeamName, GamePoints, MAX(PlayerName) FROM Scores;
- SELECT TeamName, PlayerName, MAX FROM Scores;
12. Which of the following is the correct general syntax for the INSERT statement?
- INSERT <column name> INTO <table name>;
- INSERT <table name> INTO <column name> VALUES {[value], [value],…};
- INSERT INTO <table name> (column1, column2…) VALUES (value1, value2…);
- INSERT INTO <table name> WHERE <column name> EQUALS <primary key> WITH VALUES
13. What data would be returned from this SQL statement?
SELECT firstname FROM Book WHERE firstname LIKE R%;
- Returns data from the column named “firstname” from the “Book” table if the first letter of “firstname” is ‘R’
- Returns data from the column named “firstname” from the “Book” table if the “firstname” contains an R
- Returns data from the column named “firstname” from the “Book” table if the first letter of “firstname” is NOT ‘R’
- Returns data in the row whose primary key is “firstname” from the “Book” table if the first letter of the Book name is ‘R’
14. What feature in a relational database management system is similar to an observation in R?
- A row
- An attribute
- A table
- A primary key
15. Data that needs transformed into a factor is generally transferred from an R object database management system (RODBMS) into R as what data type?
- A float
- An object
- A Boolean
- A character