Ch6_2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

A ________ view is materialized when referenced. A) virtual B) dynamic C) materialized D) base

B

In an SQL statement, which of the following parts states the conditions for row selection? A) Select B) From C) Where D) Group By

C

The ALTER TABLE command is used to change a table definition.

True

The content of dynamic views is generated when they are referenced

True

Any create command may be reversed by using a ________ command. A) truncate B) drop C) delete D) unpack

B

DDL is typically used during which phases of the development process? A) Implementation B) Physical design C) Analysis D) All of the above

B

What result will the following SQL statement produce? Select Avg(standard_price) as average from Product_V; A) The average of all products in Product_V B) The average Standard_Price of all products in Product_V C) The average price of all products D) None of the above

B

Which of the following will produce the minimum of all standard prices? A) Select standard_price from Product_V where Standard_Price = min; B) Select min(standard_price) from Product_V; C) Select Standard_Price from min(Product_V); D) Select min(Standard_Price) from Product_V where Standard_Price = min(Standard_Price);

B

The command for creating a database is: A) create table. B) create view. C) create schema. D) create authorization.

C

The DROP command deletes rows from a table individually or in groups.

False

The HAVING clause and the WHERE clause perform the same operation.

False

The ORDER BY clause is the first statement processed in an SQL command.

False

The FROM clause is the first statement processed in an SQL command.

True

The SQL command used to populate tables is the INSERT command.

True

The views are created by executing a CREATE VIEW SQL command.

True

What result set is returned from the following query? Select Customer_Name, telephone from customers where city in ('Boston','New York','Denver'); A) The Customer_Name and telephone of all customers B) The Customer_Name and telephone of all customers living in either Boston, New York or Denver C) The Customer_Name and telephone of all customers living in Boston and New York and Denver D) The Customer_Name of all customers living in Boston, New York or Denver

B

Which of the following is the wildcard operator in SQL statements? A) < > B) * C) = D) &

B

Which of the following is a purpose of the SQL standard? A) To specify syntax and semantics of SQL data definition and manipulation B) To specify minimal and complete standards, which permit different degrees of adoption in products C) To define the data structures and basic operations for SQL databases D) All of the above

D

What three clauses are contained in most SQL retrieval statements?

The SELECT clause, which lists the columns and calculated expression from base tables. The FROM clause, which identifies tables and views which we want to gather data from in the query. The WHERE clause, which is used to specify conditions for selection of rows in the result set.

Explain the three classes of SQL commands and when they would be used.

There are three classes or types of SQL commands. Data definition language commands are used to create tables, alter and drop tables, views and indexes. These commands are used to build the structure of the database as well as some additional objects. Data Manipulation Language commands, which are used to maintain and query a database. Commands in this class include select, update, delete and insert. Data control language commands, which are used to grant and revoke privileges on tables and other objects in the database.

) 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; Select last_name, first_name from customer where credit_limit between 100 and 10000;

True

A database table is defined using the data definition language (DDL).

True

The WHERE clause includes the conditions for row selection within a single table or view and the conditions between tables or views for joining.

True

The WHERE clause is always processed before the GROUP BY clause when both occur in a SELECT statement.

True

Multiple values returned from an SQL query that includes an aggregate function are called: A) vector aggregates. B) scalar aggregates. C) agates. D) summations

A

To get all the customers from Hawaii sorted together, which of the following would be used? A) ORDER BY B) GROUP BY C) HAVING D) SORT

A

What does the following SQL statement do? Alter Table Customer_T Add (Type Varchar (2)); A) Alters the Customer_T table to accept Type 2 Varchars B) Alters the Customer_T table to be a Type 2 Varchar C) Alters the Customer_T table, and adds a field called "Type" D) Alters the Customer_T table by adding a 2-byte field called "Varchar"

C

Indexes generally slow down access speed in most RDMS.

False

Materialized views are stored on disk and are never refreshed.

False

SQL has been implemented only in the mainframe and midrange environments.

False

