100% found this document useful (12 votes)
98 views67 pages

Modern Database Management 12th Edition Hoffer Solutions Manual Download

The document provides information about the 'Modern Database Management 12th Edition Hoffer' Solutions Manual and various related educational resources available for download. It includes an overview of SQL, emphasizing its importance in relational database management systems, and outlines key concepts such as Data Definition Language (DDL) and Data Manipulation Language (DML). Additionally, it discusses classroom ideas for teaching SQL and the historical development of SQL standards.

Uploaded by

tuvanaribe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (12 votes)
98 views67 pages

Modern Database Management 12th Edition Hoffer Solutions Manual Download

The document provides information about the 'Modern Database Management 12th Edition Hoffer' Solutions Manual and various related educational resources available for download. It includes an overview of SQL, emphasizing its importance in relational database management systems, and outlines key concepts such as Data Definition Language (DDL) and Data Manipulation Language (DML). Additionally, it discusses classroom ideas for teaching SQL and the historical development of SQL standards.

Uploaded by

tuvanaribe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Modern Database Management 12th Edition Hoffer

Solutions Manual download pdf

https://testbankfan.com/product/modern-database-management-12th-edition-
hoffer-solutions-manual/

Visit testbankfan.com today to download the complete set of


test banks or solution manuals!
We believe these products will be a great fit for you. Click
the link to download now, or visit testbankfan.com
to discover even more!

Modern Database Management 12th Edition Hoffer Test Bank

https://testbankfan.com/product/modern-database-management-12th-
edition-hoffer-test-bank/

Modern Database Management 10th Edition Hoffer Solutions


Manual

https://testbankfan.com/product/modern-database-management-10th-
edition-hoffer-solutions-manual/

Modern Database Management 11th Edition Hoffer Solutions


Manual

https://testbankfan.com/product/modern-database-management-11th-
edition-hoffer-solutions-manual/

Essentials of Marketing Management 1st Edition Marshall


Test Bank

https://testbankfan.com/product/essentials-of-marketing-
management-1st-edition-marshall-test-bank/
Practical Financial Management 7th Edition Lasher
Solutions Manual

https://testbankfan.com/product/practical-financial-management-7th-
edition-lasher-solutions-manual/

Precalculus Essentials 5th Edition Blitzer Test Bank

https://testbankfan.com/product/precalculus-essentials-5th-edition-
blitzer-test-bank/

Operations and Supply Chain Management 9th Edition Russell


Solutions Manual

https://testbankfan.com/product/operations-and-supply-chain-
management-9th-edition-russell-solutions-manual/

Computer Organization and Design RISC-V 1st Edition


Patterson Solutions Manual

https://testbankfan.com/product/computer-organization-and-design-
risc-v-1st-edition-patterson-solutions-manual/

Essentials of Radiographic Physics and Imaging 2nd Edition


Johnston Test Bank

https://testbankfan.com/product/essentials-of-radiographic-physics-
and-imaging-2nd-edition-johnston-test-bank/
On Cooking A Textbook of Culinary Fundamentals 6th Edition
Labensky Test Bank

https://testbankfan.com/product/on-cooking-a-textbook-of-culinary-
fundamentals-6th-edition-labensky-test-bank/
Chapter 6 1

Chapter 6 Introduction to SQL

Chapter Overview

This chapter describes in detail what has become the standard query language for
relational database management systems, SQL. Although SQL is illustrated in this
chapter primarily through a current Oracle version (MySQL and Microsoft Access SQL
are also sometimes displayed), SQL is a widely used language that is available on all
classes of computers and with many different DBMSs.
This chapter introduces SQL and emphasizes the Data Definition Language
(DDL) and Data Manipulation Language (DML) commands. Single table queries are
covered in this chapter, and multiple-table queries are covered in Chapter 7.
Several chapters contain important prerequisite material for this chapter. Chapter
4 introduces the relational model and provides much of the background for this chapter
(including an introduction to the Data Definition Language commands). The discussion
in Chapter 5 on indexes is also important because choosing primary and secondary key
indexes is one of the few, but crucial, internal database design choices for users of
relational systems.

Chapter Objectives
Specific student learning objectives are included at the beginning of the chapter. From an
instructor’s point of view, the objectives of this chapter are to:
1. Explain SQL and show the basic operators so that the student can anticipate the
capabilities of particular SQL-based systems.
2. Provide a historical perspective of the development of SQL and its continuing
development. This perspective illustrates the benefits and risks of adopting a
standard query language.
3. Show that SQL, although a standard and a high-level language, does have some
flaws, and that SQL must evolve to include additional features.
4. Explain and illustrate the power of relational views for simplifying relational
database processing.
5. Illustrate data definition language (DDL) commands for creating tables and views
as well as modifying and dropping tables.
6. Provide examples of single table SQL queries.
7. Provide some examples of the use of functions within SQL queries.
8. Show how to establish referential integrity using SQL.
9. Illustrate the use of the group by and order by clauses.

Key Terms

Base table Data manipulation Scalar aggregate


language (DML)
Catalog Dynamic view Schema
Data control language (DCL) Materialized view Vector aggregate
Data definition language Relational DBMS Virtual table
(DDL) (RDBMS)

Copyright © 2016 Pearson Education, Inc.


2 Modern Database Management, Eleventh Edition

Classroom Ideas

1. Depending on how you choose to sequence the chapters of this book, you may want
to begin lecturing on this chapter by reviewing normalization principles and
discussing why one might want to implement a fully normalized database. See the
section “Denormalization” in Chapter 5 for background on this topic. The point is to
emphasize the difference between logical and physical database designs.

2. With the variety of SQL implementations now available, we strongly recommend


that you illustrate some SQL system in class and have the students use such a
system. The Pine Valley Furniture case in the text provides a rich context in which to
develop examples that emphasize those aspects of SQL the instructor considers most
important. We have found that students learn SQL best by seeing and doing many
examples and experimentation, so we encourage teaching SQL by example. When
teaching SQL, we often spend about 15 minutes giving an overview of the evolution
of SQL and providing some basic syntax and terminology. Then we spend between
two and six hours in live demonstrations showing simple to complex queries in a
well-designed sequence. In a computer-enabled classroom where an SQL system can
be demonstrated to and used by students, this time can be an effective, interactive
learning experience.

All the SQL queries in this chapter can be found in a Microsoft Access database
available from the publisher; you can show in class how Access SQL varies from
standard SQL, and you can show variations on the queries from this chapter. In
addition, a set of 40 lab exercise queries is available on
www.teradatauniversitynetwork.com for use with the Pine Valley Furniture
Company case. Many of these lab exercises are included already in this text. These
queries are designed to work with a database that is close to, but not exactly, the data
model in Figure 2-22.

3. Because many SQL systems include other modules (report writers, business graphics
routines, screen painters, and so forth), this chapter can be expanded to discuss
fourth-generation languages and systems prototyping. Explain that most packages
include capabilities and development tools that are more than simply a relational
DBMS and query language. If your school has joined the Oracle Academy, it may be
possible to demonstrate additional tools such as SQL Developer and/or
Designer/2000. Additionally, Oracle provides universal and free access to its
Express Edition with a Java-based application development environment which can
easily be used on individually-owned computers.

4. One interesting discussion item is the widespread and continued use of SQL in most
types of administrative systems, regardless of the system type and architecture. SQL
has been one of the most durable components of corporate computing architectures
during the past 20-30 years and it still does not show signs of aging.

Copyright © 2016 Pearson Education, Inc.


Chapter 6 3

5. It should be emphasized that SQL is still fundamentally a programming language for


the professional programmer. That is, SQL is not really a suitable language for end-
user system development. This does not diminish its importance because it achieves
tremendous productivity gains for a professional programming staff and is used
extensively by database administrators. Many of your students are likely to hold
these positions during their careers. Other user interfaces that might permit access to
a relational database (like QBE) are more appropriate for end users.

6. The simplicity of SQL syntax leads some students to become overconfident of their
SQL prowess. It may help to develop some examples to demonstrate that logically
and syntactically correct SQL queries can be constructed that do not accomplish the
intended data manipulation and may be dangerously incorrect. For example, two
tables may be joined using common domains (for instance, positive integers) but
non-common roles (for example, two tables can be joined on equal values of
quantity-on-hand of a product and number of employees in a department). Such
potential problems arise because the relational data model uses implicit relationships,
not explicit ones. Stress the importance of testing a query on a small, tractable set of
data before using it in a production environment.

7. The capabilities and benefits of views are not as obvious to students as you might
expect. First, many relational systems place limitations on operations that may be
performed on views (for example, no or restricted modification). Second, views are
not just the relational term for temporary table or for subschemas (from the network
model); rather, views provide a capability for simpler query writing for casual users.
Finally, views may have negative performance implications compared to temporary,
intermediate tables explicitly created by a prewritten procedure. These points should
be emphasized in lectures or assignments. Consider having students create both a
view and a temporary table (or materialized view) in SQL. In most SQL systems, a
temporary table can be created by the use of a SAVE or KEEP clause at the end of a
query, or one can use a CREATE TABLE command that has a query (rather than
column definitions) as its object. Then, the same query can be run and timed against
both the view and temporary tables. As another alternative, have students derive the
view table as part of the FROM clause of a query. One way to estimate the timing of
each approach, given small data sets, is to use the EXPLAIN command (or similar
command with your RDBMS) on each version of the query to show students how the
query would be processed using each approach.

Answers to Review Questions

Define each of the following key terms:

a. Base table. A table in the relational data model containing inserted raw data
that is likely to correspond to one physical file in secondary storage. The base
table is also referred to as one of the objects—such as the base tables, views,
constraints, and so on—which have been defined for a particular database by a
particular user, who owns the objects in the schema.

Copyright © 2016 Pearson Education, Inc.


4 Modern Database Management, Eleventh Edition

b. Data definition language. Those commands used to define a database,


including creating, altering, and dropping tables and establishing constraints
c. Data manipulation language. Those commands used to maintain and query a
database, including updating, inserting, modifying, and querying data.
d. Dynamic view. A virtual table that is created dynamically upon request by a
user. It is not a temporary table; instead, its definition is stored in the system
catalog. The contents of the view are materialized as a result of an SQL query
that uses the view.
e. Materialized view. Copies or replicas of data based on SQL queries, in the
same manner that dynamic views are created. However, a materialized view
exists as a table and care must be taken to keep it synchronized with its
associated base tables.
f. Referential integrity constraint. An integrity constraint specifying that the
value or existence of an attribute in one relation depends on the value or
existence of a primary key in the same or another relation. Referential
integrity means that a value in the matching column on the many-side must
correspond to a value in the primary key for some row in the table on the one-
side, or be null.
g. Relational DBMS (RDBMS). A database management system that manages
data as a collection of tables in which all data relationships are represented by
common values (not links) in related tables
h. Schema. A structure that contains descriptions of objects created by a user,
such as base tables, views, constraints, and so on, as part of a database
i. Virtual table. A table constructed automatically as needed by a DBMS.
Virtual tables are not maintained as real data. Sometimes a virtual table is
referred to as a dynamic view.

Match the following terms to the appropriate definitions:

d view
h referential integrity constraint
c dynamic view
i materialized view
j SQL:2011
e null value
k scalar aggregate
a vector aggregate
b catalog
f schema
g host language

Contrast the following terms:

