CH6

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The benefits of a standardized relational language include:

) all of the above.

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

: FALSE

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

: TRUE

) 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

Which of the following is a purpose of the SQL standard?

All of the above

What does the following SQL statement do? Alter Table Customer_T Add (Type Varchar (2));

Alters the Customer_T table, and adds a field called "Type"

Which of the following is a technique for optimizing the internal performance of the relational data model?

Clustering data

Which of the following counts ONLY rows that contain a value?

Count

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

FALSE

Which of the following can produce scalar and vector aggregates?

GROUP BY

Which of the following finds all groups meeting stated conditions

Having

To get all the customers from Hawaii sorted together, which of the following would be used?

ORDER BY

DDL is typically used during which phases of the development process?

Physical design

Which of the following will produce the minimum of all standard prices?

Select min(standard_price) from Product_V;

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"

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.

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

TRUE

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

TRUE

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

TRUE

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

TRUE

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

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

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 content of dynamic views is generated when they are referenced.

TRUE

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

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');

The Customer_Name and telephone of all customers living in either Boston, New York or Denver

What will result from the following SQL Select statement? Select min(Product_Description) from Product_V;

The first product description alphabetically in Product_V will be shown.

In an SQL statement, which of the following parts states the conditions for row selection?

Where

A view may not be updated directly if it contains:

all of the above.

The command for creating a database is:

create schema.

The SQL command ________ defines a logical table from one or more tables or views.

create view

Any create command may be reversed by using a ________ command.

drop

A ________ view is materialized when referenced.

dynamic

The first in a series of steps to follow when creating a table is to:

identify each attribute and its characteristics.

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

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.

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

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 between 101 and 199

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

Which of the following is true of the order in which SQL statements are evaluated?

The SELECT clause is processed before the ORDER BY clause.

What result will the following SQL statement produce? Select Avg(standard_price) as average from Product_V;

The average Standard_Price of all products in Product_V

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.

What results will be produced by the following SQL query?

The total price of all products that are of type wood

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

FALSE

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. The next type is Data Manipulation Language commands, which are used to maintain and query a database. Commands in this class include select, update, delete and insert. The last type is the data control language commands, which are used to grant and revoke privileges on tables and other objects in the database.

What does the following SQL statement do?

Changes the unit price of Product 7 to 775

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

FALSE

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

FALSE

DCL is used to update the database with new records

FALSE

Implementation of a standard can never stifle creativity and innovation.

FALSE

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

SQL originated from a project called System-S.

FALSE

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

FALSE

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

FALSE

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

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

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

FALSE

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

TRUE

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

TRUE

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

TRUE

Adding the DISTINCT keyword to a query eliminates duplicates.

TRUE

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

TRUE

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

TRUE

) A single value returned from an SQL query that includes an aggregate function is called a(n):

scalar aggregate.

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. Finally, the WHERE clause, which is used to specify conditions for selection of rows in the result set.

Which of the following is the wildcard operator in SQL statements?

*

) 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 each driver as well as the number of deliveries that he or she has made

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 each driver who made deliveries to state = 'MA' as well as the number of deliveries that each driver has made to that state

________ is a set of commands used to update and query a database

DML

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

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

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

Which of the following questions is answered by the SQL statement? Select Count (Product_Description) from Product_T;

How many products have product descriptions in the Product Table?

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

TRUE

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

TRUE

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

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

) 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 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

The SQL command ________ adds one or more new columns to a table.

alter table

) The ________ is the structure that contains descriptions of objects such as tables and views created by users.

schema

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')

You must specify the fields to insert if you are only inserting some of the fields.

Indexes are created in most RDBMSs to:

provide rapid random and sequential access to base-table data.

Multiple values returned from an SQL query that includes an aggregate function are called:

vector aggregates.

________ is a set of commands used to control a database, which includes security.

DCL

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.

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.

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

To eliminate duplicate rows in a query, the ________ qualifier is used in the SQL Select command.

distinct


Set pelajaran terkait

Medical Administrative Assistant: Module 6: Patient Accounts and Payment Processing

View Set

Lifespan and Development (Ch.1-4) (Test 1)

View Set

Graphing Two-Variable Linear Inequalities: Quiz

View Set

AP PSYCH CHAPTER 8- Motivation & Emotion

View Set

Art History Survey II Quiz Stuff

View Set

"First Aid- Chapter 23: Disaster, Remote, and Wilderness Emergencies"

View Set

Chapter 5: Competitive Rivalry & Competitive Dynamics

View Set