What does the following SQL command do? insert into Customer_T values (001,'John Smith','231 West St','Boston','MA','02115'); A) Adds a new record to the Customer_T B) Creates the Customer_T table C) Deletes the Customer_T table D) Updates the Customer_T table

A

What does the following SQL statement do? Delete from Customer_T where state = 'HI'; A) Deletes all records from customer_t where the state is equal to HI B) Removes the Customer_T table from the database C) Deletes all records from the Customer_T table D) None of the above

A

What does the following SQL statement do? Select * From Customer Where Cust_Type = "Best" A) Selects all the fields from the Customer table for each row with a customer labeled "Best" B) Selects the "*" field from the Customer table for each row with a customer labeled "Best" C) Selects fields with a "*" in them from the Customer table D) Selects all the fields from the Customer table for each row with a customer labeled "*"

A

What results will be produced by the following SQL query? Select sum(standard_price) as Total_Price from Product_V where Product_Type = 'WOOD'; A) The total price of all products that are of type wood B) The total price of all products C) The Standard_Price of the first wood product in the table D) The Standard_Price of any wood product in the table

A

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) A listing of all drivers who made more than 2 deliveries as well as a count of the number of deliveries B) A listing of all drivers C) A listing of the number of deliveries greater than 2 D) A listing of all drivers who made more than 2 deliveries

A

Which of the following counts ONLY rows that contain a value? A) Count B) Count(*) C) Tally(*) D) Checknum

A

________ is a set of commands used to update and query a database. A) DML B) DDL C) DCL D) DPL

A

Discuss the pros and cons of using dynamic views.

A dynamic view is useful, since it provides a way to access part of a table or a combination of columns from multiple tables. A view can simplify query commands, since much of the complicated syntax of a query can be done to create the view. A view can also improve programmer productivity, since programmers can access views rather than have to rewrite the SQL commands for a query. Security is increased, since users can only see what the view presents. Also, views use little or no storage space. On the downside, views use processing time each time that the view is recreated for reference. Also, the views may or may not be recreatable.

A single value returned from an SQL query that includes an aggregate function is called a(n): A) agate. B) scalar aggregate. C) vector aggregate. D) summation.

B

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') A) It would work just fine. B) You must specify the fields to insert if you are only inserting some of the fields. C) There is no table keyword. D) None of the above.

B

The SQL command ________ adds one or more new columns to a table. A) create table B) alter table C) create view D) create relationship

B

The ________ is the structure that contains descriptions of objects such as tables and views created by users. A) SQL B) schema C) catalog D) master view

B

The first in a series of steps to follow when creating a table is to: A) identify columns that must be unique. B) identify each attribute and its characteristics. C) create an index. D) identify columns that must be null

B

To eliminate duplicate rows in a query, the ________ qualifier is used in the SQL Select command. A) alter B) distinct C) check D) specific

B

What does the following SQL statement do? Update Product_T Set Unit_Price = 775 Where Product_ID = 7 A) Changes the price of a unit called Product_T to 7 B) Changes the unit price of Product 7 to 775 C) Changes the length of the Unit_Price field to 775 D) Updates the Product_T table to have a unit price of 775

B

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) A listing of all drivers who made deliveries to state = 'MA', sorted by driver number B) 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 C) A count of all of the deliveries made to state = 'MA' by all drivers D) None of the above

B

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) A listing of all drivers, sorted by driver number B) A listing of each driver as well as the number of deliveries that he or she has made C) A count of all of the deliveries made by all drivers D) None of the above

B

Which of the following can produce scalar and vector aggregates? A) ORDER BY B) GROUP BY C) HAVING D) SORT

B

Which of the following is a technique for optimizing the internal performance of the relational data model? A) Avoiding indexes on secondary keys B) Clustering data C) Not reporting statistics to save machine resources D) Using random index organizations

B

Which of the following questions is answered by the SQL statement? Select Count (Product_Description) from Product_T; A) How many products are in the table Product_T? B) How many products have product descriptions in the Product Table? C) How many characters are in the field name "Product_Description"? D) How many different columns named "Product_Description" are there in table Product_T?

