Introduction to Databases | Week 2

Course Name: Introduction to Databases

Course Link: Introduction to Databases

These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Self review: Working with numbers

Q1. Identify the correct data type for the Product Price column in the following table.

  • product_price DECIMAL
  • product_price INT
  • product_price TINYINT
  • product_price STRING

Answer: product_price DECIMAL


Q2. A “customer id” column in a customer table is expected to include thousands of customers and the data type should be numeric only. What data type should you use to define this column?

  • customerID DECIMAL
  • customerID TINYINT
  • customerID INT

Answer: customerID INT


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. The data type for the “Number of students” column in the following table must be defined as an INTEGER data type to ensure that only numeric values are accepted.

  • False
  • True

Answer: True


Q4. Which of the following pieces of data are examples of a DECIMAL data type? Select all correct answers.

  • 550
  • 50.00
  • 75.50
  • 455

Answer: 50.00
75.50


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q5. The integer data type stores both negative and positive numbers.

  • False
  • True

Answer: True


Self review: Working with strings

Q1. A college database contains a table called “Students” that has three columns: username, full name and email address. The username column contains alphanumeric values such as “St001” and has a fixed length of five characters. Select the correct SQL syntax for the username column.

  • username VARCHAR(5)
  • username CHAR(5)

Answer: username CHAR(5)


Q2. Which of the following SQL statements uses the right syntax to create the Student table in a college database with character limits?

CREATE TABLE students 
(
    username CHAR(5), 
    fullName VARCHAR(100), 
    email VARCHAR(255)
);
CREATE TABLE students 
(
    username CHAR, 
    fullName VARCHAR, 
    email VARCHAR
);

Answer:

CREATE TABLE students 
(
    username CHAR(5), 
    fullName VARCHAR(100), 
    email VARCHAR(255)
);

These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. You are sourcing feedback from students on college services. Each student can provide up to 10000 characters worth of feedback in an online form, which will then be stored in a database. Identify the correct SQL syntax to create the “Feedback” column.

  • article CHAR(10000)
  • article TEXT(10000)

Answer: article TEXT(10000)


Q4. TINYTEXT is a string data type used to define columns with small letter characters only.

  • False
  • True

Answer: False


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Self review: Working with default values

Q1. A soccer club in London wants to create a table within their database to hold data on each player. Since most of the players are from London, the club can set “London” as the default value in the “City” column. Can you identify the correct SQL syntax to set London as the default value for this column?

  • City DEFAULT VARCHAR(30) “London”;
  • City VARCHAR(30) DEFAULT “London”;

Answer: City VARCHAR(30) DEFAULT “London”;


Q2. The skill level of all new players within a soccer club must automatically be set at Level 1. Can you identify the correct SQL syntax to set each new player’s skill level using the DEFAULT keyword?

  • level INT DEFAULT 1;
  • DEFAULT level INT 1;

Answer: level INT DEFAULT 1;


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. The following SQL statement creates a table in a soccer club database called “Players”. It also adds two default values to the table: club with a default value of “Newport FC”, and city with default value of “Newport”.

CREATE TABLE Players 
(
    playerName VARCHAR(50), 
    club VARCHAR (10) 
    DEFAULT "Newport FC", city 
    VARCHAR (100) DEFAULT "Newport"
);
  • False
  • True

Answer: True


Q4. Database default constraints are used to limit the value of data that can be stored in a table.

  • True
  • False

Answer: True


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q5. You are creating a new members table in the sports club database. The table must have two columns with the following default values: city ‘London’ and gender ‘female’. How many instances of the DEFAULT keyword does your SQL statement require?

  • Two DEFAULT keywords.
  • One DEFAULT keyword.

Answer: Two DEFAULT keywords.


Self review: Choosing the right data type for a column

Q1. A soccer club’s database includes a “Players” table. The table contains a “Player number” column that records the jersey number of each player in the team. Each jersey number is a whole number. Identify the correct data type for this column.

  • DECIMAL
  • TINYINT

Answer: TINYINT


Q2. In a sports club database, the “Players” table includes a date of birth column that records the date of birth for each player. The right SQL data type to define the player date of birth is DOB VARCHAR(100).

  • True
  • False

Answer: False


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. Which one of the following SQL statements makes use of the correct data types to create a “Players” table in a soccer club’s database?

CREATE TABLE players 
(
    playerNumber INT, 
    fullName VARCHAR(100), 
    date_of_birth CHAR
);
CREATE TABLE players 
(
    playerNumber Decimal, 
    fullName VARCHAR(100), 
    date_of_birth DATE
);
CREATE TABLE players 
(
    playerNumber INT, 
    fullName VARCHAR(100), 
    date_of_birth DATE
);

Answer:

CREATE TABLE players 
(
    playerNumber INT, 
    fullName VARCHAR(100), 
    date_of_birth DATE
);

