C170 Data Management Chapter 2.2Questions
with 100% Verified Correct Answers
character
string
CHAR(N)
CHAR(N)N bytes
Fixed-length string of length N; 0 ≤ N ≤ 255VARCHAR(N)Length of characters + 1
bytesVariable-length string with maximum N characters; 0 ≤ N ≤ 65,535
VARCHAR
VARCHAR(N)
Length of characters + 1 bytes
Variable-length string with maximum N characters; 0 ≤ N ≤ 65,535
Storing a city's population, which ranges from a dozen to 24 million people.
unsigned MEDIUMINT
unsigned INTEGER
unsigned BIGINT
An INTEGER requires 4 bytes and is sufficient to represent populations that are up to 4.3
billion people. The next smallest data type, MEDIUMINT, can only represent populations up
to 16.8 million.
Storing the annual gain or loss in a city's population, which ranges from -1 million to 1
million.
signed SMALLINT
,unsigned MEDIUMINT
signed MEDIUMINT
A signed MEDIUMINT requires 3 bytes and can store -8,388,608 to 8,388,607.
Storing the price of an item that ranges from a few dollars to a few hundred dollars.
FLOAT
DECIMAL(2,5)
DECIMAL(5,2)
M = 5 and N = 2, so the number of significant digits is 5, and the number of places after the
decimal point is 2. A price like $599.27 has 5 significant digits and 2 numbers after the
decimal point.
Storing the date and time an item is purchased.
DATE
TIME
DATETIME
DATETIME stores both a date and a time. Ex: If an item is purchased on July 4, 2020 at 2:30
pm, the value stored in DATETIME is '2020-07-04 14:30:00'.
Storing a student's assigned letter grade, like A or D.
TINYINT
CHAR(1)
VARCHAR(1)
CHAR
A grade is a single character, and N = 1 uses 1 byte to store each grade.
, Storing a student's email address.
VARCHAR(100)
VARCHAR(10)
CHAR(100)
Each student's email address varies in length, so a VARCHAR is ideal. Using N = 100 means
no email address can exceed 100 characters, which is a reasonable assumption.
Storing a yes or no value.
TINYINT
CHAR(3)
VARCHAR(3)
Typically, a yes/no or true/false value is stored as a 1-byte TINYINT, where 1 means
yes/true, and 0 means no/false. A common term that refers to yes/no is Boolean.
create table
The CREATE TABLE statement creates a new table by specifying the table name, column
names, and column data types.
DROP TABLE
The DROP TABLE statement deletes a table, along with all the table's rows, from a database.
Ex: DROP TABLE Employee; deletes the Employee table.
The Employee table is created with 4 columns.
True
False
the columns are: ID, Name, BirthDate, and Salary.
with 100% Verified Correct Answers
character
string
CHAR(N)
CHAR(N)N bytes
Fixed-length string of length N; 0 ≤ N ≤ 255VARCHAR(N)Length of characters + 1
bytesVariable-length string with maximum N characters; 0 ≤ N ≤ 65,535
VARCHAR
VARCHAR(N)
Length of characters + 1 bytes
Variable-length string with maximum N characters; 0 ≤ N ≤ 65,535
Storing a city's population, which ranges from a dozen to 24 million people.
unsigned MEDIUMINT
unsigned INTEGER
unsigned BIGINT
An INTEGER requires 4 bytes and is sufficient to represent populations that are up to 4.3
billion people. The next smallest data type, MEDIUMINT, can only represent populations up
to 16.8 million.
Storing the annual gain or loss in a city's population, which ranges from -1 million to 1
million.
signed SMALLINT
,unsigned MEDIUMINT
signed MEDIUMINT
A signed MEDIUMINT requires 3 bytes and can store -8,388,608 to 8,388,607.
Storing the price of an item that ranges from a few dollars to a few hundred dollars.
FLOAT
DECIMAL(2,5)
DECIMAL(5,2)
M = 5 and N = 2, so the number of significant digits is 5, and the number of places after the
decimal point is 2. A price like $599.27 has 5 significant digits and 2 numbers after the
decimal point.
Storing the date and time an item is purchased.
DATE
TIME
DATETIME
DATETIME stores both a date and a time. Ex: If an item is purchased on July 4, 2020 at 2:30
pm, the value stored in DATETIME is '2020-07-04 14:30:00'.
Storing a student's assigned letter grade, like A or D.
TINYINT
CHAR(1)
VARCHAR(1)
CHAR
A grade is a single character, and N = 1 uses 1 byte to store each grade.
, Storing a student's email address.
VARCHAR(100)
VARCHAR(10)
CHAR(100)
Each student's email address varies in length, so a VARCHAR is ideal. Using N = 100 means
no email address can exceed 100 characters, which is a reasonable assumption.
Storing a yes or no value.
TINYINT
CHAR(3)
VARCHAR(3)
Typically, a yes/no or true/false value is stored as a 1-byte TINYINT, where 1 means
yes/true, and 0 means no/false. A common term that refers to yes/no is Boolean.
create table
The CREATE TABLE statement creates a new table by specifying the table name, column
names, and column data types.
DROP TABLE
The DROP TABLE statement deletes a table, along with all the table's rows, from a database.
Ex: DROP TABLE Employee; deletes the Employee table.
The Employee table is created with 4 columns.
True
False
the columns are: ID, Name, BirthDate, and Salary.