SQL Basics for Beginners
- 65Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
Which description best captures what data is and why it is useful?
Which description best captures what data is and why it is useful?
65 questions
- 1
Which description best captures what data is and why it is useful?
- A
Data is a dedicated location for storing information.
- B
Data is a command used to retrieve records from a table.
- C
Data is a collection of decisions already made by a business.
- D
Data consists of facts about something that can be examined for insight.
Correct answer
DData consists of facts about something that can be examined for insight.
Explanation
Data consists of facts about something. Examining those facts can reveal insights that support better decisions.
- A
- 2
What is a database, according to the content?
- A
A database is a query that selects records from several tables.
- B
A database is a key that uniquely identifies a single record.
- C
A database is a dedicated storage location where data can be managed and processed.
- D
A database is a report that displays only summarized business results.
Correct answer
CA database is a dedicated storage location where data can be managed and processed.
Explanation
A database is a dedicated place to store data and supports its management, manipulation, analysis, and processing.
- A
- 3
How can analyzing customer attributes such as age, income, and buying habits help a business?
- A
Businesses use data only to identify the names of their customers.
- B
Businesses store data mainly to avoid making decisions about products.
- C
Businesses analyze data so that databases can create profits without human decisions.
- D
Businesses analyze data to gain insights that can improve decisions and efficiency.
Correct answer
DBusinesses analyze data to gain insights that can improve decisions and efficiency.
Explanation
Businesses can use data-derived insights to improve decisions, profits, and efficiency.
- A
- 4
What is SQL?
- A
SQL is a database that automatically stores every type of business data.
- B
SQL is a key that connects a parent table to a child table.
- C
SQL is a table format used to arrange customer records in rows.
- D
SQL is a query language used to communicate with databases and act on data.
Correct answer
DSQL is a query language used to communicate with databases and act on data.
Explanation
SQL is a query language used to communicate with databases, retrieve data, and perform actions on it.
- A
- 5
What happens when a statement such as
SELECT name FROM customersis sent to a database?- A
The database converts each query into a new table and deletes the original data.
- B
The database processes the query and returns a result, such as the requested names.
- C
The database changes every matching record before returning any result.
- D
The database sends the query to each record, which independently produces a report.
Correct answer
BThe database processes the query and returns a result, such as the requested names.
Explanation
A query is sent to the database system, which processes it and returns the requested output.
- A
- 6
Why is SQL useful in business intelligence work?
- A
SQL is widely used to query and manipulate data, including in business intelligence work.
- B
SQL is mainly a method for designing hardware that stores business information.
- C
SQL is useful only for creating customer-facing websites and is rarely used with databases.
- D
SQL is used only to describe relationships between tables, not to retrieve their data.
Correct answer
ASQL is widely used to query and manipulate data, including in business intelligence work.
Explanation
SQL is used to retrieve and manipulate data and is widely used with relational databases and business intelligence tools.
- A
- 7
In a table, what do rows and columns represent?
- A
Rows represent records, while columns represent attributes describing those records.
- B
Rows represent attributes, while columns represent complete records.
- C
Rows represent databases, while columns represent relationships between databases.
- D
Rows represent keys, while columns represent constraints on the table.
Correct answer
ARows represent records, while columns represent attributes describing those records.
Explanation
The content describes rows as records and columns as attributes that describe those records.
- A
- 8
What role does a field or column play in a table?
- A
A field is a command that removes all records but preserves a table.
- B
A field is a relationship between a parent table and a child table.
- C
A field is a location for stored attributes, such as a column for age or city.
- D
A field is a complete record, while an attribute is a database name.
Correct answer
CA field is a location for stored attributes, such as a column for age or city.
Explanation
A field is the location where an attribute is stored; columns hold attributes such as name, age, or address.
- A
- 9
Which statement best describes a table in a relational database?
- A
A table is a collection of unrelated databases with different structures.
- B
A table is a structured set of records with a consistent set of typed attributes.
- C
A table is a command that specifies the permissions for a database user.
- D
A table is a query result that must contain only one row.
Correct answer
BA table is a structured set of records with a consistent set of typed attributes.
Explanation
A table is described as a structured set of data whose columns have consistent types and whose records are stored in rows.
- A
- 10
What is the main purpose of a primary key?
- A
A primary key stores a description shared by every record.
- B
A primary key uniquely identifies a record in its table.
- C
A primary key specifies the maximum character length for a column.
- D
A primary key indicates whether a relationship between tables is optional.
Correct answer
BA primary key uniquely identifies a record in its table.
Explanation
The content presents a primary key as a unique identifier for each record, such as an ID.
- A
- 11
Which property of a primary key lets it distinguish one record from another?
- A
A primary key must contain the name of a related table.
- B
A primary key is allowed to identify several records at once.
- C
A primary key value cannot be duplicated among records in the table.
- D
A primary key value must be identical in every record in the table.
Correct answer
CA primary key value cannot be duplicated among records in the table.
Explanation
A primary key must be unique to each record, so it cannot be duplicated.
- A
- 12
How does a foreign key connect two related tables?
- A
A foreign key in a child table refers to a key in the parent table.
- B
A foreign key uniquely identifies every database in the system.
- C
A foreign key replaces the primary key in the parent table.
- D
A foreign key stores the attributes that are missing from the parent table.
Correct answer
AA foreign key in a child table refers to a key in the parent table.
Explanation
A foreign key in the child table refers to a primary key in the parent table, linking the records.
- A
- 13
What does a
NOT NULLconstraint require?- A
NOT NULLrequires that a column have a value rather than be left empty. - B
NOT NULLallows a column to contain only text values. - C
NOT NULLprevents a table from receiving any additional records. - D
NOT NULLrequires that every row contain the value zero.
Correct answer
ANOT NULLrequires that a column have a value rather than be left empty.Explanation
NOT NULLprevents a column from being left empty when a record is entered. - A
- 14
In the example table definition, which type pairing is appropriate for age and name?
- A
Use a null type for age and a database type for a name.
- B
Use an integer type for age and a variable-character type for a name.
- C
Use a primary-key type for a name and a foreign-key type for an age.
- D
Use an integer type for a name and a variable-character type for an age.
Correct answer
BUse an integer type for age and a variable-character type for a name.
Explanation
The example uses an integer type for values such as age and a variable-character type for string values such as a name.
- A
- 15
In the example, what does specifying
VARCHAR(30)for a name indicate?- A
VARCHAR(30)specifies that a field must contain exactly 30 rows. - B
VARCHAR(30)specifies a fixed primary key with 30 unique values. - C
VARCHAR(30)specifies an integer field that can store 30 records. - D
VARCHAR(30)specifies a variable-character field with a capacity of 30 characters.
Correct answer
DVARCHAR(30)specifies a variable-character field with a capacity of 30 characters.Explanation
The example defines a name as
VARCHAR(30), using 30 as the specified character capacity. - A
- 16
How does the example arrange for customer IDs to be generated automatically and identify records?
- A
Make the name column auto-increment so it can identify each row.
- B
Define an integer ID as a primary key and set it to auto-increment.
- C
Make the age column a foreign key so its values increase automatically.
- D
Make the city column the primary key and leave the ID unspecified.
Correct answer
BDefine an integer ID as a primary key and set it to auto-increment.
Explanation
The example combines an integer ID,
NOT NULL, auto-increment, and a primary-key declaration to make IDs automatically increase and identify records. - A
- 17
What does a relationship between database tables represent?
- A
A relationship represents a connection between tables in a database.
- B
A relationship is a way to store all tables as one column.
- C
A relationship is a rule that makes every column contain a unique value.
- D
A relationship is a command that orders records by a selected column.
Correct answer
AA relationship represents a connection between tables in a database.
Explanation
A relationship describes a connection between tables, such as a customer table connected to a product table.
- A
- 18
In the customer-and-product example, which table is treated as the parent?
- A
The table with fewer records is always the parent, regardless of the relationship.
- B
The product table is the parent, and the customer table is the child in the example.
- C
Both the customer and product tables must be child tables.
- D
The customer table is the parent, and the product table is the child in the example.
Correct answer
DThe customer table is the parent, and the product table is the child in the example.
Explanation
In the example, the customer table is treated as the parent and the product table as the child.
- A
- 19
How does the example use keys to represent a parent-child relationship?
- A
The parent table's primary key can appear as a foreign-key column in the child table.
- B
The child table's primary key must replace every column in the parent table.
- C
The parent table's foreign key must be copied into every database.
- D
The child table's columns are combined into the parent table's primary key.
Correct answer
AThe parent table's primary key can appear as a foreign-key column in the child table.
Explanation
The parent table's primary key is placed as a column in the child table, where it acts as a foreign key.
- A
- 20
What does ordinality describe in a relationship between tables?
- A
Ordinality indicates the order in which a query returns records.
- B
Ordinality indicates whether a parent-child relationship is optional or required.
- C
Ordinality indicates whether a key is an integer or a string.
- D
Ordinality indicates how many columns are present in a table.
Correct answer
BOrdinality indicates whether a parent-child relationship is optional or required.
Explanation
Ordinality indicates whether the relationship between a parent and child is optional or required.
- A
- 21
In the relationship notation described, what do zero and a perpendicular line indicate?
- A
Zero indicates a many-to-many relationship, while a perpendicular line indicates one-to-one.
- B
Zero indicates a parent table, while a perpendicular line indicates a child table.
- C
Zero indicates a required relationship, while a perpendicular line indicates an optional one.
- D
Zero indicates an optional relationship, while a perpendicular line indicates a required one.
Correct answer
DZero indicates an optional relationship, while a perpendicular line indicates a required one.
Explanation
The content explains that zero marks an optional relationship, whereas a perpendicular line indicates that the relationship is required.
- A
- 22
Which example illustrates an optional relationship?
- A
A book must have an owner, but it need not have been written by anyone.
- B
A book may have no author, although it must have several owners.
- C
A book must have both an owner and a reader at all times.
- D
A book may have no owner, although it must have been written by someone.
Correct answer
DA book may have no owner, although it must have been written by someone.
Explanation
The book-and-owner example shows that a book's relationship to an owner may be optional, while someone must have written the book.
- A
- 23
What does cardinality describe?
- A
Cardinality describes how many commands are available in SQL.
- B
Cardinality describes whether a relationship is optional or required.
- C
Cardinality describes patterns such as one-to-one, one-to-many, and many-to-many.
- D
Cardinality describes whether a database stores text or integer values.
Correct answer
CCardinality describes patterns such as one-to-one, one-to-many, and many-to-many.
Explanation
Cardinality describes the number pattern of a child table's relationship to its parent, such as one-to-one, one-to-many, or many-to-many.
- A
- 24
What is the general purpose of data definition language (DDL)?
- A
DDL is used to save or undo a transaction.
- B
DDL is used to define database structures such as tables and databases.
- C
DDL is used to assign or withdraw access privileges from users.
- D
DDL is used mainly to retrieve selected rows from an existing table.
Correct answer
BDDL is used to define database structures such as tables and databases.
Explanation
DDL is used to define database structures such as databases and tables.
- A
- 25
Which command is used to create a database or table?
- A
CREATEcreates a database or table. - B
DROPcreates a new database or table. - C
ALTERcreates a new database or table. - D
TRUNCATEcreates a new database or table.
Correct answer
ACREATEcreates a database or table.Explanation
The content identifies
CREATEas the command used to create a database or table. - A
- 26
What is the distinction between
DROPandTRUNCATEdescribed in the content?- A
DROPremoves the table itself, whileTRUNCATEremoves its records but preserves the table. - B
DROPinserts records, whileTRUNCATEupdates selected records. - C
DROPchanges a column, whileTRUNCATEcreates a replacement table. - D
DROPremoves records only, whileTRUNCATEremoves the table structure.
Correct answer
ADROPremoves the table itself, whileTRUNCATEremoves its records but preserves the table.Explanation
DROPremoves the table or database itself, whileTRUNCATEremoves its records but preserves the table structure. - A
- 27
Which command is identified as being used to alter a table?
- A
ALTERundoes the most recent transaction. - B
ALTERgrants a user permission to access a database. - C
ALTERretrieves every row from a table. - D
ALTERchanges a table or its structure.
Correct answer
DALTERchanges a table or its structure.Explanation
ALTERis presented as a command for changing a table or its structure. - A
- 28
According to the content, what is the comment command used for?
- A
It adds comments to a data dictionary.
- B
It removes every record from a table.
- C
It assigns access privileges to a database user.
- D
It returns the average value of a column.
Correct answer
AIt adds comments to a data dictionary.
Explanation
The content identifies the comment command as a way to add comments to a data dictionary.
- A
- 29
What is the general purpose of data manipulation language (DML)?
- A
DML is used only to grant and revoke user permissions.
- B
DML is used to manipulate data in database tables.
- C
DML is used only to specify transaction characteristics.
- D
DML is used only to define the structure of a database.
Correct answer
BDML is used to manipulate data in database tables.
Explanation
DML is described as the language group used to manipulate data, including inserting, updating, and deleting records.
- A
- 30
Which command is used to add values to a table?
- A
INSERT INTOorders a table by one of its columns. - B
INSERT INTOremoves a selected record from a table. - C
INSERT INTOgives a user access to a database. - D
INSERT INTOadds values to a table.
Correct answer
DINSERT INTOadds values to a table.Explanation
INSERT INTOis used to add values or records to a table. - A
- 31
How do
UPDATEandDELETEdiffer?- A
UPDATEcreates a database, whileDELETEcreates a table. - B
UPDATEremoves a table, whileDELETEchanges its column definitions. - C
UPDATEchanges existing values, whileDELETEremoves records. - D
UPDATEgrants permissions, whileDELETErevokes permissions.
Correct answer
CUPDATEchanges existing values, whileDELETEremoves records.Explanation
UPDATEchanges values in existing records, whileDELETEremoves records. - A
- 32
What does
SELECT * FROM table_namerequest?- A
SELECTqueries data, andSELECT *requests all columns from the table. - B
SELECTdefines a table, andSELECT *requests only its primary key. - C
SELECTsets a transaction point, andSELECT *commits the transaction. - D
SELECTremoves data, andSELECT *removes every row in the table.
Correct answer
ASELECTqueries data, andSELECT *requests all columns from the table.Explanation
SELECTis used to query data, andSELECT *requests all columns from the specified table. - A
- 33
Which statement about data control language (DCL) matches the content?
- A
DCL includes
INSERTandDELETE, which modify table records. - B
DCL includes
CREATEandDROP, which define and remove tables. - C
DCL includes
COMMITandROLLBACK, which manage transactions. - D
DCL includes
GRANTandREVOKE, which give and withdraw user privileges.
Correct answer
DDCL includes
GRANTandREVOKE, which give and withdraw user privileges.Explanation
DCL includes
GRANTandREVOKE, which give and withdraw user access privileges. - A
- 34
Which set of commands belongs to transaction control language (TCL)?
- A
TCL includes commands for creating and removing database tables.
- B
TCL includes commands for granting and withdrawing user privileges.
- C
TCL includes commands for selecting columns and filtering records.
- D
TCL includes commands for committing, rolling back, and saving transaction points.
Correct answer
DTCL includes commands for committing, rolling back, and saving transaction points.
Explanation
TCL includes commands such as
COMMIT,ROLLBACK, andSAVEPOINTfor managing transactions. - A
- 35
How do
COMMITandROLLBACKdiffer in transaction control?- A
COMMITgrants access, whileROLLBACKremoves a user's privileges. - B
COMMITsaves changes, whileROLLBACKundoes changes back to the previous commit. - C
COMMITdeletes a table, whileROLLBACKrecreates its columns. - D
COMMITselects records, whileROLLBACKorders them by a column.
Correct answer
BCOMMITsaves changes, whileROLLBACKundoes changes back to the previous commit.Explanation
The content describes
COMMITas saving transaction changes andROLLBACKas returning to the previous commit after an error. - A
- 36
What functions do
SAVEPOINTandSET TRANSACTIONserve?- A
SAVEPOINTmarks a point in a transaction, andSET TRANSACTIONspecifies its characteristics. - B
SAVEPOINTcreates a database, andSET TRANSACTIONtruncates its tables. - C
SAVEPOINTgrants user privileges, andSET TRANSACTIONrevokes them. - D
SAVEPOINTpermanently removes a transaction, andSET TRANSACTIONselects table columns.
Correct answer
ASAVEPOINTmarks a point in a transaction, andSET TRANSACTIONspecifies its characteristics.Explanation
A
SAVEPOINTmarks a point in a transaction, andSET TRANSACTIONspecifies transaction characteristics. - A
- 37
What does CRUD stand for?
- A
CRUD stands for create, read, update, and delete.
- B
CRUD stands for create, revise, undo, and deploy.
- C
CRUD stands for control, read, update, and describe.
- D
CRUD stands for connect, retrieve, use, and define.
Correct answer
ACRUD stands for create, read, update, and delete.
Explanation
CRUD stands for create, read, update, and delete—the basic operations that can be performed on data.
- A
- 38
How do
SHOW DATABASESandUSEdiffer in the setup example?- A
SHOW DATABASEScreates a database, andUSEremoves it. - B
SHOW DATABASESlists databases, andUSEselects one to work with. - C
SHOW DATABASESselects a database, andUSElists the tables in it. - D
SHOW DATABASESdisplays rows, andUSEupdates them.
Correct answer
BSHOW DATABASESlists databases, andUSEselects one to work with.Explanation
SHOW DATABASESdisplays available databases, andUSE database_nameselects one as the active database. - A
- 39
Which sequence matches the database setup demonstrated?
- A
Create the tables first, then use
DROPto add them to a database. - B
Create the database, then use it before creating tables inside it.
- C
Insert records first, then use
CREATE DATABASEto store them. - D
Use the database name to create a table, then truncate the database.
Correct answer
BCreate the database, then use it before creating tables inside it.
Explanation
The example creates a database with
CREATE DATABASEand then selects it withUSEbefore creating tables inside it. - A
- 40
Which command is used in the example to define a table?
- A
USE TABLEdefines a new table and its columns. - B
SHOW TABLESdefines a new table and its attributes. - C
INSERT INTOdefines a new table and its attributes. - D
CREATE TABLEdefines a new table and its attributes.
Correct answer
DCREATE TABLEdefines a new table and its attributes.Explanation
The example uses
CREATE TABLEto define a table and its attributes. - A
- 41
Why is
AUTO_INCREMENTused for an ID column in the example?- A
AUTO_INCREMENTprevents new records from being inserted into the table. - B
AUTO_INCREMENTautomatically increases the ID value for new records. - C
AUTO_INCREMENTcopies the same ID into every new record. - D
AUTO_INCREMENTgenerates a random city value for each record.
Correct answer
BAUTO_INCREMENTautomatically increases the ID value for new records.Explanation
AUTO_INCREMENTgenerates increasing ID values as new records are inserted, avoiding the need to enter each ID manually. - A
- 42
What punctuation marks the end of a query in the demonstrated MySQL interaction?
- A
A comma marks the end of every SQL query in the example.
- B
A quotation mark marks the end of every SQL query in the example.
- C
A semicolon marks the end of a query in the example.
- D
A closing parenthesis marks the end of every SQL query in the example.
Correct answer
CA semicolon marks the end of a query in the example.
Explanation
In the demonstrated MySQL interaction, a semicolon marks the end of a query.
- A
- 43
How does the demonstrated
INSERT INTOstatement specify where new values belong?- A
Name the rows to remove, then provide replacement column definitions.
- B
Name a database and its keys, then provide a query result as a constraint.
- C
Name the target table and columns, then provide values for those columns.
- D
Name the user and permissions, then provide the table's transaction history.
Correct answer
CName the target table and columns, then provide values for those columns.
Explanation
The
INSERT INTOexample names the table and the columns that will receive values, then supplies corresponding values. - A
- 44
How are string and integer values entered in the demonstrated insert example?
- A
Put string values in quotation marks and enter integer values as numbers.
- B
Put both strings and integers in quotation marks in every case.
- C
Enter both strings and integers without quotation marks in every case.
- D
Put integer values in quotation marks and enter strings without quotation marks.
Correct answer
APut string values in quotation marks and enter integer values as numbers.
Explanation
The example puts string values such as names and cities in quotation marks, while integer values are entered as numbers.
- A
- 45
Which command is used in the example to check which tables have been created?
- A
SHOW TABLESlists the tables in the selected database. - B
SHOW DATABASESdisplays the records inside the currently selected table. - C
SELECT TABLESchecks whether a new column has been created. - D
USE TABLESdisplays all databases on the server.
Correct answer
ASHOW TABLESlists the tables in the selected database.Explanation
SHOW TABLESis used after table creation to check which tables exist in the selected database. - A
- 46
How does selecting
*differ from selecting specific column names?- A
SELECT *deletes all columns, while named columns recreate selected ones. - B
SELECT *requests all rows from all tables, while named columns request one row. - C
SELECT *requests only the primary key, while named columns request every column. - D
SELECT *requests all columns, while named columns restrict the returned columns.
Correct answer
DSELECT *requests all columns, while named columns restrict the returned columns.Explanation
SELECT *requests all columns, while a list such asSELECT name, agerequests only those named columns. - A
- 47
What is the purpose of a
WHEREclause?- A
A
WHEREclause defines the data type of each column. - B
A
WHEREclause filters records to match a condition. - C
A
WHEREclause grants database access to a user. - D
A
WHEREclause adds a new table to the database.
Correct answer
BA
WHEREclause filters records to match a condition.Explanation
A
WHEREclause filters records according to a condition, allowing the query to target specific rows. - A
- 48
What does a condition such as
WHERE city = 'Mumbai'do?- A
It sorts all records alphabetically by city.
- B
It changes the city value in every record to Mumbai.
- C
It selects every record except those whose city is Mumbai.
- D
It selects records whose city value equals Mumbai.
Correct answer
DIt selects records whose city value equals Mumbai.
Explanation
The example
WHERE city = 'Mumbai'selects records whose city value matches Mumbai. - A
- 49
In the example query, what is the effect of using
ANDbetween city and product conditions?- A
ANDreturns records that satisfy either of two conditions. - B
ANDrequires records to satisfy both specified conditions. - C
ANDcombines two columns into a single result column. - D
ANDsorts records by the first condition and ignores the second.
Correct answer
BANDrequires records to satisfy both specified conditions.Explanation
The example combines conditions with
ANDto find records satisfying both the city condition and the product condition. - A
- 50
What does
ORDER BY incomedo when no sort direction is specified?- A
ORDER BY incomecalculates the total income of all records. - B
ORDER BY incomefilters out records that have no income. - C
ORDER BY incomechanges every income value to the same amount. - D
ORDER BY incomesorts records by income, ascending by default.
Correct answer
DORDER BY incomesorts records by income, ascending by default.Explanation
The example uses
ORDER BY incometo sort records by income, and ascending order is the default when no direction is specified. - A
- 51
What does adding
DESCto an ordering request do?- A
DESCcalculates the difference between the largest and smallest values. - B
DESCsorts values from lowest to highest. - C
DESCsorts values from highest to lowest. - D
DESCremoves duplicate values from the results.
Correct answer
CDESCsorts values from highest to lowest.Explanation
The content explains that
DESCorders results in descending order, placing larger values such as higher incomes first. - A
- 52
What does
DISTINCTdo in a query?- A
DISTINCTreturns unique values without repeating duplicates. - B
DISTINCTupdates repeated values to make them identical. - C
DISTINCTreturns every occurrence of each value, including duplicates. - D
DISTINCTsorts values from highest to lowest.
Correct answer
ADISTINCTreturns unique values without repeating duplicates.Explanation
DISTINCTis used to return unique values, such as customer names, without repeating duplicates. - A
- 53
What does
SUM(income)calculate?- A
SUM(income)returns the smallest income value. - B
SUM(income)adds the income values together. - C
SUM(income)returns the average income value. - D
SUM(income)counts the records with an income value.
Correct answer
BSUM(income)adds the income values together.Explanation
The example uses
SUM(income)to calculate the total income for the records included in the query. - A
- 54
What does
AVG(income)return?- A
AVG(income)counts all records in the table. - B
AVG(income)adds all income values without averaging them. - C
AVG(income)returns the largest income value. - D
AVG(income)calculates the average income value.
Correct answer
DAVG(income)calculates the average income value.Explanation
AVG(income)calculates the average of the income values included in the query. - A
- 55
How do
MAXandMINdiffer when applied to a column?- A
MAXfinds the smallest value, whileMINfinds the largest value. - B
MAXremoves duplicates, whileMINorders them. - C
MAXfinds the largest value, whileMINfinds the smallest value. - D
MAXcounts values, whileMINaverages them.
Correct answer
CMAXfinds the largest value, whileMINfinds the smallest value.Explanation
The examples use
MAXto find the largest value andMINto find the smallest value in a column. - A
- 56
Why does the example recommend counting a field that is not null?
- A
COUNTsums field values, so the field should contain only integers. - B
COUNTcounts records through a field, so a non-null field avoids missing-value issues. - C
COUNTsorts records, so the field should contain dates. - D
COUNTreturns unique values, so the field should contain duplicates.
Correct answer
BCOUNTcounts records through a field, so a non-null field avoids missing-value issues.Explanation
The example uses
COUNTto count records through a chosen field and notes that a field that is not null is preferable because null values may not be counted. - A
- 57
What happens when an aggregate query includes a
WHEREcondition on product?- A
A
WHEREclause with an aggregate limits the calculation to records that match its condition. - B
A
WHEREclause with an aggregate applies only after the results are sorted. - C
A
WHEREclause with an aggregate always changes the underlying values. - D
A
WHEREclause with an aggregate prevents the query from returning a result.
Correct answer
AA
WHEREclause with an aggregate limits the calculation to records that match its condition.Explanation
Using
WHEREwith an aggregate, such asSUM(income)for customers who bought a phone, restricts the aggregate to matching records. - A
- 58
Which distinction between
UPDATEandALTERmatches the content?- A
UPDATEchanges record values, whileALTERchanges a table or its structure. - B
UPDATEremoves all records, whileALTERrestores them. - C
UPDATEchanges the table structure, whileALTERchanges selected record values. - D
UPDATEgrants permissions, whileALTERselects records.
Correct answer
AUPDATEchanges record values, whileALTERchanges a table or its structure.Explanation
The content distinguishes
UPDATE, which changes values in selected records, fromALTER, which changes a table or its structure. - A
- 59
How can an
UPDATEstatement target a particular record rather than changing every record?- A
Use
DISTINCTto identify the records whose values should change. - B
Use
CREATE TABLEto identify the records whose values should change. - C
Use a
WHEREcondition to target the records whose values should change. - D
Use
ORDER BYto identify the records whose values should change.
Correct answer
CUse a
WHEREcondition to target the records whose values should change.Explanation
An
UPDATEstatement uses aWHEREcondition to target the records whose values should change. - A
- 60
How does
DELETEdiffer fromTRUNCATEas described in the content?- A
DELETEcan remove records, whileTRUNCATEremoves all records but preserves the table. - B
DELETEchanges selected values, whileTRUNCATEchanges the data types. - C
DELETEcreates a fresh table, whileTRUNCATEchanges its name. - D
DELETEremoves the table structure, whileTRUNCATEremoves only one column.
Correct answer
ADELETEcan remove records, whileTRUNCATEremoves all records but preserves the table.Explanation
DELETEremoves records, whileTRUNCATEremoves all records from a table but leaves the table itself in place. - A
- 61
What relationship does the example's foreign-key constraint establish?
- A
It makes every product record a new customer record.
- B
It makes
customer_idan independent primary key unrelated to customers. - C
It links product records to customer records through a referenced customer key.
- D
It makes the customer table depend on product names rather than customer IDs.
Correct answer
CIt links product records to customer records through a referenced customer key.
Explanation
The example defines
customer_idin the product table as a foreign key referencing the customer table, linking product records to existing customers. - A
- 62
Why does the example's insert fail when it uses a customer ID that is not present in the customer table?
- A
It automatically creates a matching customer for every product record.
- B
It prevents a product record from referring to a nonexistent customer ID.
- C
It changes a product's ID to match the customer's ID.
- D
It prevents product records from containing names.
Correct answer
BIt prevents a product record from referring to a nonexistent customer ID.
Explanation
The example's foreign-key constraint rejects a product record whose
customer_iddoes not match an existing customer record. - A
- 63
Why would a query use a join between customer and product tables?
- A
A join changes all columns in two tables to the same data type.
- B
A join combines related data from multiple tables in one query result.
- C
A join assigns a primary key to every database in the system.
- D
A join deletes records that are shared by multiple tables.
Correct answer
BA join combines related data from multiple tables in one query result.
Explanation
A join lets a query retrieve fields from two tables, such as customer details from one table and product details from another.
- A
- 64
Why does the join example qualify fields with table names, such as
customer.name?- A
Table-qualified field names create new columns in the joined result.
- B
Table-qualified field names identify which table supplies each selected field.
- C
Table names are used to convert all selected values to strings.
- D
Table names are used only to specify which records should be deleted.
Correct answer
BTable-qualified field names identify which table supplies each selected field.
Explanation
The join example uses table-qualified references such as
customer.nameandproduct_model.priceto specify which table supplies each field. - A
- 65
What condition allows the demonstrated join to connect customer and product-model records?
- A
The tables are joined by sorting both tables by their prices.
- B
The tables are joined by matching every customer field to every product field.
- C
The tables are joined by matching the related key fields.
- D
The tables are joined by requiring their names to be identical.
Correct answer
CThe tables are joined by matching the related key fields.
Explanation
The example joins customer and product-model information using a condition that connects their related IDs.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.