B

Indexes are created in most RDBMSs to: A) provide a quicker way to store data. B) decrease the amount of disk space utilized. C) provide rapid random and sequential access to base-table data. D) increase the cost of implementation

C

The SQL command ________ defines a logical table from one or more tables or views. A) create table B) alter table C) create view D) create relationship

C

What result set will the following query return? Select Item_No, description from item where weight > 100 and weight < 200; A) The Item_No and description for all items weighing less than 100 B) The Item_No for all items weighing between 101 and 199 C) The Item_No and description for all items weighing between 101 and 199 D) The Item_No for all items weighing more than 200

C

What will result from the following SQL Select statement? Select min(Product_Description) from Product_V; A) The minimum value of Product_Description will be displayed. B) An error message will be generated. C) The first product description alphabetically in Product_V will be shown. D) None of the above

C

Which of the following finds all groups meeting stated conditions? A) Select B) Where C) Having D) Find

C

Which of the following is true of the order in which SQL statements are evaluated? A) The SELECT clause is always processed first. B) The SELECT clause is always processed last. C) The SELECT clause is processed before the ORDER BY clause. D) The GROUP BY clause is processed before the WHERE clause

C

________ is a set of commands used to control a database, which includes security. A) DML B) DDL C) DCL D) DPL

C

Implementation of a standard can never stifle creativity and innovation.

False

SQL originated from a project called System-S.

False

The CREATE SCHEMA DDL command is used to create a table.

False

What are some of the advantages and disadvantages to an SQL standard

Some of the advantages are: reduced training costs, increased productivity, application portability, application longevity, reduced dependence on a single vendor and cross-system communication. Some disadvantages include: stifling creativity, difficulty in changing standard, and loss of application portability when adding additional proprietary features.

Discuss when to use the GROUP BY clause.

The GROUP BY clause is useful when you have a set of values for one column (such as a salesperson ID) and you would like to then calculate something like total sales for each salesperson. Rather than having to use the sum function with one salesperson's ID in the WHERE clause (and run multiple queries) you can use the GROUP BY to get the same results in one query.

What are some of the standard SQL functions that can be used in the SELECT clause?

The standard functions can be broken down into 4 categories: Mathematical, String, Date and Analytical. Mathematical functions include: Min, Max, Count, Sum, Round, Trunc and Mod. String functions include lower, upper, initcap, concat, substr and coalesce. Date functions are used for converting dates and calculating dates and include next_day, add_months and months_between. Top (to find the top n values) is one of the analytical functions.

A major benefit of SQL as a standard is reduced training costs

True

Adding the DISTINCT keyword to a query eliminates duplicates.

True

An insert command does not need to have the fields listed.

True

Applications can be moved from one machine to another when each machine uses SQL

True

Expressions are mathematical manipulations of data in a table that may be included as part of the SELECT statement.

True

If multiple Boolean operators are used in an SQL statement, NOT is evaluated first, then AND, then OR.

True

In order to update data in SQL, one must inform the DBMS which relation, columns, and rows are involved.

True

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

SQL is both an American and international standard for database access.

True

Some DBMS can handle graphic data types as well as text and numbers.

True

The ORDER BY clause sorts the final results rows in ascending or descending order.

True

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

The following query totals sales for each salesperson. Select salesperson_id, sum(sales) from salesperson group by salesperson_id;

True

When a GROUP BY clause is included in an SQL statement, only those columns with a single value for each group can be included.

True

When creating tables, it's important to decide which columns will allow null values before the table is created.

True

The DELETE TABLE DDL command is used to remove a table from the database.

False

The comparison operators = and != are used to establish a range of values.

False

The following command would work fine: insert into budget values 121,222,111;

False

The following query totals sales in state= 'MA' for each salesperson. Select salesperson_id, sum(sales) from salesperson group by salesperson_id having state = 'MA';

False