Q4. A soccer club’s database includes a staff table with three columns: username, full name and title. The username contains alphanumeric values such as: “Staff001” and has a fixed length of eight characters. Select the right SQL syntax.

  • username CHAR(8)
  • username VARCHAR(8)

Answer: username CHAR(8)


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q5. The following SQL statement can be used to create a table called “Players”, with a default value of “Miami” for the city column.

CREATE TABLE players 
(
    playerName VARCHAR(100), 
    city VARCHAR(50) 
    DEFAULT “Miami”, age INT
);
  • False
  • True

Answer: True


Self-review: Create database, create table and insert data

Q1. The following SQL statement can be used to create a database for a bookshop:
CREATE bookshop DATABASE;

  • True
  • False

Answer: False


Q2. The following SQL statement can be used to create a “Customers” table in a bookshop database:
CREATE TABLE customers 
(
    customerName VARCHAR(100), 
    customerAddress VARCHAR(100)
);

  • False
  • True

Answer: True


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. Identify the correct SQL command to insert a new record of data in a table.

  • INSERT INTO
  • INSERT INTO SELECT

Answer: INSERT INTO


Q4. Which of the following SQL statements can you use to insert a record for a customer named “Karl”, aged 21 into a table called “Customers”?

INSERT name, age 
INTO customer table values "Karl" "21";
INSERT customer 
SET name = "Karl" and age = 21;
INSERT INTO customer (name, age) 
VALUES ("Karl", 21);

Answer:

INSERT INTO customer (name, age) 
VALUES ("Karl", 21);

These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q5. Identify the missing keyword in the following SQL statement. INSERT INTO customers (ID, name) __ (7, “Tom”);

  • INSERT INTO customers (ID, name) WHERE (7, “Tom”);
  • INSERT INTO customers (ID, name) VALUES (7, “Tom”);

Answer: INSERT INTO customers (ID, name) VALUES (7, “Tom”);


Self review: Practicing table creation

Q1. Which of the following SQL syntax statements can you use to create a table? Select all that apply.

  • create table table_name;
  • CREATE table_name TABLE;
  • CREATE TABLE table name;
  • CREATE TABLE table_name;

Answer: create table table_name;
CREATE TABLE table_name;


Q2. Select all steps to create a table in the database.

  • Use the FROM keyword.
  • Select a database.
  • Define the columns of the table with relevant data types.
  • Use the CREATE TABLE command.
  • Write the table name.

Answer: Select a database.
Define the columns of the table with relevant data types.
Use the CREATE TABLE command.
Write the table name.


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. Identify which of the following SQL statements can be used to create a table called “Products” for an online store. The table must contain two columns named “ID” and “Quantity.” The values within both columns must be whole numbers.

  • CREATE TABLE products (ID CHAR, quantity VARCHAR);
  • CREATE TABLE products (ID INT, quantity INT);

Answer: CREATE TABLE products (ID INT, quantity INT);


Q4. Which of the following SQL statements can be used to build a table that stores data about cell phone products?

CREATE TABLE cell_phone 
(
    name VARCHAR(100),
    productionDate DATE,
    price DECIMAL
);
CREATE TABLE cell_phone 
(
    name VARCHAR(), 
    productionDate DATE, 
    price DECIMAL);

Answer:

CREATE TABLE cell_phone 
(
    name VARCHAR(100),
    productionDate DATE,
    price DECIMAL
);

These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q5. You need to create a table called “Players”. The table must contain two columns. The first column is called “playername” and holds the names of each player as a text data type. The second column is called “playerAge” and contains the age of each player as a whole number value. Identify the correct syntax to create this table.

CREATE TABLE Players 
(
    playerName VARCHAR(100), 
    playerAge DECIMAL
);
CREATE TABLE Players 
(
    playerName VARCHAR(100), 
    playerAge INT
);

Answer:

CREATE TABLE Players 
(
    playerName VARCHAR(100), 
    playerAge INT
);

Knowledge check: Create, insert and select

Q1. The following SQL statement contains the syntax to create a product table with two columns ID and price:
CREATE TABLE product_table (ID, price);

  • False
  • True

Answer: False


Q2. You need to create a table for bank account records in a financial database. Which of the following SQL statements can you use to complete this task?

  • CREATE TABLE bank_account (account_number INT, balance DECIMAL);
  • CREATE ENTITY bank_account (account_number INT, balance DECIMAL);

Answer: CREATE TABLE bank_account (account_number INT, balance DECIMAL);


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. Select the right SQL statement to insert a new record of data into three columns of a table called “Games” with the following values:
GameID = 1, gameDate = 2022-10-10 and score = 3

  • INSERT INTO games (GameID, gameDate, score) VALUES (1, “2022-10-10”, 3);
  • INSERT INTO games (GameID, gameDate, score) CONSTRAINT (1, “2022-10-10”, 3);