a. Base table; view. A view is a virtual table and is often part of an external
database. In contrast to a defined base table (relation), a view is not
permanently represented in storage. A view definition is stored, and the
contents of the view are calculated each time the view is referenced in a

Copyright © 2016 Pearson Education, Inc.


Chapter 6 5

query. A view may join multiple tables or views together and may contain
derived (or virtual) columns, while base tables cannot. In comparison to a
temporary real table, a view consumes very little storage space. A view is
costly (compared to a dynamic, materialized view), however, because its
contents must be calculated each time that it is requested.
b. Dynamic view; materialized view. Dynamic views are not a temporary table
but are materialized from an SQL query that uses the view definition that is
stored in the system catalog. Materialized views exist as a table and, thus,
must be kept synchronized with their associated base tables.
c. Catalog; schema. Schema is a structure that contains descriptions of objects
created by a user, such as base tables, views, constraints, and so on. These
objects have been defined for a particular database by a particular user, who
owns those objects in the schema. The catalog is a set of schemas, which,
when put together, constitute a description of a database. (If more than one
user has created objects in the database, combining information about all their
schemas will yield information for the entire database.)

History leading up to SQL:2011:

a. To provide direction for the development of RDBMSs, the American National


Standards Institute (ANSI) and the International Organization for
Standardization (IOS) approved a standard for the SQL relational query
language functions and syntax proposed originally by the X3H2 Technical
Committee on Database (Technical Committee X3H2 Database, 1986; ISO,
1987). This standard is often referred to as SQL/86. The 1986 standards have
been extended to include an optional Integrity Enhancement Feature (IEF),
often referred to as SQL/89. The ISO and ANSI committees created SQL-92
(Technical Committee X3H2 Database, 1989; ISO, 1989, 1991), which was a
more extensive expansion of SQL/86. This standard was ratified in late 1992,
and is known as International Standard ISO/IEC 9075:1992, Database
Language SQL.
b. SQL:1999 is a significant extension beyond SQL-92. SQL: 1999 established
Core-level conformance, which must be met before any other level of
conformance can be achieved. Eight additional types of enhanced
conformance have been specified so far, including Active Database, Enhanced
Integrity Management, Enhanced Datetime Facilities, Basic Object Support,
Enhanced Object Support, OLAP Facilities, Persistent Stored Modules, and
Call-Level Interface.
c. SQL:2011 provides many enhancements to SQL:1999 including predefined
data types, type constructors, scalar, and table expressions. Temporal
extensions are an important addition available in SQL:2011. Also included as
part of this standard is SQL/XML.

Temporal extensions in SQL:2011

The temporal extensions in SQL:2011 include mechanisms with which database


designers and various types of users of a relational database can explicitly specify,

Copyright © 2016 Pearson Education, Inc.


6 Modern Database Management, Eleventh Edition

manipulate, and query phenomena related to data values that change over time.
Temporal extensions are discussed at a more detailed level in Chapter 7.

Describe a relational DBMS (RDBMS), its underlying data model, data storage
structures, and manner of establishing data relationships:

a. A relational DBMS (or RDMBS) is a data management system that


implements a relational data model.
b. Data are stored in a collection of tables, and the data relationships are
represented by common values, not links.
c. The relational data model assumes that a table is a logical construct rather
than a physical construct, so a table need not correspond to a physical file of
contiguous records. The same data model may have many different possible
physical implementation structures. The storage of the database is dependent
on both the hardware and software environment. It is usually the concern of
the system administrator.
d. The power of the RDBMS is realized through relationships existing between
tables. These relationships are established by including a common column(s)
in each table where a relationship is needed.

Six potential benefits of achieving a widely accepted SQL standard:

a. Reduced training costs. Training in an organization can concentrate on SQL,


and a large labor pool of IS professionals trained in a common language
reduces retraining when hiring new employees.
b. Productivity. IS professionals can learn SQL thoroughly and become
proficient with it from continued use, the organization can afford to invest in
tools to help IS professionals become more productive, and programmers can
more quickly maintain existing programs because they are familiar with the
language in which programs are written.
c. Application portability. Applications can be moved from machine to machine
when each machine uses SQL. Further, it is economical for the computer
software industry to develop off-the-shelf application software when there is a
standard language.
d. Application longevity. A standard language tends to remain so for a long time,
so there will be little pressure to rewrite old applications. Rather, applications
will simply be updated as the standard language is enhanced or new versions
of DBMSs are introduced.
e. Reduced dependence on a single vendor. When a nonproprietary language is
used, it is easier to use different vendors for the DBMS, training and
educational services, application software, and consulting assistance. Further,
the market for such vendors will be more competitive, which may lower
prices and improve service.
f. Cross-system communication. Different DBMSs and application programs can
more easily communicate and cooperate in managing data and processing user
programs.

Copyright © 2016 Pearson Education, Inc.


Chapter 6 7

The components and structure of a typical SQL environment:

The SQL environment includes an instance of an SQL DBMS along with


accessible databases and associated users and programs. Each database is
included in a catalog and has a schema that describes the database objects.
Information contained in the catalog is maintained by the DBMS itself, rather
than by the users of the DBMS.

Distinguish among data definition commands, data manipulation commands, and


data control commands:

a. The data definition language (DDL) commands of SQL are used to define a
database, including its creation and the creation of its tables, indexes, and
views. Referential integrity is also established through DDL commands.
CREATE/DROP DICTIONARY, CREATE/DROP TABLE, ALTER
TABLE, CREATE/DROP INDEX, CREATE/DROP VIEW are examples of
DDL commands.
b. The data manipulation (DML) commands of SQL are used to load, update,
and query the database through the use of the SELECT command. (START
TRANSACTION, COMMIT WORK, ROLLBACK WORK, INSERT,
UPDATE, and DELETE are examples of DML commands.)
c. Data control language (DCL) commands are used to establish user access to
the database through the GRANT, ADD USER, and REVOKE commands.

Establishing referential integrity using an SQL:1999 compliant database and the


differences among the ON UPDATE RESTRICT, ON UPDATE CASCADE, and
ON UPDATE SET NULL clauses, and results of declaring ON DELETE
CASCADE:

a. The SQL REFERENCES clause is used to establish referential integrity and


prevents a foreign key value from being added if it is not already a valid value
in the referenced primary key column.
b. The ON UPDATE RESTRICT clause allows a row to be deleted in a parent
table only if no record in the child table references the primary key value to be
deleted in the parent table. The ON UPDATE CASCADE clause will cause a
change in a primary key value of a parent table to be passed through and
update the foreign key value in the related child table. The ON UPDATE SET
NULL option allows the update on the parent table, but changes the involved
foreign key value in the child table to NULL. Using the SET NULL option
would result in losing the connection between the parent and child tables, not
a desired effect.
c. With DELETE CASCADE, removing the primary key value in the parent
table also removes all associated records from the child table.

Copyright © 2016 Pearson Education, Inc.


8 Modern Database Management, Eleventh Edition

Reasons to create a view using SQL and how a view can be used to reinforce data
security:

a. Views may simplify query commands, provide valuable data security, and
enhance programming productivity for a database.
b. Tables and columns that are not included in a view will not be obvious to the
user of the view. Restricting access to a view with GRANT and REVOKE
statements (security statements) adds a further layer of security. It should not
be regarded as the primary security layer.

Update limitations on data changes when referencing data through a view:

In general, update operations to data in a view are permitted as long as the update
is unambiguous in terms of data modification in the base table. However, when
the CREATE VIEW statement contains any of the following situations, that view
may not be updated directly.
a. The SELECT clause includes the keyword DISTINCT.
b. The SELECT clause contains expressions, including derived columns,
aggregates, statistical functions, and so forth.
c. The FROM clause, a subquery, or a UNION clause references more than one
table.
d. The FROM clause or a subquery references another view, which is not
updateable.
e. The CREATE VIEW command contains an ORDER BY, GROUP BY, or
HAVING clause.

Saving reprogramming (application maintenance) effort by using views:

When more than one program uses a view on the same base table, changes in all
the applications that relate to this particular base table will require only re-
creation of the view (outside the applications themselves). Views require
considerable run-time computer processing because the virtual table of a view is
recreated each time the view is referenced. Therefore, referencing a base table
through a view rather than directly can add considerable time to query processing,
depending on the query. This additional operational cost must be balanced against
the potential application maintenance savings from a view. A view also simplifies
query writing because queries written against the view refer to only one (virtual)
table, rather than several base tables.

Factors to be considered in deciding whether to create a key index for a table in


SQL:

a. A key index on one column or a concatenation of columns enables rapid


access to the rows of a table in a sequence or randomly by key value.
b. Choosing to index primary and/or secondary keys may increase the speed of
row selection, table joining, and row ordering.
c. Dropping indexes will increase the speed of table updating.

Copyright © 2016 Pearson Education, Inc.


Chapter 6 9

Qualifying the ownership of a table in SQL:

Placing the ID of the owner prior to the table name and attribute name indicates
ownership of a table. For example, if the user with the User_ID of ORTEGA
owns the CUSTOMER_T table, that ownership would be indicated as
ORTEGA.CUSTOMER_T. In order for one user to be allowed to use a table in
the database owned by another user, the non-owner user must be granted
authorization to use it, usually by the database administrator.

Changing attribute order and column heading labels in a result table:

a. Attributes are displayed in columns in the sequence in which they are listed in
the SELECT list unless the SELECT list is *, in which case all attributes from
the referenced tables are displayed in the sequence in which they are defined.
b. Use AS to specify column heading labels, e.g., SELECT CUST.
CustomerName AS NAME will result in a column heading label NAME
instead of CustomerName.

COUNT, COUNT DISTINCT, and COUNT(*) in SQL and the results generated
when using these:

a. COUNT tallies only those rows that contain a value; it ignores all null values.
b. COUNT DISTINCT does not return a count on all values; it only tallies once
if more than one row has equal values.
c. COUNT (*) counts all rows regardless of whether any of the rows contain null
values.
d. If we never use NULL values, COUNT and COUNT(*) will return the same
results. If our table includes no duplicates in the considered attribute values,
COUNT and COUNT DISTINCT will have the same meaning.

Evaluation order for the Boolean operators (AND, OR, NOT) in an SQL
command; getting the operators to work in the order that you want:

a. If multiple Boolean operators are used in an SQL statement, NOT is evaluated


first, then AND, then OR.
b. With the use of parentheses around statements using standard mathematical
notation, a set of statements may be given a user-chosen specific order of
evaluation.

Limitations on attributes that can be selected when an SQL statement contains


GROUP BY:

Only those columns that have a single value for each group can be included.

HAVING clause usage:

The HAVING clause is useful when you need to select results based upon
qualifications on an aggregation, such as a characteristic of a group. For example,

Copyright © 2016 Pearson Education, Inc.


10 Modern Database Management, Eleventh Edition

if we have a table with transactional sales data for salespeople, we may want to
sum up the total sales for a given period of time (an aggregate). We may then
want to produce a list of only salespeople who sold more than a certain amount,
say $1,000. This can be done using the HAVING clause.

IN operator usage:

The IN operator is used in conjunction with the WHERE clause. A set of valid
selections for the IN operator within parentheses follows the operator [e.g., IN
('WA', 'CA')]. The OR operator can be used to perform the same operation as the
IN operator. For example, if part of our WHERE clause is State IN ('MA', 'NH'),
this could be substituted with State = 'MA' OR State = 'NH'.