What were the original purposes of SQL, and does SQL as we know it today live up to those standards?

The following were the original purposes of SQL: 1. To specify the syntax and semantics of SQL data definition and manipulation languages 2. To define the data structures and basic operations for designing, accessing, maintaining, controlling, and protecting an SQL database 3. To provide a vehicle for portability of database definition and application modules between conforming DBMSs 4. To specify both minimal (Level 1) and complete (Level 2) standards, which permit different degrees of adoption in products 5. To provide an initial standard, although incomplete, that will be enhanced later to include specifications for handling such topics as referential integrity, transaction management, user-defined functions, join operators beyond the equi-join, and national character sets While SQL as we know it today does have some variants, there is a basic standard which is adhered to. As mentioned in the text, it seems that industry lags behind the standards somewhat. Each vendor has its own set of proprietary features which differ from the standard.

A view may not be updated directly if it contains: A) the DISTINCT keyword. B) derived columns and expressions in the SELECT clause. C) uses the GROUP BY or HAVING clause. D) all of the above.

D

The benefits of a standardized relational language include: A) application longevity. B) reduced training costs. C) cross-system communication. D) all of the above.

D

What result set will the following query return? Select Item_No from Order_V where quantity > 10; A) The Item_No of all orders that had more than 10 items B) The Order_Id of all orders that had more than one item C) The Order_Id of all orders that had more than 10 items D) The Item_No of all orders that had 10 or more items

D

A catalog is the structure that contains object descriptions created by a user.

False

A database is maintained and queried using the data mapping language (DML).

False

A referential integrity constraint specifies that the existence of an attribute in one table depends upon the existence of a foreign key in the same or another table.

False

A single value returned from an SQL query that includes an aggregate function is called a vector aggregate.

False

Count(*) tallies only those rows that contain a value, while Count counts all rows.

False

DCL is used to update the database with new records.

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'; Select last_name, first_name from customer where state in ('MA','NY','NJ','NH','CT');

False

When creating a table, it is not important to consider foreign key—primary key mates.

False

When the SELECT clause in the create view statement contains the keyword DISTINCT, the view can be used to update data.

False

What is a materialized view, and when would it be used?

Materialized views are just like dynamic views, except that an actual copy of the data is kept. With a dynamic view, the SQL is stored on the server and executed when the view is referenced. A materialized view, on the other hand, keeps a copy of the actual data. This increases performance and is particularly useful if the data are relatively static and the number of queries against the view are high.

What steps should be followed when preparing to create a table?

When preparing to create a table, one should: 1. Identify the appropriate data type and length for each attribute 2. Identify the columns that should accept null values 3. Identify that columns that need to be unique 4. Identify all primary-foreign key mates 5. Determine default values 6. Identify any columns for which domain constraints, such as check, need to be stated 7. Create the table and any indexes using create table and create index statements

How is the HAVING clause different from the WHERE clause?

While the WHERE clause works on each row in a query resultset, the HAVING clause works on the aggregate (or combined) rows in a GROUP BY. WHERE does not allow aggregates while the HAVING does allow aggregates. For example, if you had the following query: select customer_id, sum(purchase_price*quantity) from customer where sum(purchase_price*quantity) > 100 this would not work. However, with a GROUP BY and HAVING written as follows we would get back all customers whose total purchases were greater than $100 select customer_id, sum(purchase_price*quantity) from customer group by customer_id having sum(purchase_price*quantity) > 100


संबंधित स्टडी सेट्स

Cardio Chapter 4 Self-Test Questions (Exam 2)

View Set

Chapter 43: Assessment of Digestive and Gastrointestinal Function PREP-U

View Set

Micro Test #3 (Gene Transfer, Recombinant DNA, & Genetic Engineering)

View Set

linear algebra final (5.1-5.3, 6.1-6.3, 6.5, 6.6)

View Set

Fundamentals of management MGT 305 Exam 1

View Set

Primerica - Life Insurance Basics (AZ)

View Set

Competitive Advantage and Strategy Mid-Term

View Set