Worksheetschap 5
Total questions: 102
Worksheet time: 51mins
The ________ is the structure that contains descriptions of objects such as tables and views created by users.
SQL
schema
catalog
master view
________ is a set of commands used to control a database, including security.
DML
DDL
DCL
DPL
________ is a set of commands used to update and query a database.
DML
DDL
DCL
DPL
DDL is typically used during which phase of the development process?
Implementation
Physical design
Analysis
Evaluation
The main concept of relational databases was published in 1970 by:
Itzak Ben-Gan
Hoffer
Mills
E.F.Codd
Relational databases are heavily based on the mathematical concept of:
set theory
bet theory
get theory
met theory
The command for creating a database is:
CREATE TABLE
CREATE VIEW
CREATE SCHEMA
CREATE AUTHORIZATION
The command for removing a table is:
CREATE TABLE
REMOVE TABLE
DROP TABLE
TRUNCATE TABLE
Any create command may be reversed by using a(n) ________ command.
undo
drop
delete
unpack
The first in a series of steps to follow when creating a table is to:
identify columns that must be unique
identify each attribute and its characteristics
create an index
identify columns that must be null
The SQL command ________ adds one or more new columns to a table.
CREATE TABLE
ALTER TABLE
CREATE VIEW
CREATE RELATIONSHIP
What does the following SQL statement do? ALTER TABLE Customer_T ADD (Type Varchar (2));
Alters the Customer_T table to accept Type 2 Varchars
Alters the Customer_T table to be a Type 2 Varchar
Alters the Customer_T table by adding a field called "Type"
Alters the Customer_T table by adding a 2-byte field called "Varchar"
INSERT INTO is an example of ________ code.
DDL
DML
DCL
TIO
What does the following SQL command do? INSERT INTO Customer_T values (001,'John Smith','231 West St','Boston','MA','02115');
Adds a new record to the Customer_T table
Creates the Customer_T table
Deletes the Customer_T table
Updates the Customer_T table
Given a table named store with 5 fields: store_id, address, city, state, zipcode, why would the following insert command not work? INSERT INTO store values ('234 Park Street')
It would work just fine.
You must specify the fields to insert if you are only inserting some of the fields.
There is no table keyword.
INSERT INTO should be INSERT to.
What does the following SQL statement do? DELETE FROM Customer_T WHERE state = 'HI';
Deletes all records from Customer_t where the state is equal to HI
Removes the Customer_T table from the database
Deletes all records from the Customer_T table
Doesn't delete anything because of a syntax error
What does the following SQL statement do? UPDATE Product_T SET Unit_Price = 775 WHERE Product_ID = 7
Changes the price of a unit called Product_T to 7
Changes the unit price of Product 7 to 775
Changes the length of the Unit_Price field to 775
Updates the Product_T table to have a unit price of 775
Which of the following is a technique for optimizing the internal performance of the relational data model?
Avoiding indexes on secondary keys
Clustering data
Not reporting statistics to save machine resources
Using random index organizations
Indexes are created in most RDBMSs to:
provide a quicker way to store data
decrease the amount of disk space utilized
provide rapid random and sequential access to base-table data
increase the cost of implementation
In an SQL statement, which of the following parts states the conditions for row selection?
SELECT
FROM
WHERE
GROUP BY
The first part of an SQL query to be read is the ________ statement.
SELECT
FROM
WHERE
ORDER BY
The last part of an SQL query to be read is the ________ statement.
SELECT
FROM
WHERE
ORDER BY
What does the following SQL statement do? SELECT * From Customer WHERE Cust_Type = "Best"
Selects all the fields from the Customer table for each row with a customer labeled "Best"
Selects the "*" field from the Customer table for each row with a customer labeled "Best"
Selects fields with a "*" in them from the Customer table
Selects all the fields from the Customer table for each row with a customer labeled "*"
What result will the following SQL statement produce? SELECT Avg(Standard_Price) as average from Product_V;
The average of all products in Product_V
The average Standard_Price of all products in Product_V
The average price of all products
The mode of all prices
Which of the following questions is answered by the SQL statement? SELECT COUNT (Product_Description) FROM Product_T;
How many products are in the table Product_T?
How many products have product descriptions in the Product Table?
How many characters are in the field name "Product_Description"?
How many different columns named "Product_Description" are there in table Product_T?
What results will be produced by the following SQL query? SELECT SUM(Standard_Price) as Total_Price from Product_V where Product_Type = 'WOOD';
The total price of all products that are of type wood
The total price of all products
The Standard_Price of the first wood product in the table
The Standard_Price of any wood product in the table
Which of the following counts ONLY rows that contain a value?
COUNT
COUNT(*)
TALLY(*)
CHECKNUM
Which of the following will produce the minimum of all standard prices?
SELECT Standard_Price FROM Product_V WHERE Standard_Price = min;
SELECT MIN(Standard_Price) FROM Product_V;
SELECT Standard_Price FROM min(Product_V);
SELECT MIN(Standard_Price) FROM Product_V WHERE Standard_Price = min(Standard_Price);
What will result from the following SQL Select statement? SELECT MIN(Product_Description) FROM Product_V;
The minimum value of Product_Description will be displayed.
An error message will be generated.
The first product description alphabetically in Product_V will be shown.
SELECT @ will be displayed.
Which of the following is the wildcard operator in SQL statements?
<>
*
=
&
What result set will the following query return? SELECT Item_No FROM Order_V WHERE quantity > 10;
The Item_No of all orders that had more than 10 items
The Order_Id of all orders that had more than one item
The Order_Id of all orders that had more than 10 items
The Item_No of all orders that had 10 or more items
What result set will the following query return? SELECT Item_No, description FROM item WHERE weight > 100 and weight < 200;
The Item_No and description for all items weighing less than 100
The Item_No for all items weighing between 101 and 199
The Item_No and description for all items weighing between 101 and 199
The Item_No for all items weighing more than 200
To eliminate duplicate rows in a query, the ________ qualifier is used in the SQL Select command.
ALTER
DISTINCT
CHECK
SPECIFIC
What result set is returned from the following query? SELECT Customer_Name, telephone FROM customers WHERE city in ('Boston','New York','Denver');
The Customer_Name and telephone of all customers
The Customer_Name and telephone of all customers living in either Boston, New York or Denver
The Customer_Name and telephone of all customers living in Boston and New York and Denver
The Customer_Name of all customers living in Boston, New York or Denver
To get all the customers from Hawaii sorted together, which of the following would be used?
ORDER BY
GROUP BY
HAVING
SORT
A single value returned from an SQL query that includes an aggregate function is called a(n):
agate
scalar aggregate
vector aggregate
summation
Multiple values returned from an SQL query that includes an aggregate function are called:
vector aggregates
scalar aggregates
agates
summations
Which of the following can produce scalar and vector aggregates?
ORDER BY
GROUP BY
HAVING
SORT
What will be returned when the following SQL statement is executed? SELECT driver_no, count(*) as num_deliveries FROM deliveries GROUP BY driver_no;
A listing of all drivers, sorted by driver number
A listing of each driver as well as the number of deliveries that he or she has made
A count of all of the deliveries made by all drivers
An error message
What will be returned when the following SQL statement is executed? SELECT driver_no, count(*) as num_deliveries FROM deliveries WHERE state = 'MA' GROUP BY driver_no;
A listing of all drivers who made deliveries to state = 'MA', sorted by driver number
A listing of each driver who made deliveries to state = 'MA' as well as the number of deliveries that each driver has made to that state
A count of all of the deliveries made to state = 'MA' by all drivers
An error message will be generated
Which of the following finds all groups meeting stated conditions?
SELECT
WHERE
HAVING
FIND
What will be returned when the following SQL query is executed? SELECT driver_no, COUNT(*) as num_deliveries FROM deliveries GROUP BY driver_no HAVING COUNT(*) > 2;
A listing of all drivers who made more than 2 deliveries as well as a count of the number of deliveries
A listing of all drivers
A listing of the number of deliveries greater than 2
A listing of all drivers who made more than 2 deliveries
Which of the following is true of the order in which SQL statements are evaluated?
The SELECT clause is always processed first.
The SELECT clause is always processed last.
The SELECT clause is processed before the ORDER BY clause.
The GROUP BY clause is processed before the WHERE clause.
A view may not be updated directly if it contains:
the SELECT clause.
the HAVING clause.
the FROM clause.
the WHERE clause.
Requiring a CustomerID to exist in a Primary table before it can exist in a foreign table is an example of:
referential referring.
referential integrity.
ethical integrity.
the Hoffer Principle.
Which of the following is a purpose of the SQL standard?
To specify syntax and semantics of SQL data definition and manipulation languages
To specify maximum and incomplete standards
To define every operation for every SQL database
To permit no degrees of freedom for SQL DBMS
The benefits of a standardized relational language include:
application turnover.
increased training costs.
cross-system communication.
confusing the SQL programmers.
A catalog is the structure that contains object descriptions created by a user.
True
False
DCL is used to update the database with new records.
True
False
A database table is defined using the data definition language (DDL).
True
False
A database is maintained and queried using the data mapping language (DML).
True
False
The content of dynamic views is generated when they are referenced.
True
False
The views are created by executing a CREATE VIEW SQL command.
True
False
When the SELECT clause in the create view statement contains the keyword DISTINCT, the view can be used to update data.
True
False
The CREATE SCHEMA DDL command is used to create a table.
True
False
Select True or False: SQL is both an American and international standard for database access.
True
False
Select True or False: SQL has been implemented only in the mainframe and midrange environments.
True
False
Select True or False: SQL originated from a project called System-S.
True
False
Select True or False: One of the original purposes of the SQL standard was to provide a vehicle for portability of database definition and application modules between conforming DBMSs.
True
False
Select True or False: A major benefit of SQL as a standard is reduced training costs.
True
False
Select True or False: Implementation of a standard can never stifle creativity and innovation.
True
False
Select True or False: Applications can be moved from one machine to another when each machine uses SQL.
True
False
Select True or False: Some DBMSs can handle graphic data types as well as text and numbers.
True
False
Select True or False: When creating tables, it's important to decide which columns will allow null values before the table is created.
True
False
Select True or False: In databases, null values are equivalent to zero.
True
False
Select True or False: The DELETE TABLE DDL command is used to remove a table from the database.
True
False
Select True or False: The ALTER TABLE command is used to change a table definition.
True
False
Select True or False: The SQL command used to populate tables is the INSERT command.
True
False
Select True or False: An INSERT command does not need to have the fields listed.
True
False
Evaluate the statement: INSERT INTO budget values 121,222,111; Would this command work as written?
Yes, it would work
No, it would not work
Select True or False: The DROP command deletes rows from a table individually or in groups.
True
False
Select True or False: In order to update data in SQL, one must inform the DBMS which relation, columns, and rows are involved.
True
False
Select True or False: Indexes generally slow down access speed in most RDMS.
True
False
Select True or False: Expressions are mathematical manipulations of data in a table that may be included as part of the SELECT statement.
True
False
Select True or False: COUNT(*) tallies only those rows that contain a value, while COUNT counts all rows.
True
False
Select True or False: The asterisk (*) wildcard designator can be used to select all fields from a table as well as in WHERE clauses when an exact match is not possible.
True
False
Select True or False: The comparison operators = and != are used to establish a range of values.
True
False
Select True or False: If multiple Boolean operators are used in an SQL statement, NOT is evaluated first, then AND, then OR.
True
False
Select True or False: The following two SQL statements will produce the same results: SELECT last_name, first_name FROM customer WHERE credit_limit > 99 AND credit_limit < 10001; and SELECT last_name, first_name FROM customer WHERE credit_limit BETWEEN 100 and 10000;
True
False
Select True or False: Adding the DISTINCT keyword to a query eliminates duplicates.
True
False
Select True or False: The following two SQL statements will produce different results: SELECT last_name, first_name FROM customer WHERE state = 'MA' OR state = 'NY' OR state = 'NJ' OR state = 'NH' OR state = 'CT'; and SELECT last_name, first_name FROM customer WHERE state in ('MA','NY','NJ','NH','CT');
True
False
Select True or False: The ORDER BY clause sorts the final results rows in ascending or descending order.
True
False
A single value returned from an SQL query that includes an aggregate function is called a vector aggregate.
True
False
When a GROUP BY clause is included in an SQL statement, only columns with a single value for each group can be included.
True
False
The HAVING clause and the WHERE clause perform the same operation.
True
False
Consider the query: SELECT salesperson_id, sum(sales) FROM salesperson GROUP BY salesperson_id. The query totals sales for each salesperson.
True
False
Consider the query: SELECT salesperson_id, sum(sales) FROM salesperson GROUP BY salesperson_id HAVING state = 'MA'; The query totals sales in state 'MA' for each salesperson.
True
False
The ORDER BY clause is the first statement processed in an SQL command.
True
False
The WHERE clause is always processed before the GROUP BY clause when both occur in a SELECT statement.
True
False
The FROM clause is the first statement processed in an SQL command.
True
False
When creating a table, it is not important to consider foreign key–primary key mates.
True
False
A referential integrity constraint specifies that the existence of an attribute in one table depends on the existence of a foreign key in the same or another table.
True
False
Select all the classes of SQL commands used to build, maintain, and secure a database.
Data definition language (DDL)
Data manipulation language (DML)
Data control language (DCL)
Transaction control language (TCL)
Markup definition language (MDL)
Select all true statements about dynamic views.
They provide a way to access part of a table or a combination of columns from multiple tables.
They can improve programmer productivity by allowing queries to be reused via views.
They use little or no storage space but consume processing time when the view is recreated for reference.
They are always recreatable regardless of database changes.
They can increase security because users see only what the view presents.
Which option best describes a materialized view and its typical use?
It keeps a copy of the actual data and is useful for relatively static data when many queries are run against the view, improving performance.
It executes the view's SQL on the server only when the view is referenced and stores no results.
It is a temporary, session-only view that disappears at disconnect.
It is an index-organized synonym that replaces base tables.
Select all original purposes of SQL.
To specify the syntax and semantics of SQL data definition and manipulation languages.
To define data structures and basic operations for designing, accessing, maintaining, controlling, and protecting an SQL database.
To provide portability of database definition and application modules between conforming DBMSs.
To specify both minimal (Level 1) and complete (Level 2) standards allowing different degrees of adoption in products.
To prohibit national character sets to enforce uniformity across vendors.
Select all recommended steps when preparing to create a table.
Identify the appropriate data type and length for each attribute.
Identify the columns that should accept null values.
Identify columns that need to be unique.
Identify all primary–foreign key mates.
Drop all default values to avoid ambiguity.
Which three clauses are contained in most SQL retrieval statements?
SELECT, FROM, WHERE
SELECT, GROUP BY, HAVING
FROM, WHERE, ORDER BY
SELECT, JOIN, ORDER BY
Select all categories of standard SQL functions that can be used in the SELECT clause.
Mathematical
String
Date
Analytical
Network
When is the GROUP BY clause useful?
When you need to calculate aggregates such as totals for each distinct value in a column (e.g., total sales per salesperson).
When you need to filter individual rows before aggregation.
When you need to sort the result set by one or more columns.
When you need to join two tables on a foreign key.
Which statement correctly contrasts the HAVING clause with the WHERE clause?
WHERE filters individual rows before grouping, while HAVING filters groups based on aggregate conditions.
HAVING filters individual rows before grouping, while WHERE filters groups after aggregation.
WHERE and HAVING perform the same operation at the same stage of query processing.
HAVING can be used only with ORDER BY, while WHERE can be used only with GROUP BY.
Select all statements that correctly describe advantages or disadvantages of an SQL standard.
Reduced training costs
Increased productivity
Stifling creativity
Greater dependence on a single vendor
Cross-system communication