Determining the order in which the rows appear in the SQL query response set

The ORDER BY clause can be added to an SQL query to determine the order in
which the rows appear in the final response set.

SQL as a set-oriented language

SQL is considered a set-oriented language because it processes sections (or sets)


of table data that meet certain criteria (e.g., products that are desks or tables, for
instance) with other sections (or sets) of table data that meet other criteria (e.g.,
products having a standard price above $300). SQL will “grab” the data that
meets the criteria, hold it in a temporary work area(s), then using logical UNION
and INTERSECTION commands find the “result set” that meets all criteria
specified by the SQL statements. A set-oriented language, like SQL, is presented
in contrast to a record-oriented language (such as C, Java, and COBOL) that must
process one record/row of a table at a time.

LIKE keyword usage:

CREATE TABLE LIKE is a quick way to clone a table.

Identity column definition and usage:

The identity column creates a numeric sequence. For example, if we create the
following table:

CREATE TABLE Test1_T


(ID SMALLINT IDENTITY(5,2),…)

then the first record added to Test1_T table will have 5 as its value for the ID
column. Subsequent record IDs will be incremented by 2.

This is beneficial because it allows a way to automatically generate a unique


number, such as an ID. Please note that this does not work in Oracle; IDENTITY
is a SQL Server specific command.

Copyright © 2016 Pearson Education, Inc.


Chapter 6 11

Merge keyword usage:

Prior to SQL:2006 and SQL:2008, one had to use both insert and update to update
and merge data into a table. The Merge command allows one to do this in a single
step. A common use for this would be updating master table from a transaction
table where one might want to update records or create new records in the master
table based upon what was done in the transaction table. Let’s take a look at an
example: Suppose that we have an item table and a shipment table. The Item table
contains all of the items and the Shipment table contains items received by the
company.

Item Table
ItemNo Description Quantity
on Hand
342 MacBook Pro 10
345 Lenovo PC 55
346 4GB Memory 100
347 500GB HD 6

Shipment Table
ItemNo Description Quantity
Received
342 MacBook Pro 1
345 Lenovo PC 5
347 500GB HD 3
352 1TB External Drive 4

Notice that there is one additional item in the Shipment table. Now, let’s write the
merge statement to update the Item table. If the record exists in Item, then we will
add to the quantity on hand. If it does not, then we will add the record.

MERGE INTO Item_T AS ITM


USING (SELECT ItemNo, Description, QuantityReceived FROM
Shipment_T) AS SH
ON (ITM.ItemNo = SH.ItemNo)
WHEN MATCHED THEN UPDATE
SET QuantityOnHand = ITM.QuantityOnHand +
SH.QuantityReceived
WHEN NOT MATCHED THEN INSERT
(ItemNo, Description, QuantityOnHand)
VALUES (SH.ItemNo, SH.Description,
SH.QuantityReceived);

Copyright © 2016 Pearson Education, Inc.


12 Modern Database Management, Eleventh Edition

SQL clause processing order:

In a SELECT statement, the processing of clauses follows the order shown in


Figure 6-10, and reproduced below:

 the FROM clause is evaluated first (sources of data)


 then:
WHERE (criteria to be met, if stated), and/or
GROUP BY (organizes rows according to values in stated column(s)),
and
HAVING (finds groups meeting criteria), and
 then SELECT (particular columns to show/display), and
 then ORDER BY (sorts rows in result table).

SQL clause & derived table creation:

A derived table can be defined in the FROM clause of an SQL statement.

ORDER BY clause & sort order:

In an ORDER BY clause, the columns to be sorted can be referred to by: (1)


column name from the actual table referenced in the FROM clause, or (2) column
position in the SELECT clause list.

CHECK clause usage:

In a CREATE TABLE command, the CHECK clause allows for validation rules
for values to be inserted into the database, such as only allowing the Product_T
table to have rows of products that meet a checklist of certain ProductFinish
values (e.g., such as Cherry, Natural Ash, White Ash, Red Oak, Natural Oak, and
Walnut). In a CREATE VIEW command, the WITH CHECK OPTION ensures
that data entered into the database through a View meets the specifications stated
in the WITH CHECK OPTION element of the View definition. For example,
when a View is created with a criterion (or criteria) specification (e.g., all
products with price > $300) and the WITH CHECK OPTION enabled, any SQL
UPDATE or INSERT commands against the View that would violate the criterion
of Price needing to be $300 or more would be rejected.

ALTER command usage:

The ALTER command may be used to add new columns, change existing
columns (name, data type, length, constraints, and default values), delete columns,
add constraints, and delete constraints of a Table. The ALTER command may not
be used with Views, nor can the ALTER command change the order of columns
within a Table.

Copyright © 2016 Pearson Education, Inc.


Chapter 6 13

Difference between the WHERE and HAVING clauses in an SQL query

This difference is relevant for aggregate queries using GROUP BY because that is
the context in which HAVING is used. WHERE clause limits the number of rows
that will be considered in the processing specified in the SQL query, whereas
HAVING is used to limit output rows (summarized groups) based on criteria that
apply to aggregate function values. For example, let’s assume that we have
products and product lines in a simple database, and we want to know the average
product price by product line but limit the results to a) only to those products that
cost more than $1,000 and b) to those product lines where the average price is
higher than $10,000. The following query achieves that:

SELECT ProdLineNbr, AVG(ProdPrice)


FROM Product
WHERE ProdPrice > 1000
GROUP BY ProdLineNbr
HAVING AVG(ProdPrice) > 10000;

In this case, WHERE limits the query to consider only those Products that cost
more than $1,000 and HAVING limits the output to those Product lines that have
an average ProdPrice greater than $10,000.

Usage of both WHERE and HAVING clauses?

Yes, a query may use both the WHERE and HAVING clauses. The WHERE
clause would restrict which rows are included for processing by the query. The
HAVING clause (used in conjunction with a GROUP BY clause) determines
which summarized groups are included in the result set.

Answers to Problems and Exercises

Note to Instructor: The solutions that include SQL statements are not intended
as the definitive answer to the questions, but as possible solutions. Instructors and
students will approach the problems using different SQL capabilities, achieving
results that are also correct.

Solutions are presented with SQL syntax that should work in most Oracle
installations (unless noted otherwise; for example, some examples follow the MS
Access syntax). Solutions may need to be modified for a particular Oracle
installation or if you are using a different relational database management system
(e.g., Teradata) to illustrate the use of SQL commands. The solutions in this
chapter and the following chapter use the naming conventions for tables,
relations, attributes/columns, and views as shown in the textbook chapters,
although Oracle SQL is not Upper/Lower case sensitive except when querying
metadata (e.g., table names).

Copyright © 2016 Pearson Education, Inc.


14 Modern Database Management, Eleventh Edition

Database descriptions:

Note: A particular SQL system may restrict the length of column names or may
not permit embedded spaces in names. The following answer may not be
acceptable to the SQL system you use; please modify the grammar accordingly.

CREATE TABLE Student


(StudentID NUMBER NOT NULL,
StudentName VARCHAR2(25),
CONSTRAINT Student_PK PRIMARY KEY (StudentID));

CREATE TABLE Faculty


(FacultyID NUMBER NOT NULL,
FacultyName VARCHAR2(25),
CONSTRAINT Faculty_PK PRIMARY KEY (FacultyID));

CREATE TABLE Course


(CourseID CHAR(8) NOT NULL,
CourseName VARCHAR2(15),
CONSTRAINT Course_PK PRIMARY KEY
(CourseID));

CREATE TABLE Section


(SectionNo NUMBER NOT NULL,
Semester CHAR(7) NOT NULL,
CourseID CHAR(8),
CONSTRAINT Section_PK PRIMARY KEY(SectionNo),
CONSTRAINT Section_FK FOREIGN KEY (CourseID)
REFERENCES Course (CourseID));

CREATE TABLE Qualified


(FacultyID NUMBER NOT NULL,
CourseID CHAR(8) NOT NULL,
DateQualified DATE,
CONSTRAINT IsQualified_PK PRIMARY KEY
(FacultyID, CourseID),
CONSTRAINT QualifiedFaculty_FK FOREIGN
KEY (FacultyID) REFERENCES Faculty
(FacultyID),
CONSTRAINT QualifiedCourse_FK FOREIGN KEY
(CourseID) REFERENCES Course (CourseID));

CREATE TABLE Registration


(StudentID NUMBER NOT NULL,
SectionNo NUMBER NOT NULL,
CONSTRAINT IsRegistered_PK PRIMARY KEY
(StudentID, SectionNo),

Copyright © 2016 Pearson Education, Inc.


Chapter 6 15

CONSTRAINT StudentIsRegistered_FK
FOREIGN KEY(StudentID)
REFERENCES Student(StudentID),
CONSTRAINT CourseIsRegistered_FK
FOREIGN KEY (SectionNo)
REFERENCES
Section(SectionNo));

Normalization status of the database

In its current form, the data is fully normalized. The question referred to an older
form of the database.

Creating a view

CREATE VIEW Student_V AS


SELECT StudentID, StudentName FROM Student_T;

Referential integrity & SQL clause usage in DDL

See the SECTION_FK constraint in the DDL for the SECTION table in Problem
and Exercise 6-34 above.

SQL Definition commands

a.

ALTER TABLE Student_T


ADD Class VARCHAR2(5);
b.

DROP TABLE Registration_T;


c.

ALTER TABLE Faculty_T


MODIFY FacultyName VARCHAR2(40);

Note: CHANGE instead of MODIFY also usually works.

SQL commands: INSERT, DELETE, UPDATE

a.

INSERT INTO Student_T (StudentID, StudentName)


VALUES (65798, 'Lopez');
INSERT INTO Student_T VALUES (65798, 'Lopez');
b.

Copyright © 2016 Pearson Education, Inc.


16 Modern Database Management, Eleventh Edition

DELETE FROM Student_T WHERE StudentID = 65798;


c.

UPDATE Course_T
SET CourseName = 'Introduction to Relational Databases'
WHERE CourseID = 'ISM 4212';

SQL queries

a.

SELECT StudentID, StudentName


FROM Student_T
WHERE StudentID < 50000;
b.

SELECT FacultyName
FROM Faculty_T
WHERE FacultyID = 4756;
c.

SELECT MIN(SectionID)
FROM Registration_T
WHERE Semester = 'I-2016';

SQL queries

a.

SELECT COUNT(*)
FROM Registration_T
WHERE Section = 2714
AND Semester = 'I-2015';
b.

SELECT FacultyID,CourseID,DateQualified
FROM Qualified_T
WHERE DateQualified >= '01-JAN-2008';

SQL queries

a. We assume all the question wishes in the result set are the Student IDs. The
Database course is ISM 4212, which is Section 2714 in the Registration_T
table, and the Networking course is ISM 4930, which is Section 2715 in the
Registration_T table:

SELECT StudentID,COUNT(*)
FROM Registration_T

Copyright © 2016 Pearson Education, Inc.


Chapter 6 17

WHERE SectionNo IN (2714,2715)


GROUP BY StudentID
HAVING COUNT(*) > 1;

b. In answering this question, we assume we are not interested in seeing those


instructors who can teach neither course, but rather only those who can teach
one but not the other course. To find those instructors who cannot teach either
course requires SQL capabilities introduced in Chapter 7:

SELECT FacultyID,COUNT(*)
FROM Qualified_T
WHERE CourseID IN ('ISM 3113', 'ISM 3112')
GROUP BY InstructorID
HAVING COUNT(*) = 1;