Answer: INSERT INTO games (GameID, gameDate, score) VALUES (1, “2022-10-10”, 3);


Q4. A player with ID = 5, name = “Tina” and age = 23 must be added to the “Players” table for a soccer club database. Select the right SQL syntax to insert the player data into the table.

  • INSERT INTO Players (ID, name, age) VALUES (5, “Tina”, 23);
  • INSERT INTO TABLE Players (ID, name, age) VALUES (5, “Tina”, 23);

Answer: INSERT INTO Players (ID, name, age) VALUES (5, “Tina”, 23);


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q5. A hockey team requires all available data on their players for an upcoming meeting. Choose the correct SQL statement to select all data available in the players’ table

  • SELECT * players;
  • SELECT * FROM players;

Answer: SELECT * FROM players;


Self-review: Record deletion

Q1. The correct command to remove a record from a table is: DROP FROM

  • True
  • False

Answer: False


Q2. You can delete all records of data from a table without deleting the table itself using the SQL command DELETE FROM.

  • False
  • True

Answer: True


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. You can delete the record of the player assigned the number seven from the table “Players” using the following SQL syntax:
DELETE FROM players
WHERE playerNumber = seven;

  • True
  • False

Answer: False


Q4. You can delete all records from a table called “Players” where the value of City is equal to “London” using the following SQL syntax:
DELETE FROM players
WHERE city = “London”;

  • False
  • True

Answer: True


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Knowledge check: Update and Delete

Q1. Which of the following statements is the correct command syntax to update a table in SQL?

  • UPDATE table_name;
  • UPDATE column;
  • UPDATE Table table_name;

Answer: UPDATE table_name;


Q2. What is the missing SQL keyword in the following SQL statement to update the customer’s table?
UPDATE Customers
_ ContactName = ‘Jack Molly’
WHERE CustomerID = 10;

  • ANY
  • SET

Answer: SET


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. Which of the following SQL statements can be used to update data for a student in the “Students” table?

  • UPDATE students SET name = ‘Karl’ AND ID = 18;
  • UPDATE students SET name = ‘Karl’ WHERE ID = 18;
  • UPDATE students WHERE ID = 18 SET name = ‘Karl’;

Answer: UPDATE students SET name = ‘Karl’ WHERE ID = 18;


Q4. The following table contains data about customers. The customer data should be removed completely, but without deleting the table. Identify which statement can be used to delete all records of data from the customers table without deleting the table itself.

  • DROP TABLE customers
  • DELETE FROM customers;

Answer: DELETE FROM customers;


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q5. The ‘WHERE’ keyword is used in SQL to specify a condition to update or delete data from a table.

  • False
  • True

Answer: True


Module quiz: Create, Read, Update and Delete (CRUD) Operations

Q1. The following SQL clause creates a table named staff within a database:
CREATE staff TABLE;

  • True
  • False

Answer: False


Q2. The following SQL statement creates a table named staff, with two columns called name and address:
CREATE TABLE staff (name VARCHAR(100), address VARCHAR(100));

  • False
  • True

Answer: True


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q3. What is the SQL command to add a new record of data in the staff table?

  • ADD INTO staff;
  • INSERT staff INTO;
  • INSERT INTO staff;

Answer: INSERT INTO staff;


Q4. Which is the right command syntax to update the staff table in SQL?

  • UPDATE Table staff;
  • UPDATE staff;

Answer: UPDATE staff;


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q5. EDIT command is used to modify data in a database table.

  • False
  • True

Answer: False


Q6. Which one of the following SQL statements updates the staff email address for the individual named “Karl” in the staff table?

Answer: UPDATE staff SET email = ‘[email protected]’ WHERE name = ‘Karl’;


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q7. Select the right keyword to complete the missing part of the following statement:
INSERT INTO staff (ID, name) ___ (7, “Tom”);

  • VALUES
  • DATA

Answer: VALUES


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q8. A staff table consists of three columns called name, email and age. Which of the following SQL statements selects all available data in all three columns in the staff table?

  • SELECT name, email AND age FROM staff;
  • SELECT * FROM staff;
  • SELECT name, email, age FROM staff;

Answer: SELECT * FROM staff;
SELECT name, email, age FROM staff;


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q9. The following SQL statement returns all staff phone numbers from the staff table:
SELECT phoneNumber FROM staff;

  • False
  • True

Answer: True


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera


Q10. Which of the following SQL statements deletes all records of data from the staff table without deleting the table itself?

  • TRUNCATE TABLE staff;
  • DROP TABLE staff;
  • DELETE FROM staff;

Answer: TRUNCATE TABLE staff;
DELETE FROM staff;


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera

More Weeks of this course: Click Here

More Coursera Courses: http://progiez.com/coursera


These are answers of Introduction to Databases Week 2 Quiz Answers Coursera
The content uploaded on this website is for reference purposes only. Please do it yourself first.