c. Using Chapter 6 SQL tools, a user could use two single table queries over the
SECTION table and then manually inspect the results to find the courses that
are taught in first semester but not in the second semester. This manual
inspection solution works moderately well when there are few rows in the
tables. Another possible manual solution is to list all the courses sorted by
CourseID and Semester from the SECTION table, and then manually inspect
the entries to find those with only first semester offerings. Again, this
approach works moderately well if there are few rows in the tables.

Using some Chapter 7 tools, the following query could be used to find the
requested information from the database:

SELECT CourseID, Semester


FROM Section_T
WHERE Semester = 'I-2015'
AND CourseID NOT IN
(SELECT CourseID FROM SECTION Where Semester = 'II-2015');

SQL queries

a.

SELECT DISTINCT CourseID


FROM Section_T;
b.

SELECT StudentName
FROM Student_T
ORDER BY StudentName;
c.

SELECT SectionNo,Semester,StudentID

Copyright © 2016 Pearson Education, Inc.


18 Modern Database Management, Eleventh Edition

FROM Registration_T
WHERE Semester = 'I-2015'
ORDER BY SectionNo,Semester,StudentID;
d.

SELECT CourseID,CourseName
FROM Course_T
ORDER BY CourseID ASC;

SQL queries

a.

SELECT SectionNo
FROM Section_T
WHERE CourseID = 'ISM 3113' AND
Semester = 'I-2015';
b.
SELECT CourseID, CourseName
FROM Course_T
WHERE CourseName LIKE 'Data%';
c.
SELECT FacultyID
FROM Qualified_T
WHERE CourseID IN ('ISM 3112', 'ISM 3113')
GROUP BY FacultyID
HAVING COUNT(CourseID)>1;
d.
SELECT FacultyID
FROM Qualified_T
WHERE CourseID IN ('ISM 3112', 'ISM 3113') AND
DateQualified > '31-DEC-2005'
GROUP BY FacultyID
HAVING COUNT(CourseID)>1;

e.

This query requires the missing Assignment table and use of data from multiple
tables

SELECT FacultyID
FROM Assignment_T
WHERE Semester = 'II-2015' AND
SectionNo IN (
SELECT SectionNo
FROM Section_T
WHERE CourseID = 'ISM 4212');

Copyright © 2016 Pearson Education, Inc.


Chapter 6 19

Problems 10-15 are based on Figure 6-12, Adult Literacy situation

a. Query: How many tutors have status of Temp Stop?

SELECT COUNT(TutorID) AS NUMTSTOP


FROM Tutor
WHERE Status = 'Temp Stop';

b. Query: Which tutors are active?

SELECT TutorID
FROM Tutor
WHERE Status = 'Active';

SQL queries

a. Query: What is the average Read score for all students?

SELECT AVG(Read)
FROM Student;

b. Query: What are the minimum and maximum Read scores?

SELECT MIN(Read), MAX(Read)


FROM Student;

Query: List the IDs of the tutors who are currently tutoring more than one
student.

SELECT TutorID
FROM MatchHistory
GROUP BY TutorID
HAVING COUNT(StudentID)>1;

Query: What are TutorIDs for tutors who have not yet tutored anyone?

Using Chapter 6 tools, a user could formulate two single table queries over the
database and then manually inspect the query results to find the required
information. For instance, a query over the TUTOR table will provide TutorIDs
of all Tutors and a query of DISTINCT TutorIDs from the MATCH_HISTORY
table will provide a listing of all currently matched Tutors. By manual inspection
of these two query result lists, one can find the “missing” TutorIDs from the
MATCH_HISTORY table. For a database such as this one, with a small number

Copyright © 2016 Pearson Education, Inc.


20 Modern Database Management, Eleventh Edition

of rows, a user could still find the information easily. As tables grow in size, such
a multiple step manual inspection process becomes less feasible as a practical
matter.

Using Chapter 7 tools, the following query could be used to get the information:

SELECT TutorID
FROM Tutor
WHERE TutorID NOT IN
(SELECT TutorID FROM MATCH_HISTORY);

Query: How many students are matched with someone in first five months of
year?

SELECT COUNT(StudentID)
FROM Match_History
WHERE StartDate BETWEEN '01-JAN-2015' AND '31-MAY-2015';

Query: Which student has highest Read score?

SELECT Read, StudentID


FROM Student
ORDER BY Read DESC;

Note to Instructor: For 6-51 and 6-53, be sure the student realizes that a null
value in ENDDATE means that a student is still studying in the program and
should be included in the calculation. This is a good opportunity for the student to
discover that a calculated field can be quite useful where null values can be
expected. You may want to emphasize that this query will not update the base
table and these null values will remain until a student leaves the program.

This answer is shown in MS ACCESS SQL and uses the NZ function, which is
not covered in the text, to deal with the null dates. If no date is entered as an end
date in the dialog box, today’s date is inserted automatically for null values. As
the NZ function is used here, it will return the number of days the student has
studied into the calculated field.

Query: How long had each student studied in the adult literacy program?

SELECT StudentID, StartDate, EndDate,


DateDiff(“d”,[StartDate],NZ([EndDate], NZ
[Enter date for blank records], Date()))) AS
TotalDays
FROM Match_History;

Copyright © 2016 Pearson Education, Inc.


Chapter 6 21

Query: Which tutors have a Dropped status and have achieved their certification
after 4/01/2015?

SELECT TutorID
FROM Tutor
WHERE Status = 'Dropped' AND
CertDate > '1-APR-2015';

Query: What is the average length of time a student stayed (or has stayed) in the
program?

This query needs to use the TotalDays information calculated in 6-53, but as the
average function aggregates all rows, a two-step query will be needed to complete
the problem. This problem also demonstrates using a query as the base for another
query rather than working from a base table.

a. Query: (Answer assumes this query is named CH6P53_First Query.)

SELECT DateDiff('d',[StartDate],NZ([EndDate], NZ
[Enter date for blank records], Date()))) AS
TotalDays
FROM Match_History;

b. Query:

SELECT AVG(TotalDays) AS [AverageTime]


FROM CH6P53_FirstQuery;

Queries related to the Pine Valley Furniture Company

Note to instructor: Problems and Exercises 6-54 – 6-85 are based on the
extended version of the Pine Valley Furniture Company database. (BigPVFC.mdb
is the MS Access file version of this database; this is also available on Teradata
student resources.) Please note that this version of the database has a different
structure than that in the textbook version of the database (e.g., the salesperson
information is in the extended version but not in the textbook version). Some of
the field names may also have changed due to the version of the database you are
using due to the reserved words of the DBMS. When you first use the database,
check the table definitions to see what the exact field names and table structures
are for the DBMS that you are using.

Copyright © 2016 Pearson Education, Inc.


22 Modern Database Management, Eleventh Edition

Add attribute to Product_T table

ALTER TABLE Product_T


ADD QtyOnHand NUMBER(5) CHECK (QtyOnHand >=0);

Enter sample data:

Students should answer this exercise using a series of UPDATE commands to


SET values for this new field in each existing row of the Product_T table. If using
Oracle and the CHECK option, students should receive error messages if they
attempt to enter negative values for QtyOnHand values.

Add Order to Order_T table:

Students should answer this exercise using INSERT commands to enter new rows
into the Order_T and OrderLine_T tables.

PVFC queries:

Although the data in this table is sparsely populated and the answers to these
questions can be found by simple inspection of the table values, encourage the
students to write SQL to derive the results:

a.

SELECT COUNT(*)
FROM WorkCenter_T;

b.

SELECT WorkCenterLocation
FROM WorkCenter_T;

Employees whose name begins with “L”:

Query:

SELECT EmployeeID,EmployeeName
FROM Employee_T
WHERE EmployeeName LIKE 'L%';

Employees hired during 2005:

Query:

SELECT EmployeeName
FROM Employee_T
WHERE EmployeeDateHired BETWEEN '01-JAN-2005'
AND '31-DEC-2005';

Copyright © 2016 Pearson Education, Inc.


Chapter 6 23

Customers who live in California or Washington, ordered by descending zip code:

Query:

SELECT CustomerID, CustomerName


FROM Customer_T
WHERE CustomerState IN ('WA', 'CA')
ORDER BY CustomerPostalCode DESC;

OR

SELECT CustomerID, CustomerName


FROM Customer_T
WHERE CustomerState = 'WA'
OR CustomerState = 'CA'
ORDER BY CustomerPostalCode DESC;

Number of customers per state included in the Customer_T table:

SELECT CustomerState, COUNT(CustomerID)


FROM Customer_T
GROUP BY CustomerState;

All raw materials made of cherry and 12 x 12 dimensions:

Note: The query shown here is an MS-Access query. If using Oracle, simply
replace the double quotes with single quotes.

Query:

SELECT MaterialID, MaterialName


FROM RawMaterial_T
WHERE Material = “Cherry” AND Thickness =“12” AND Width =
“12”;

Material ID, name, material, standard cost, and thickness for raw materials made
of cherry, pine, or walnut. Order the list by material, standard cost, and
thickness:

Note: The query shown here is an MS-Access query. If using Oracle, simply
replace the double quotes with single quotes. Also, an alternative solution is to
use the OR operator rather than the IN operator, as in Problem & Exercise 6-60
above.

Query:

Copyright © 2016 Pearson Education, Inc.


24 Modern Database Management, Eleventh Edition

SELECT MaterialID, MaterialName, Material,


MaterialStandardPrice, Thickness
FROM RawMaterial_T
WHERE Material IN (“Cherry”, “Pine”, “Walnut”)
ORDER BY Material, MaterialStandardPrice, Thickness;

Display the product line ID and the average standard price for all products in
each product line:

Query:

SELECT ProductLineID, AVG(ProductStandardPrice)


FROM Product_T
GROUP BY ProductLineID;

For every product that has been ordered, display the product ID and the total
quantity ordered (label this result TotalOrdered). List the most popular product
first and the least popular last:

Query:

SELECT ProductID, SUM(OrderedQuantity) AS TotalOrdered


FROM OrderLine_T
GROUP BY ProductID
ORDER BY SUM(OrderedQuantity) DESC;

Customer ID and total number of orders placed:

Query:

SELECT CustomerID,COUNT(OrderID) AS TotOrders


FROM Order_T
GROUP BY CustomerID;

Each salesperson’s list of customers, by ID:

Query:

SELECT DISTINCT SalespersonID, CustomerID


FROM Order_T
ORDER BY SalespersonID;

Display the product ID and the number of orders placed for each product. Show
the results in decreasing order, and label result column NumOrders:

Query:

SELECT ProductID, COUNT(ProductID) AS NumOrders

Copyright © 2016 Pearson Education, Inc.


Chapter 6 25

FROM OrderLine_T
GROUP BY ProductID
ORDER BY COUNT(ProductID) DESC;

Customer ID and total orders placed in 2015:

In MS-Access, the query would be written as follows:

SELECT Order_T.CustomerID,
COUNT(Order_T.OrderID) AS TotOrders
FROM Order_T
WHERE (((Order_T.OrderDate) Between #1/1/2015# AND
#12/31/2015#))
GROUP BY Order_T.CustomerID;

In Oracle, the query would be written as follows:

SELECT CustomerID,
COUNT(OrderID) AS TotOrders
FROM Order_T
WHERE OrderDate Between '01-Jan-2015' AND
'31-Dec-2015'
GROUP BY CustomerID;

Total number of orders for each salesperson:

Query:

SELECT SalespersonID,count(OrderID) AS TotalOrders


FROM Order_T
GROUP BY SalespersonID;

Customer ID and total orders placed if more than two orders were placed:

Query:

SELECT CustomerID, COUNT(OrderID) as TotOrders


FROM Order_T
GROUP BY CustomerID
HAVING COUNT(OrderID) > 2;

All sales territories that have more than one salesperson: (Note: We also show
the number of salespeople for each territory.)

Query:

SELECT SalesTerritoryID, COUNT(SalespersonName) AS


NumSalesPeople
FROM Salesperson_T

Copyright © 2016 Pearson Education, Inc.


26 Modern Database Management, Eleventh Edition

GROUP BY SalesTerritoryID
HAVING COUNT(SalespersonName) > 1;

ProductID of most frequently ordered product:

Note: Because subqueries have not been covered yet, the student should just order
the query by the total orders and report on the top ProductID (or ProductIDs if
more than one):

Query:

SELECT ProductID,
COUNT(*) AS NumOrders
FROM OrderLine_T
GROUP BY ProductID
ORDER by COUNT(*) DESC;

An alternate approach in SQL-Server or MS-Access is to use the TOP predicate:

Query:

SELECT TOP 1 ProductID, COUNT(*) AS NumOrders


FROM OrderLine_T
GROUP BY ProductID;

Measured by average standard price, what is the least expensive product finish?

Query:

SELECT ProductFinish, AVG(ProductStandardPrice)


FROM Product_T
GROUP BY ProductFinish
ORDER BY AVG(ProductStandardPrice) ASC;

Note: This response includes the average prices for all finishes.

For every territory having more than one salesman, display SalesTerritoryID and
the number of salespersons in the territory:

Query:

SELECT SalesTerritoryID, COUNT(*) AS NumSalesPersons


FROM Salesperson_T
GROUP BY SalesTerritoryID
HAVING COUNT(*) > 1;

Number of orders for each salesperson except salespersons 3, 5, and 9:

Query:

Copyright © 2016 Pearson Education, Inc.


Chapter 6 27

SELECT SalespersonID, COUNT(*)


FROM Order_T
WHERE SalespersonID NOT IN (3, 5, 9)
GROUP BY SalespersonID;

Each salesperson’s number of orders placed for each month of 2015.

The solution is shown here in both MS-Access and Oracle:

MS-Access
SELECT SalespersonID, month(OrderDate) AS Month,
COUNT(OrderID) as TotalOrders
FROM Order_t
WHERE OrderDate BETWEEN #01/01/2015# and #12/31/2015#
GROUP BY SalespersonID, month(OrderDate)
ORDER BY SalespersonID,month(OrderDate);

Oracle
SELECT SalespersonID,
TO_CHAR(OrderDate, 'MON') AS Month,
COUNT(OrderID) AS TotalOrders
FROM Order_T
WHERE OrderDate BETWEEN '01-Jan-2015' AND
'31-Dec-2015'
GROUP BY
SalespersonID,TO_CHAR(OrderDate, 'MON')
ORDER BY
SalespersonID,TO_CHAR(OrderDate, 'MON');

Material name, material, and width for raw materials that are not cherry or oak
and whose width is greater than 10 inches.

Note: This query is in an Oracle format. If you want to use it with Access, please
replace the single quotes with double quotes.

Query:

SELECT MaterialName, Material, Width


FROM RawMaterial_T
WHERE Material NOT IN ('Cherry', 'Oak')
AND Width > 10;

Copyright © 2016 Pearson Education, Inc.


28 Modern Database Management, Eleventh Edition

Suggested Venn Diagram:

ProductID, ProductDescription, ProductFinish, and ProductStandardPrice for


oak products with price > 400 or cherry products with price < 300:

Query:

SELECT ProductID, ProductDescription, ProductFinish,


ProductStandardPrice
FROM Product_T
WHERE (ProductFinish = 'Oak' and ProductStandardPrice >
400) OR
(ProductFinish = 'Cherry' and ProductStandardPrice <
300);

Although not asked by the problem and exercise, an alternative solution might
sort the output, as follows:

SELECT ProductID, ProductDescription, ProductFinish,


ProductStandardPrice
FROM Product_T
WHERE (ProductFinish = 'Oak' and ProductStandardPrice >
400) OR
(ProductFinish = 'Cherry' and ProductStandardPrice <
300)
ORDER BY ProductFinish, ProductStandardPrice;

Copyright © 2016 Pearson Education, Inc.


Chapter 6 29

Suggested Venn Diagram:

OrderID, CustomerID, OrderDate and most recent date among orders:

Query:

Write the query to find the most recent date among orders:
SELECT MAX(OrderDate) AS MostRecent FROM Order_T;

Then, use this query as a derived table to access with the FROM clause:
SELECT OrderID, CustomerID, OrderDate,
(SELECT MAX(OrderDate) AS MostRecent FROM ORDER_T) AS
MostRecent
FROM Order_T;

Copyright © 2016 Pearson Education, Inc.


30 Modern Database Management, Eleventh Edition

Suggested Venn Diagram:

CustomerID, number of orders from that customer, total number of orders from
all customers combined, and the ratio of that customer’s orders to all customer
orders:

Query:

/* first, get the total number of orders */

SELECT COUNT(OrderID) AS AllOrders FROM Order_T;

/* then, get the count by individual customers */


SELECT CustomerID, COUNT(OrderID) AS CustOrders
FROM Order_T
GROUP BY CustomerID;

/* finally, combine these two queries to get ratio displayed */


SELECT Order_T.CustomerID,
COUNT(OrderID) AS OrderCount,
AllOrders,
COUNT(OrderID)/AllOrders AS RATIO
FROM Order_T,
(SELECT COUNT(OrderID) AS AllOrders FROM Order_T)
GROUP BY Order_T.CustomerID, AllOrders;

Copyright © 2016 Pearson Education, Inc.


Random documents with unrelated
content Scribd suggests to you:
slowly and earnestly. They were at the mouth of the inlet. As she
spoke, she luffed sharply and they entered it close-hauled.
"Yes," she repeated, speaking still more earnestly, "I am very glad of
that. It makes me feel much easier in my mind about what I am
going to do."
Her tone startled him. He looked up at her quickly and anxiously.
"What are you going to do?" he asked.
"Drown you," she answered simply.
For an instant he did not take in the meaning of her words. Then his
face became very white, though he tried to smile. His voice shook as
he said: "I do not think that this is a good time for joking." The boat
was biting her way into the wind sharply, plunging and bucketing
through the partly spent waves which came in from outside.
"You know that I am not joking," Ulrica answered very quietly. "I am
going to drown you, and to drown myself too. I have thought it all
out, and this seems the best thing to do. It is the best for father,"
her voice trembled, "and it is the best," she went on again, firmly,
"for me. As for you, it does not matter whether it is the best for you
or not—it is what you deserve. For you are a liar and a traitor—a liar
and a traitor to me, and to that other woman too!" As she spoke
these last words her calmness left her, and there was the ring of
passionate anger in her tone. The fire that she had been
smothering, at last was in full blaze.
They were at the very mouth of the inlet. The white-capped surface
of the lake swelled and tossed before them. The boat was wallowing
heavily.
Maltham's paleness changed to a greenish-grey. He uttered a shrill
scream—a cry of weakly helpless terror. "Put about! For God's sake
put about!" he gasped. "We shall be drowned!"
For answer, she hauled the sheet a little and brought the boat still
closer into the wind—heading straight out into the lake. "I told you
once that the Nixie could sail into the wind's eye," she said, coolly.
"Now she is doing it. Does she not go well?"
At that, being desperate, he rallied a little. Springing to his feet, but
standing unsteadily, he grasped the tiller and tried to shift the helm.
Ulrica, standing firmly, laid her hand flat against his breast and
thrust him away savagely—with such force that he reeled backward
and fell, striking against the combing and barely missing going over
the side.
"You fool!" she exclaimed. "Do you not see that it is too late?" She
did not trouble herself to look at him. Her gaze was fixed in a keen
ecstasy on the great oncoming waves.
What she said was true—it was too late. They were fairly out on the
open lake, and all possibility of return was gone. To try to go about
would be to throw the Nixie into the trough of the sea—and so send
her rolling over like a log. At the best, the little boat could live in that
surge and welter for only a very few minutes more.
Maltham did not attempt to rise. His fall had hurt him, and what little
was left of his spirit was cowed. He lay in a miserable heap, uttering
little whimpering moans. The complaining noise that he made
annoyed her. For the last time she looked at him, burning him for an
instant with her glowing eyes. "Silence, you coward!" she cried,
fiercely—and at her strong command he was still. Then her look was
fixed on the great oncoming waves again, and she cast him out from
her mind.
Even in her rage—partly because of it—Ulrica felt in every drop of
her Norse blood the glow and the thrill of this glorious battle with
great waters. The sheer delight of it was worth dying for—and so
richly worth living through to the very last tingling instant that she
steered with a strong and a steady hand. And again—as she stood
firmly on the tossing boat, her draperies blown close about her, her
loosened hair streaming out in golden splendour—she was Aslauga's
very self. Sorrow and life together were ending well for her—in high
emotion that filled and satisfied her soul. Magnificent, commanding,
defiant, she sailed on in joyful triumph: glad and eager to give
herself strongly to the strong death-clasp of the waves.
The Death-Fires of Les Martigues

"God keep you from the she-wolf, and from your heart's deep
desire!"
That is one of our old sayings here in Provence. I used to laugh at it
when I was young. I do not laugh at it now. When those words
come into my heart, and they come often, I go by the rough hard
way that leads upward to Notre Dame de la Garde until I come to
the Crime Cross—it is a wearying toil for me to get up that steep hill-
side, I am so stiff and old now—and there I cast fresh stones upon
the heap at the foot of the cross. Each stone cast there, you know,
is a prayer for forgiveness for some hidden crime: not a light fault,
but a crime. The stones must be little stones, yet the heap is very
wide and high—though every winter, when the great mistrals are
blowing across the Étang de Berre, the little stones are whirled away
down the hill-side. I do not know how this custom began, nor when;
but it is a very old custom with us here in Les Martigues.
Once in every year I go up to the Crime Cross by night. This is on All
Souls Eve. First I light the lamp over Magali's breast where she lies
sleeping in the graveyard: going to the graveyard at dusk, as the
others do, in the long procession that creeps up thither from the
three parts of our town—from Jonquières, and the Isle, and Ferrières
—to light the death-fires over the dear dead ones' graves. I go with
the very first, as soon as the sun is down. I like to be alone with
Magali while I light the little lamp that will be a guide for her soul
through that night when souls are free; that will keep it safe from
the devils who are free that night too. I do not like the low buzzing
of voices which comes later, when the crowd is there, nor the broken
cries and sobs. And when her lamp is lit, and I have lit my mother's
lamp, I hurry away from the graveyard and the moaning people—
threading my steps among the graves on which the lights are
beginning to glimmer, and through the oncoming crowd, and then by
the lonely path through the olive-orchards, and so up the stony
height until I come at last to the Crime Cross—panting, aching—and
my watch begins.
MARIUS
Up on that high hill-side, open to the west, a little of the dying
daylight lingers. Eastward, like a big black mirror, lies the great
étang; and far away across its still waters the mountain chain above
Berre and Rognac rises purple-grey against the darker sky. In the
west still are faint crimson blotches, or dashes of dull blood-red—
reflected again, and made brighter, in the Étang de Caronte: that
stretches away between the long downward slopes of the hills, on
which stone-pines stand out in black patches, until its gleaming
waters merge into the faint glow upon the waters of the
Mediterranean. Above me is the sanctuary of Notre Dame de la
Garde, a dark mass on the height above the olive-trees: of old a
refuge for sinful bodies, and still a refuge where sinful souls may
seek grace in prayer from their agony. And below me, on the slope
far downward, is the graveyard: where the death-fires multiply each
moment, as more and more lamps are lighted, until at last it is like a
little fallen heaven of tiny stars. Only in its midst is an island of
darkness where no lamps are. That is where the children lie
together: the blessed innocents who have died sinless, and who
wander not on All Souls Eve because when sweet death came to
them their pure spirits went straight home to God. And beyond the
graveyard, below it, is the black outspread of the town: its blackness
deepened by a bright window here and there, and by the few street
lamps, and by the bright reflections which shine up from the waters
of its canals.
Seeing all this—yet only half seeing it, for my heart is full of other
things—I sit there at the foot of the Crime Cross in the darkness,
prayerful, sorrowful, while the night wears on. Sometimes I hear
footsteps coming up the rocky path, and then the shadowy figure of
a man or of a woman breaks out from the gloom and suddenly is
close beside me—and I hear the rattle of little stones cast upon the
heap behind me, on the other side of the cross. Presently, the rite
ended, whoever it is fades back into the gloom again and passes
away. And I know that another sinful soul has been close beside my
sinful soul for a moment: seeking in penitent supplication, as I am
seeking, rest in forgiveness for an undiscovered crime. But I am sure
that none of them sees—as I see in the gloom there always—a
man's white face on which the moonlight is shining, and beyond that
white face the glint of moonlight on a raging sea; and I am sure that
on none of their blackened souls rests a burden as heavy as that
which rests on mine.
I am very weary of my burden, and old and broken too. It is my
comfort to know that I shall die soon. But, also, the thought of that
comfort troubles me. For I am a lone man, and childless. When I go,
none of Magali's race, none of my race, will be left alive here in Les
Martigues. Our death-fires will not be lighted. We shall wander in
darkness on All Souls Eve.

II

"God keep you from the she-wolf, and from your heart's deep
desire!"
My old mother, God rest her, said that to me when first she began to
see that my love was set on Magali—and saw, too, that I was
winning from Magali the love that belonged to Jan, who had her
promise.
"It is an old man's lifetime, mother," I said, "since a wolf has been
seen near Les Martigues." And I laughed and kissed her.
"Worse than a wolf is a heart that covets what it may not have,
Marius," she answered. "Magali is as good as Jan's wife, and you
know it. For a year she has been promised to him. She is my dead
sister's child, and she is in my care—and in your care too, because
you and she and I are all that is left of us, and you are the head of
our house, the man. You are doing wickedness in trying to take her
away from Jan—and Jan your own close friend, who saved your life
out of the sea. The match is a good match for Magali, and she was
contented with it until you—living here close beside her in your own
house—began to steal away her heart from him. It is rascal work,
Marius, that you are doing. You are playing false as a house-father
and false as a friend—and God help me that I must speak such
words to my own son! That is why I say, and I say it solemnly, 'God
keep you from the she-wolf, and from your heart's deep desire!' That
desire has no right to be in your heart, Marius. Drag it out of your
heart and cast it away!"
But I only laughed and kissed her again, and told her that I would
take good care of myself if a she-wolf tried to eat me—and so I went
away, still laughing, to my fishing in the Gulf of Fos.
But I did not laugh when I was alone in my boat, slipping down the
Étang de Caronte seaward. What she had said had made me see
things clearly which until then had been half hid in a haze. We had
slipped into our love for each other, Magali and I, softly and easily—
just as my boat was slipping down the étang. Every day of our lives
we were together, in the close way that housemates are together in
a little house of four rooms. Before I got up in the morning I could
hear her moving near me, only a thin wall between us; and her
movements, again, were the last sounds that I heard at night. She
waited on me at my meals. She helped my mother to mend my
clothes—the very patches on my coat would bring to my mind the
sight of her as she sat sewing at night beside the lamp. We were as
close together as a brother and a sister could be; and in my dulness
I had fancied for a long while that what I had felt for her was only
what a brother would feel.
What first opened my eyes a little was the way that I felt about it
when she gave her promise to Jan. For all our lives Jan and I had
been close friends: and most close since that day when the squall
struck our boats, as we lay near together, and I went overboard, and
Jan—letting his own boat take its chances—came overboard after
me because he knew that I could not swim. It was by a hair's-
breadth only that we were not drowned together. After we were safe
I told him that my life was his. And I meant it, then. Until Magali
came between us I would have died for him with a right good will.
After that I was ready enough that he should do the dying—and so
be gone out of my way.
When he got Magali's promise, I say, my ugly feeling against him
began. But it was not very strong at first, and I was not clear about
it in my own mind. All that I felt was that, somehow, he had got
between me and the sun. For one thing, I did not want to be clear
about it. Down in the roots of me I knew that I had no right to that
sunshine, and that Jan had—and I could not help thinking about
how he had come overboard after me and had held me up there in
the tumbling sea, and how I had told him that my life was his. But
with this went a little thin thought, stirring now and then in the
bottom of my mind though I would not own to it, that in giving him
my life—which still was his if he wanted it—I had not given him the
right to spoil my life for me while leaving me still alive. And I did my
best not to think one way or the other, and was glad that it all was a
blur and a haze.
And all the while I was living close beside Magali in that little house,
with the sound of her steps always near me and the sound of her
voice always in my ears. She had a very sweet voice, with a
freshness and a brightness in it that seemed to me like the
brightness of her eyes—and Magali's great black eyes were the
brightest eyes that ever I saw. Even in Arles, where all the women
are beautiful, there would be a buzz among the people lining Les
Lices when Magali walked there of a feast-day, wearing the beautiful
dress that our women wear here in Provence. To look at her made
you think of an Easter morning sun.

III

"God keep you from the she-wolf, and from your heart's deep
desire!"
My mother's words kept on ringing in my ears after I had left her.
Suddenly the haze was gone and I saw clearly—and I knew that my
heart's deep desire was to have Magali for my very own. And with
that sudden coming of clear sight I knew, too, that I could have her.
Out of the past came a crowd of memories which proved it to me. In
my dull way, I say, I had fancied that I loved Magali as a sister, and I
had tried to keep that fancy always by me in my haze. But with the
haze gone—swept away by my mother's words as the mistral
sweeps away our Mediterranean fogs—I knew that Magali never had
been the fool that I had been.
I remembered her looks and her ways with me from the very day
when she came to us, when she was just turned of sixteen: how she
used sometimes to lay her hand lightly on my shoulder, how she
would bend over to look at the net that I was mending until her hair
brushed against my cheek or my forehead, how she always was
bringing things to show me that I could not see rightly unless she
stood very close at my side, and most of all how a dozen times a day
she would be flashing at me her great black eyes. And I
remembered how moody and how strange in her ways she was just
before Jan got his promise from her; and how, when she told me
that her promise was given, she gave me a look like none that ever I
had from her, and said slowly: "The fisherman who will not catch any
fish at all because he cannot catch the fish he wants most—is a fool,
Marius!"
Yet even then I did not understand; though, as I say, my eyes were
opened a little and I had the feeling that Jan had got between me
and the sun. That feeling grew stronger because of the way that she
treated him and treated me. Jan was for hurrying the marriage, but
she kept him dangling and always was putting him off. As for me, I
got all sides of her moods and tempers. Sometimes she scarcely
would speak to me. Sometimes she would give me looks from those
big black eyes of hers that thrilled me through! Sometimes she
would hang about me in a patient sad way that made me think of a
dog begging for food. And the colour so went out of her face that
her big black eyes looked bigger and blacker still.
Then it was that I began to find in the haze that was about me a
refuge—because I did not want to see clear. I let my thoughts go
out to Magali, and stopped them before they got to Jan. It would be
time enough, I reasoned—though I did not really reason it: I only
felt it—to think about him when I had to. For the passing hours it
was enough to have the sweetness of being near Magali—and that
grew to be a greater sweetness with every fresh new day. Presently
I noticed that her colour had come back again; and it seemed to me
—though that may have been only because of my new love of her—
that she had a new beauty, tender and strange. Certainly there was
a new brightness, a curiously glowing brightness, in her eyes.
For Jan, things went hardly in those days. Having her promise, he
had rights in her—as we say in Provence. But he did not get many of
his rights. Half the time when he claimed her for walks on the hill-
sides among the olive-orchards, she would not go with him—
because she had her work to do at home, she said. And there was I,
where her work was, at home! For a while Jan did not see beyond
the end of his nose about it. I do not think that ever it crossed his
mind to think of me in the matter—not, that is, until some one with
better eyes than his eyes helped him to see. For he knew that I was
his friend, and I suppose that he remembered what I had told him
about my life being his. And even when his eyes were helped, he
would not at first fully believe what he must plainly have seen. But
he soon believed enough to make him change his manner toward
me, and to make him watch sharp for something that would give
him the right to speak words to me which would bring matters to a
fair settlement by blows. And I was ready, as I have said—though I
would not fairly own it to myself—to come to blows with him. For I
wanted him dead, and out of my way.
And so my mother's words, which had made me at last see clearly,
stayed by me as I went sailing in my boat softly seaward down the
étang. And they struck deeper into me because Jan's boat was just
ahead of mine; and the sight of him, and the thought of how he had
saved my life only to cross it, made me long to run him down and
drown him, and so be quit of him for good and all. I made up my
mind then that, whether I killed him or left him living, it would be I
who should have Magali and not he.

IV

"God keep you from the she-wolf, and from your heart's deep
desire!"
My mother said that again to me when I came home that night from
my fishing; and she said it to me often as the days went on. She
saw the change that had come to me, and she knew what was in my
soul. It is not wonderful, when you stop to think about it, that a
man's mother should know what is in his soul: for the body in which
that soul is, the living home of it, is a part of her own. And she grew
sad and weary-looking when she found that her words had no hold
on me, and there came into her eyes the sorrowful look that comes
into the eyes of old people who are soon to die.
But Magali's eyes were the only eyes that I cared for then, and they
seemed to me to grow brighter and brighter every day. When she
and I walked in the olive-orchards together in the starlight the glow
of them outshone the star-glow. It seemed to light up my heart.
I do not think that we talked much in those walks. I do not seem to
remember our talking. But we understood each other, and we were
agreed about what we were to do. I was old enough to marry as I
pleased, but Magali was not—she could not marry without my
mother's word. We meant to force that word. Some day we would
go off in my boat together—over to Les Saintes Maries, perhaps; or
perhaps to Marseille. It did not matter where we went. When we
came back again, at the end of two or three days, my mother no
longer could deny us—she would have to give in. And no one would
think the worse of Magali: for that is our common way of settling a
tangled love-matter here in Provence.
But I did not take account of Jan in my plans, and that was where I
made a mistake. Jan had just as strong a will as I had, and every bit
of his will was set upon keeping Magali for himself. I wanted her to
break with him entirely, but that she would not do. She was a true
Provençale—and I never yet knew one of our women who would rest
satisfied with one lover when she could have two. If she can get
more than two, that is better still. While I hung back from her,
Magali was more than ready to come to me; but when she found me
eager after her, and knew that she had a grip on me, she danced
away.
And so, before long, Jan again had his walks with her in the olive-
orchards by starlight just as I did, and likely enough her eyes glowed
for him just as they did for me. When they were off that way
together I would get into a wild-beast rage over it. Sometimes I
would follow them, fingering my knife. I suppose that he felt like
that when the turn was mine. Anyhow, the love-making chances
which she gave him—even though in my heart I still was sure of her
—kept me always watching him; and I could see that he always was
watching me. Very likely he felt sure of her too, and that was his
reason—just as it was my reason—for not bringing our matter to a
fighting end. I was ready enough to kill him, God knows. Unless his
eyes lied when he looked at me, he was ready to kill me.
And in that way the summer slipped past and the autumn came, and
neither of us gained anything. I was getting into a black rage over it
all. Down inside of me was a feeling like fire in my stomach that
made me not want to eat, and that made what I did eat go wrong.
My poor mother had given up trying to talk to me. She saw that she
could not change my way—and, too, I suppose that she pretty well
understood it all: for she had lived her life, and she knew the ways
of our men and of our women when love stings them here in
Provence. Only, her sadness grew upon her with her hopelessness.
What I remember most clearly as I think of her in those last days is
her pale old face and the dying look in her sorrowful eyes.
But seeing her in that way grief-struck only made my black rage
blacker and the fire in my stomach burn hotter. I had the feeling that
there was a devil down there who all the time was getting bigger
and stronger: and that before long he and I would take matters in
hand together and settle them for good and all. As for keeping on
with things as they were, it was not to be thought of. Better than
much more of such a hell-life would be ending everything by killing
Jan.
What made me hang back from that was the certainty that if I did
kill him—even in a fair fight, with his chance as good as mine—I
would lose Magali beyond all hope: for the gendarmes would have
me away in a whiff to jail—and then off would go my head, or, what
would be just as bad, off I would go head and all to Cayenne. It was
no comfort to me to know that Magali would almost cry her eyes out
over losing me. Of course she would do that, being a Provençale.
But before her eyes were quite out she would stop crying; and then
in a moment she would be laughing again; and in another moment
she would be freshly in love once more—with some man who was
not murdered and who was not gone for his lifetime over seas. And
all that, also, would be because she was a Provençale.

All the devils are let loose on earth on All Souls Eve—that is a fact
known to everybody here in Provence. But whether it was one of
those loosed devils, or the devil that had grown big in my own
inside, that made me do what I did I do not know. What I do know,
certainly, is that about dusk on All Saints Day the thought of how I
could force things to be as I wanted them to be came into my heart.
My thought was not a new thought, exactly. It was only that I would
do what we had planned to do to make my mother give in to us: get
Magali into my boat and carry her off with me for a day or two to
Les Saintes. But it came to me with the new meaning that in that
way I could make Magali give in to me too. When we came back she
would be ready enough to marry me, and my mother would be for
hurrying our marrying along. It all was as plain and as sure as
anything could be. And, as I have said, nobody would think the
worse of Magali afterward; because that way of cutting through such
difficulties is a common way with us in Provence.
And All Souls Eve was the time of all times for doing it. The whole
town is in commotion then. In the churches, when the Vespers of All
Saints are finished, the Vespers of the Dead are said. Then, just
after sunset, the streets are crowded with our people hurrying to the
graveyard with their lanterns for the graves. Nothing is thought
about but the death-fires. From all the church towers—in Jonquières,
in the Isle, in Ferrières—comes the sad dull tolling of bells. After
that, for an hour or more, the town is almost deserted. Only the very
old, and the very young, and the sick with their watchers, and the
bell-ringers in the towers, are left there. Everybody else is in the
graveyard, high up on the hill-side: first busied in setting the lights
and in weeping over dead loved ones; and then, when the duty to
the dead ones is done with, in walking about through the graveyard
to see the show. In Provence we take a great interest in every sort
of show.
Magali and I had no death-fires to kindle, for in the graveyard were
no dead of ours. Our people were of Les Saintes Maries, and there
their graves were—and my father, who was drowned at his fishing,
had no grave at all. But we went always to the graveyard on All
Souls Eve, and most times together, that we might see the show
with the others and enjoy the bustle of the crowd. And so there was
nothing out of the common when I asked her to come with me; and
off we started together—leaving my old mother weeping at home for
my dead father, who could have no death-fire lit for him because his
bones were lying lost to us far away in the depths of the sea.
Our house was in the eastern quarter of the town, in Jonquières. To
reach the graveyard we had to cross the Isle, and go through
Ferrières, and then up the hill-side beyond. But I did not mean that
we should do that; and when we had crossed the Canal du Roi I said
to Magali that we would turn, before we went onward, and walk
down past the Fish-market to the end of the Isle—that from there
we might see the lights glowing in the dusk on the slope rising
above us black against the western sky. We had done that before—it
is a pretty sight to see all those far-off glittering points of light
above, and then to see their glittering reflections near by in the
water below—and she willingly came with me.
But I had more in view. Down at the end of the Isle, along with the
other boats moored at the wharf there to be near the Fish-market,
my boat was lying; and when we were come close to her I said
suddenly, as though the thought had entered my head that minute,
that we would go aboard of her and run out a little way—and so see
the death-fires more clearly because they would be less hidden by
the shoulder of the hill. I did not have to speak twice. Magali was
aboard of the boat on the instant, and was clapping her hands at the
notion—for she had, as all our women have, a great pleasure in
following any sudden fancy which promises something amusing and
also a little strange. And I was quick after her, and had the lines cast
off and began to get up the sail.
"Oh," she said, "won't the oars do? Need we bother with the sail for
such a little way?"
But I did not answer her, and went on with what I was doing, while
the boat drifted quickly out from land before the gusts of wind which
struck us harder and harder as we cleared the point of the Isle. Until
then I had not thought about the weather—my mind had been full of
the other and bigger thought. The gusts of wind waked me up a
little, and as I looked at the sky I began to have doubts that I could
do what I wanted to do; for it was plain that a gale was rising which
would make ticklish work for me even out on the Gulf of Fos—and
would make pretty near impossible my keeping on to Les Saintes
over the open sea. And I had about made up my mind that we must
go back, and that I must carry out my plan some other time, when
there came a hail to us from the shore.
"Where are you going?" called a voice—and as we turned our looks
shoreward there was Jan. He had been following us, I suppose—just
as I sometimes had followed him.
Before I could answer him, Magali spoke. "We are going out on the
water to see the death-fires, Jan," she said. "We are going only a
very little way."
Her words angered me. There was something in them that seemed
to show that he had the right to question her. That settled me in my
purpose. Storm or no storm, on I would go. And I brought the boat
up to the wind, so as to lay our course straight down the Étang de
Caronte, and called out to him: "We are going where you cannot
follow. Good-bye!"
And then a gust of wind heeled us over, and we went on suddenly
with a dash—as a horse goes when you spur him—and the water
boiled and hissed under our bows. In another half-minute we were
clear of the shelter of the point, and then the wind came down on us
off the hills in a rush so strong that I had to ease off the sheet
sharply—and I had a queer feeling about what was ahead of me out
on the Gulf of Fos.
"Marius! Marius! What are you doing?" Magali cried in a shiver of
fright: for she knew by that time that something was back of it all in
my mind. As she spoke I could see through the dusk that Jan was
running up the sail of his boat, and in a minute more would be after
us.
"I am doing what I ought to have done long ago," I said. "I am
taking you for my own. There is nothing to fear, dear Magali. You
shall not be in danger. I had meant to take you to Les Saintes. But a
gale is rising and we cannot get to Les Saintes to-night. We will run
across the Gulf of Fos and anchor in the Grau de Gloria. There is a
shepherd's hut near the Grau. I will make a fire in it and you can
sleep there comfortably, while I watch outside. After all, it makes no
difference where we go. I shall have carried you off—when we go
back you must be my wife."
She did not understand at first. She was too much frightened with
the suddenness of it all, and with the coming of Jan, and with the
boat flying on through the rushing of the wind. I looked back and
saw that Jan had got away after us. Dimly I could make out his sail
through the dusk that lay thick upon the water. Beyond it and above
it was a broad patch of brightness where all the death-fires were
burning together in the graveyard. We had come too far to see any
longer those many points of light singly. In a mass, they made
against the black hill-side a great bright glow.

VI

"God keep you from the she-wolf, and from your heart's deep
desire!"
My mother's words seemed to sound in my ears loudly, coming with
the rush of wind that eddied around me out of the sail's belly. They
gave me a queer start, as the thought came with them that here at
last my heart's deep desire would be mine presently—if only I could
snatch it and keep it from the she-wolf of the sea.
Magali was silent—half standing, half sitting, against the weather
side of the boat, close in front of me as I stood at the tiller with the
sheet in my hand. She had got over her fright. I could tell that by
the brightness of her eyes, and by the warm colour in her cheeks
that I had a glimpse of as we flashed past the break in the hills
where the Mas Labillon stands. And in that moment while the dusk
was thinned a little I could see, too, that she was breathing hard. I
know what our women are, and I know what she was feeling. Our
women like to be fought for, and any one of them gladly would have
been in Magali's place—with the two strongest and handsomest men
in Les Martigues in a fair way to come to a death-grip for her in the
whirl of a rising storm.
Back in the dusk, against the faint glow of the death-fires, I could
see the sail of Jan's boat dipping and swaying with the thrusts of the
wind-gusts as it came on after me. It had gained a little; and I knew
that it would gain more, for Jan's boat was a speedier boat than
mine on the wind. Close-hauled, I could walk away from him; but in
running down the Étang de Caronte I had no choice in my sailing.
Out on the Gulf of Fos, if I dared take that chance, and if he dared
follow me, I could bear up to windward and so shake him off—
making for the Anse d'Auguette and taking shelter there. But even
my hot blood chilled a little at the thought of going out that night on
the Gulf of Fos. When we were down near the end of the étang—
close to the Salines, where it is widest—the wind that pelted down
on us from the hills was terribly strong. It was hard to stand against
even there, where the water was smooth. Outside, it would be still
stronger, and the water would be all in a boil. And at the end, to get
into the Anse d'Auguette, we should have to take the risk of a
roaring sea abeam.
But any risk was better than the risk of what might happen if Jan
overhauled me. Now that I fairly had Magali away from him, I did
not want to fight him. What might come in a fight in rough water—
where the winds and the waves would have to be reckoned with,
and with the most careful reckoning might play tricks on me—was
too uncertain; while if I could stand him off and get away from him,
so that even for one night I could keep Magali with me, the game
would be won. After that, if he wanted it, I would fight him as much
as he pleased.
The thought that I would win—in spite of Jan and in spite of the
storm, too—made all my blood tingle. More by habit than anything
else I sailed the boat: for my eyes were fixed on Magali's eyes,
shining there close to me, and my heart was full of her. We did not
speak, but once she turned and looked at me—bending forward a
little, so that her face was within a foot of mine. What she saw in my
eyes was so easy to read that she gave all at once a half-laugh and
a half-sob—and then turned away and peered through the blustering
darkness toward Jan's sail. Somehow, the way she did that made me
feel that she was holding the balance between us; that she was
waiting—as the she among wild beasts waits while the males are
fighting for her—for the stronger of us to win. After that I was ready
to face the Gulf of Fos.
The time for facing the gulf was close on me, too. We had run
through the canal of the Salines and were out in the open water of
Bouc—the great harbour at the mouth of the étang. The gale roared
down on us, now that there was little land to break it, and we began
to hear the boom of the waves pounding on the rocks outside. I
luffed well into the wind and bore up for the narrows opening
seaward where the Fort de Bouc light-house stands. The water still
was not rough enough to trouble us. It would not be rough until we
were at the very mouth of the narrows. Then, all at once, would
come the crush and fury of the wind and sea. I knew what it would
be like: and again a chill shot through me at the thought of risking
everything on that one great chance. But I had one thing to comfort
me: the moon had risen—and while the light came brokenly, as the
clouds thinned and thickened again, there was brightness enough
even at the darkest for me to lay a course when I got out among the
tumbling waves. Yet only a man half mad with passion would have
thought of fronting such a danger; and even I might have held back
at the last moment had I not been stung to go on.
Jan had so gained on me in the run down the étang that as we
came out from the canal of the Salines his boat was within less than
a dozen rods of mine; and as I hauled my sheet and bore up for the
narrows he shot down upon us and for a moment was almost under
our stern. And at that Magali gave a little jump and a half-gasp, and
laid her hand upon mine, crying: "Marius! Quick! Sail faster! He will
take me from you! Get me away! Get me away!"
And then I knew that she no longer balanced us, but that her heart
was for me. After that I would have faced not only the Gulf of Fos
but the open Mediterranean in the worst storm that ever blew.

VII

"God keep you from the she-wolf, and from your heart's deep
desire!"
The words were in my ears again as we went flying on toward the
narrows—with the reflection of the flame in the light-house making a
broad bright path for us, and the flame itself rising high before us
against the cloud-rack like a ball of fire. But God was not with me
then, and I gave those warning words no heed. I was drunk with the
gladness that came to me when Magali made her choice between
us; and all that I thought was that even if we did go down together,
out there in the Gulf of Fos, I still would be keeping her from Jan
and holding her for my own. That there might be any other ending
for us never crossed my mind.
Jan did not think, I suppose, that I would dare to go outside the
harbour. He was in a rage too, no doubt; but, still, he must have
been a good deal cooler than I was—for a rage of hate does not boil
in the very bones of a man, as a rage of love does—and so cool
enough to know that it was sheer craziness to take a boat out into
that sea. What I meant to do must have come to him with
suddenness—as we drew so close to the light-house that the flame
no longer was reflected ahead of us, and the narrows were open
over my starboard bow, and I let the boat fall off from the wind and
headed her into the broken water made by the inroll of half-spent
waves. In my run close-hauled I had dropped him, but not so much
as I thought I should, and as I came on the wind again—and hung
for a moment before gathering fresh headway—he ranged up once
more within hail.
"Where are you going? Are you crazy?" he called out—and though
he must have shouted with all the strength of his big lungs his voice
came thin through the wind to us, and broken by the pounding of
the sea.
"Where you won't dare to follow!" I called back to him—and we
went rushing on below the big old fort, that carries the light on its
tower, through the short passage between the harbour and the Gulf
of Fos.
Something he answered, but what it was I do not know: for as we
cleared the shelter of the fort—but while the tail of rock beyond it
still was to windward, so that I could not luff—down with a crash on
us came the gale. I could only let fly the sheet—but even with the
sheet all out over we went until the sail was deep in the water, and
over the leeward gunwale the waves came hissing in. I thought that
there was the end of it; but the boat had such way on her that even
on her beam ends and with the sail dragging she went on until we
had cleared the rocks; and then I luffed her and she rose slowly, and
for the moment was safe again with her nose in the wind.
Magali's face was dead white—like a dead woman's face, only for her
shining eyes. She fell to leeward as the boat went over—I could not
spare a hand to save her—and struck hard against the gunwale.
When the boat righted and she got up again her forehead was
bleeding. On her white face the blood was like a black stain. But she
put her hand on mine and said: "I am not frightened, Marius. I love
you!"
Jan was close aboard again. As our way had deadened he had
overhauled us; and because he saw what had happened to my boat
he was able to bring his boat through the narrows without going
over.
"Marius! Marius! For God's sake, for Magali's sake, put about!" he
shouted. "It is the only chance to save her. Put about, I say!"
He was only a little way to leeward of us, but I barely made out his
words. The wind was roaring past us, and the waves were banging
like cannon on the rocks close by.
What he said was the truth, and I knew it. I knew that the gale was
only just beginning, and that no boat could live through it for
another hour. And then one of the devils loose on that All Souls Eve,
or perhaps it was my own devil inside of me, put a new evil thought
into my heart: making clear to me how I might get rid of Jan for
good and all, and without its ending in my losing my head or in my
losing Magali by being sent overseas. It was a chance, to be sure,
and full of danger. But just then I was ready for any danger or for
any chance.

"THE OTHERS WERE UPCAST ON THE ROCKS"


"Lie down in the bottom of the boat, Magali," I called sharply. "That
is the safest place for you. We are going about."
I spoke the truth to Magali; but, also, I did not want her to see what
happened. She did what I told her to do, and then I began to wear
the boat around. How I did it without swamping, I do not know.
Perhaps the devils of All Souls Eve held up my mast through the
black moments while we lay wallowing in the trough of the sea. But
I did do it; and when I was come about I headed straight for Jan's
boat—lying dead to leeward of me, not twenty yards away. The
clouds thinned suddenly and almost the full light of the moon was
with us. We could see each other's faces plainly—and in mine he
saw what I meant to do.
"It will be all of us together, Marius!" he called to me. "Do you want
to murder Magali too?"
But I did not believe that it would be all of us together: for I knew
that his boat was an old one, and that mine was new and strong.
And, also, the devils had me in their hold. The gale was behind me,
driving me down upon him like a thunder-bolt. As I shot close to him
the moon shone out full for a moment through a rift in the clouds. In
that moment I saw his face clearly. The moonlight gleamed on it. It
was a ghastly dead white. But I do not suppose that it was for
himself that he was afraid. Jan was not a coward, or he would not
have jumped after me when I was drowning in the stormy sea.
Once more he called to me. "Marius! For the sake of Magali—"
And then there was a crashing and a rending of planks as I shot
against his boat, and a sudden upspringing of my own boat under
me. And after that, for a long while, a roaring of water about me,
and my own body tumbled and thrust hither and thither in it, and at
last a blow which seemed to dash me down into a vast black depth
that was all buzzing with little blazing stars.

But the others were upcast on the rocks dead.


A Sea Upcast

When we East Anglians be set to do a thing, we be set firm. We


come at what we want by slow thinking, but when we know what
we want we hold fast by it—being born stubborn, and also being
born staunch. It is the same with our hating and with our loving: we
fire slowly, but when at last the fire is kindled it burns so strongly in
the very hearts of us—with a white glow, hotter than any flame—
that there is no putting it out again short of putting out our lives.
Men and women alike, we are born that way; and we fishermen of
the Suffolk and Norfolk coast likewise are bred that way: seeing that
from the time we go afloat as youngsters until the time that we are
drowned, or are grown so old and rusty that there is no more
strength for sea-fighting left in us, our lives for the most part are
spent in fighting the North Sea. That is a fight that needs
stubbornness to carry it through to a finish. Also, it needs knowledge
of the ocean's tricks and turns—because the North Sea can do what
we East Anglians can't do: it can smile at you and lie. A man must
have a deal of training before he can tell by the feel of it in his own
insides that close over beyond a still sea and a sun-bright sky a
storm is cooking up that will kill him if it can. And even when he
feels the coming of it—if he be well to seaward, or if he be tempted
by the fish being plenty and by the bareness of his own pockets to
hold on in the face of it—he must have more in his head than any
coast pilot has if he is to win home to Yarmouth Harbour or to
Lowestoft Roads.
For God in his cruelty has set more traps to kill seafarers off this
easterly outjut of England, I do believe, than He has set anywhere
else in all the world: there being from Covehithe Ness northward to
the Winterton Overfalls nothing but a maze of deadly shoals—all cut
up by channels in which there is no sea-room—that fairly makes you
queazy to think about when you are coming shoreward in a
northeast gale. And as if that were not enough to make sure of man-
food for the fishes, the currents that swirl and play among these
shoals are up to some fresh wickedness with every hour of the tide-
run and with every half shift of wind. Whether you make in for
Yarmouth by Hemesby Hole to the north, or by the Hewett Channel
to the south, or split the difference by running through Caister Road,
it is all one: twisting about the Overfalls and the Middle Cross Sand
and the South Scroby, there the currents are. What they will be
doing with you, or how they will be doing it, you can't even make a
good guess at; all that you can know for certain being that they will
be doing their worst by you at the half tide.
At least, though, the Lowestoft men and the Yarmouth men have a
good harbour when once they fetch it; and by that much are better
off than we Southwold men, who have no harbour at all. With
anything of a sea running there is no making a landing under
Southwold Cliff—though it is safe enough when once your boat is
beached and hauled up there; and so, if the storm gets ahead of us,
there is nothing left but to run for Lowestoft: and a nice time we
often have of it, with an on-shore gale blowing, working up into the
Covehithe Channel under the tail of the Barnard Bank! As for beating
up to seaward of the Barnard and running in through Pakefield Gat,
anybody can try for it who has a mind to—and who has a boat that
can eat the very heart out of the wind. Sometimes you do fetch it.
But what happens to you most times is best known to the Newcome
Shoal. When you have cleared the Barnard—if so be you do clear it—
the Newcome lies close under your lee for all the rest of the run.
What it has done for us fishermen you can see when the spring tides
bare it and show black scraps of old boats wrecked there, and
sometimes a gleam of sand-whitened bones.
For a good many years we had another chance, though a poor one,
and that was to make a longish leg off shore and then run in before
the wind and cross the Barnard into Covehithe Channel through
what we called the Wreck Gat—a cut in the bank that the currents
made striking against a wrecked ship buried there. The Wreck Gat is
gone now—closed by the same storm that nearly closed my life for
me—and you will not find it marked nowadays on the charts. Its
going was a good riddance. At the best it was a desperate bad place
to get through; and at its worst it was about the same as a sea
pitfall: and that nobody knows better than I do, seeing that I was
the last man to get through it alive. But when you happened to be to
windward of it, if it served at all, it served better than running down
a half mile farther and trying to round the tail of the bank.
Very many craft beside our own fisher-boats find their death-harbour
on our East Anglian sands. Our coast, as it has a right to be, is the
dread of every sailor man who sails the narrow seas. Great ships,
storm-swept on our sands, are sucked down into the depths of
them, or are hammered to pieces on the top of them, as light-
heartedly as though they were no more than cock-boats. And the
supply of ships to be wrecked there is unending—since the half of
the trade of the world, they say, sails past our shores. From every
land they come: and many and many a one of them comes but
never goes. Down on them bangs the northeast wind with a roar
and a rattle—and presently our sands have hold of them with a grip
that is to keep them fast there till the last day! Sometimes the dead
men who were living sailors aboard those ships come ashore to us,
though they are more like to find graves in the sands that murdered
them or to be swept out to sea; sometimes, by a twist of chance
that you may call a miracle, the sea has a fancy for casting one or
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

testbankfan.com

You might also like