100% found this document useful (1 vote)
28 views

SQL and relational theory how to write accurate SQL code 2ed. Edition Date - The complete ebook is available for download with one click

The document provides information about the book 'SQL and Relational Theory: How to Write Accurate SQL Code, 2nd Edition' by C. J. Date, including download links and details about the author's background. It emphasizes the importance of understanding relational theory to write accurate SQL code and highlights the challenges of using SQL effectively. The book is published by O'Reilly Media and includes a comprehensive table of contents covering various aspects of SQL and relational databases.

Uploaded by

aligoaeryn23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
28 views

SQL and relational theory how to write accurate SQL code 2ed. Edition Date - The complete ebook is available for download with one click

The document provides information about the book 'SQL and Relational Theory: How to Write Accurate SQL Code, 2nd Edition' by C. J. Date, including download links and details about the author's background. It emphasizes the importance of understanding relational theory to write accurate SQL code and highlights the challenges of using SQL effectively. The book is published by O'Reilly Media and includes a comprehensive table of contents covering various aspects of SQL and relational databases.

Uploaded by

aligoaeryn23
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

Visit https://ebookultra.

com to download the full version and


explore more ebooks or textbooks

SQL and relational theory how to write accurate


SQL code 2ed. Edition Date

_____ Click the link below to download _____


https://ebookultra.com/download/sql-and-relational-theory-
how-to-write-accurate-sql-code-2ed-edition-date/

Explore and download more ebooks or textbooks at ebookultra.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

SQL and Relational Theory How to Write Accurate SQL Code


1st Edition C. J. Date

https://ebookultra.com/download/sql-and-relational-theory-how-to-
write-accurate-sql-code-1st-edition-c-j-date/

The Language of SQL How to Access Data in Relational


Databases 1st Edition Larry Rockoff

https://ebookultra.com/download/the-language-of-sql-how-to-access-
data-in-relational-databases-1st-edition-larry-rockoff/

Relational Theory for Computer Professionals 1st Edition


C.J. Date

https://ebookultra.com/download/relational-theory-for-computer-
professionals-1st-edition-c-j-date/

Database in Depth Relational Theory for Practitioners 1st


Edition C.J. Date

https://ebookultra.com/download/database-in-depth-relational-theory-
for-practitioners-1st-edition-c-j-date/
SQL Server T SQL Recipes 4th Edition Jason Brimhall

https://ebookultra.com/download/sql-server-t-sql-recipes-4th-edition-
jason-brimhall/

Microsoft SQL Server 2012 T SQL 1st Edition Tom Coffing

https://ebookultra.com/download/microsoft-sql-server-2012-t-sql-1st-
edition-tom-coffing/

Essential SQL on SQL Server 2008 1st Edition Dr. Sikha


Bagui

https://ebookultra.com/download/essential-sql-on-sql-server-2008-1st-
edition-dr-sikha-bagui/

Joe Celko s SQL for Smarties Fourth Edition Advanced SQL


Programming Joe Celko

https://ebookultra.com/download/joe-celko-s-sql-for-smarties-fourth-
edition-advanced-sql-programming-joe-celko/

Inside Microsoft SQL Server 2008 T SQL Querying 1st


Edition Itzik Ben-Gan

https://ebookultra.com/download/inside-microsoft-sql-
server-2008-t-sql-querying-1st-edition-itzik-ben-gan/
SQL and relational theory how to write accurate SQL
code 2ed. Edition Date Digital Instant Download
Author(s): Date, C. J
ISBN(s): 9781449319755, 1449319750
Edition: 2ed.
File Details: PDF, 6.61 MB
Year: 2012
Language: english
SQL and

Relational Theory

How to Write Accurate SQL Code

SECOND EDITION

C. J. Date

sql_final.pdf 1 12/8/11 2:33:04 PM


SQL and Relational Theory: How to Write Accurate SQL Code (2nd edition)
by C. J. Date

Copyright © 2012 C. J. Date. All rights reserved.


Printed in the United States of America.

Published by O’Reilly Media, Inc.,


1005 Gravenstein Highway North, Sebastopol, CA95472.

O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also
available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/institutional
sales department: (800) 998-9938 or [email protected].

Printing History:
January 2009: First Edition.
December 2011: Second Edition.

Revision History:
2011-12-08 First release
See http://oreilly.com/catalog/errata.csp?isbn= 9781449316402 for release details.

Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. SQL and Relational Theory: How to Write Accurate SQL Code and related trade dress are
trademarks of O’Reilly Media, Inc.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.

ISBN: 978-1-449-31640-2

[LSI]

sql_final.pdf 2 12/8/11 2:33:05 PM


Those who are enamored of practice without theory are like a
pilot who goes into a ship without rudder or compass
and never has any certainty where he is going
Practice should always be based upon
a sound knowledge of theory.
—Leonardo da Vinci (1452–1519)

The trouble with people is not that they don’t know


but that they know so much that ain’t so.
—Josh Billings (1818–1885)

Languages die...
mathematical ideas do not.
—G. H. Hardy (1877–1947)

Unfortunately, the gap between theory and practice


is not as wide in theory as it is in practice.
—Anon.

These are my principles.


If you don’t like them, I have others.
—Groucho Marx (1890–1977)

There is no royal road to geometry.


—Euclid (c. 365–275 BCE), attrib.

——— ®®®®® ———

To all those who think an exercise like this one is worthwhile,


and in particular to the memory of Lex de Haan,
who is very much missed

sql_final.pdf 3 12/8/11 2:33:05 PM


About the Author

C. J. Date is an independent author, lecturer, researcher, and consultant, specializing in relational database
technology. He is best known for his book An Introduction to Database Systems, 8th edition (Addison-Wesley,
2004), which has sold some 850,000 copies at the time of writing and is used by several hundred colleges and
universities worldwide. He is also the author of many other books on database management, including most
recently:

 From Addison-Wesley: Databases, Types, and the Relational Model: The Third Manifesto, 3rd edition
(coauthored with Hugh Darwen, 2006)

 From Apress: Date on Database: Writings 2000–2006 (2006)

 From Trafford: Logic and Databases: The Roots of Relational Theory (2007)

 From Apress: The Relational Database Dictionary, Extended Edition (2008)

 From Trafford: Database Explorations: Essays on The Third Manifesto and Related Topics (coauthored with
Hugh Darwen, 2010)

 From Ventus: Go Faster! The TransRelationalTM Approach to DBMS Implementation (2011)

Another book, Normal Forms and All That Jazz: A Database Professional’s Guide to Database Design Theory (a
companion to the present book), is also due for publication in the near future.
Mr. Date was inducted into the Computing Industry Hall of Fame in 2004. He enjoys a reputation that is
second to none for his ability to explain complex technical subjects in a clear and understandable fashion.

sql_final.pdf 4 12/8/11 2:33:05 PM


Contents

Preface to the First Edition xi

Preface to the Second Edition xvi

Chapter 1 Setting the Scene 1

The relational model is much misunderstood 1


Some remarks on terminology 2
Principles not products 4
A review of the original model 5
Model vs. implementation 12
Properties of relations 14
Base vs. derived relations 18
Relations vs. relvars 19
Values vs. variables 21
Concluding remarks 22
Exercises 23

Chapter 2 Types and Domains 25

Types and relations 25


Equality comparisons 26
Data value atomicity 31
What’s a type? 34
Scalar vs. nonscalar types 37
Scalar types in SQL 39
Type checking and coercion in SQL 40
Collations in SQL 42
Row and table types in SQL 43
Concluding remarks 45
Exercises 46

Chapter 3 Tuples and Relations, Rows and Tables 49

What’s a tuple? 49
Rows in SQL 53
What’s a relation? 55
Relations and their bodies 57
Relations are n-dimensional 58
Relational comparisons 58
TABLE_DUM and TABLE_DEE 59
Tables in SQL 60

sql_final.pdf 5 12/8/11 2:33:05 PM


vi Contents

Column naming in SQL 62


Concluding remarks 64
Exercises 64

Chapter 4 No Duplicates, No Nulls 67

What’s wrong with duplicates? 67


Duplicates: further issues 72
Avoiding duplicates in SQL 72
What’s wrong with nulls? 74
Avoiding nulls in SQL 77
A remark on outer join 79
Concluding remarks 80
Exercises 80

Chapter 5 Base Relvars, Base Tables 85

Updating is set level 86


Relational assignment 88
More on candidate keys 92
More on foreign keys 94
Relvars and predicates 97
Relations vs. types 99
Exercises 101

Chapter 6 SQL and Relational Algebra I: The Original Operators 105

Some preliminaries 105


More on closure 108
Restriction 110
Projection 111
Join 112
Union, intersection, and difference 116
Which operators are primitive? 119
Formulating expressions one step at a time 119
What do relational expressions mean? 121
Evaluating SQL table expressions 122
Expression transformation 123
The reliance on attribute names 125
Exercises 127

Chapter 7 SQL and Relational Algebra II: Additional Operators 131

Exclusive union 131


Semijoin and semidifference 132
Extend 133
Image relations 135
Divide 138

sql_final.pdf 6 12/8/11 2:33:05 PM


Contents vii

Aggregate operators 139


Image relations bis 144
Summarization 146
Summarization bis 150
Group, ungroup, and relation valued attributes 152
“What if” queries 157
A note on recursion 159
What about ORDER BY? 163
Exercises 164

Chapter 8 SQL and Constraints 169

Type constraints 169


Type constraints in SQL 173
Database constraints 174
Database constraints in SQL 178
Transactions 180
Why database constraint checking must be immediate 180
But doesn’t some checking have to be deferred? 182
Constraints and predicates 185
Miscellaneous issues 186
Exercises 188

Chapter 9 SQL and Views 193

Views are relvars 194


Views and predicates 197
Retrieval operations 198
Views and constraints 199
Update operations 203
What are views for? 211
Views and snapshots 212
Exercises 213

Chapter 10 SQL and Logic 215

Why do we need logic? 216


Simple and compound propositions 217
Simple and compound predicates 222
Quantification 223
Relational calculus 227
More on quantification 234
Some equivalences 241
Concluding remarks 244
Exercises 244

sql_final.pdf 7 12/8/11 2:33:05 PM


viii Contents

Chapter 11 Using Logic to Formulate SQL Expressions 247

Some transformation laws 247


Example 1: Logical implication 250
Example 2: Universal quantification 251
Example 3: Implication and universal quantification 252
Example 4: Correlated subqueries 254
Example 5: Naming subexpressions 255
Example 6: More on naming subexpressions 258
Example 7: Dealing with ambiguity 259
Example 8: Using COUNT 261
Example 9: Join queries 262
Example 10: UNIQUE quantification 263
Example 11: ALL or ANY comparisons 265
Example 12: GROUP BY and HAVING 269
Exercises 270

Chapter 12 Miscellaneous SQL Topics 273

SELECT * 273
Explicit tables 274
Name qualification 274
Range variables 275
Subqueries 277
“Possibly nondeterministic” expressions 280
Empty sets 281
A simplified BNF grammar 281
Exercises 285

Appendix A The Relational Model 287

The relational model vs. others 288


The significance of theory 291
The relational model defined 293
Database variables 298
Objectives of the relational model 299
Some database principles 300
What remains to be done? 301

Appendix B SQL Departures from the Relational Model 305

Appendix C A Relational Approach to Missing Information 307

Vertical decomposition 308


Horizontal decomposition 309
What do the shaded entries mean? 311
Constraints 313

sql_final.pdf 8 12/8/11 2:33:05 PM


Contents ix

Queries 314
More on predicates 317
Exercises 320

Appendix D A Tutorial D Grammar 321

Appendix E Summary of Recommendations 325

Appendix F Answers to Exercises 329

Chapter 1 329
Chapter 2 335
Chapter 3 341
Chapter 4 346
Chapter 5 352
Chapter 6 358
Chapter 7 366
Chapter 8 379
Chapter 9 389
Chapter 10 395
Chapter 11 403
Chapter 12 405
Appendix C 407

Appendix G Suggestions for Further Reading 409

Index 419

sql_final.pdf 9 12/8/11 2:33:05 PM


sql_final.pdf 10 12/8/11 2:33:05 PM
Preface to the First Edition

SQL is ubiquitous. But SQL is hard to use: It’s complicated, confusing, and error prone (much more so, I venture to
suggest, than its apologists would have you believe). In order to have any hope of writing SQL code that you can be
sure is accurate, therefore—meaning it does exactly what it’s supposed to do, no more and no less—you must follow
some appropriate discipline. And it’s the thesis of this book that using SQL relationally is the discipline you need.
But what does this mean? Isn’t SQL relational anyway?
Well, it’s true that SQL is the standard language for use with relational databases—but that fact in itself
doesn’t make it relational. The sad truth is, SQL departs from relational theory in all too many ways; duplicate rows
and nulls are two obvious examples, but they’re not the only ones. As a consequence, the language gives you rope to
hang yourself with, as it were. So if you don’t want to hang yourself, you need to understand relational theory (what
it is and why); you need to know about SQL’s departures from that theory; and you need to know how to avoid the
problems they can cause. In a word, you need to use SQL relationally. Then you can behave as if SQL truly were
relational, and you can enjoy the benefits of working with what is, in effect, a truly relational system.
Now, a book like this wouldn’t be needed if everyone was using SQL relationally already—but they aren’t.
On the contrary, I observe much bad practice in current SQL usage. I even observe such practice being
recommended, in textbooks and similar publications, by writers who really ought to know better (no names, no pack
drill); in fact, a review of the literature in this regard is a pretty dispiriting exercise. The relational model first saw
the light of day in 1969, and yet here we are, over 40 years later, and it still doesn’t seem to be very well understood
by the database community at large. Partly for such reasons, this book uses the relational model itself as an
organizing principle; it explains various features of the model in depth, and shows in every case how best to use
SQL in order to comply with the feature in question.

Prerequisites

I assume you’re a database practitioner and therefore reasonably familiar with SQL already. To be specific, I assume
you have a working knowledge of either the SQL standard or (perhaps more likely in practice) at least one SQL
product. However, I don’t assume you have a deep knowledge of relational theory as such (though I do hope you
understand that the relational model is a good thing in general, and adherence to it wherever possible is a desirable
goal). In order to avoid misunderstandings, therefore, I’ll be describing various features of the relational model in
detail, as well as showing how to use SQL to conform to those features. But what I won’t do is attempt to justify all
of those features; rather, I’ll assume you’re sufficiently experienced in database matters to understand why, e.g., the
notion of a key makes sense, or why you sometimes need to do a join, or why many to many relationships need to be
supported. (If I were to include such justifications, this would be a very different book—quite apart from anything
else, it would be much bigger than it already is—and in any case, that book has already been written.)
I’ve said I expect you to be reasonably familiar with SQL. However, I should add that I’ll be explaining
certain aspects of SQL in detail anyway—especially aspects that might be encountered less frequently in practice.
(The SQL notion of possibly nondeterministic expressions is a case in point here. See Chapter 12.)

Database in Depth

This book is based on, and intended to replace, an earlier one with the title Database in Depth: Relational Theory
for Practitioners (O’Reilly Media Inc., 2005). My aim in that earlier book was as follows (this is a quote from the
preface):

sql_final.pdf 11 12/8/11 2:33:05 PM


xii Preface to the First Edition

After many years working in the database community in various capacities, I’ve come to realize there’s a real need for a
book for practitioners (not novices) that explains the basic principles of relational theory in a way not tainted by the
quirks and peculiarities of existing products, commercial practice, or the SQL standard. I wrote this book to fill that need.
My intended audience is thus experienced database practitioners who are honest enough to admit they don’t understand
the theory underlying their own field as well as they might, or should. That theory is, of course, the relational model—
and while it’s true that the fundamental ideas of that theory are all quite simple, it’s also true that they’re widely
misrepresented, or underappreciated, or both. Often, in fact, they don’t seem to be understood at all. For example, here
are a few relational questions ... How many of them can you answer?1

1. What exactly is first normal form?


2. What’s the connection between relations and predicates?
3. What’s semantic optimization?
4. What’s an image relation?
5. Why is semidifference important?
6. Why doesn’t deferred integrity checking make sense?
7. What’s a relation variable?
8. What’s prenex normal form?
9. Can a relation have an attribute whose values are relations?
10. Is SQL relationally complete?
11. Why is The Information Principle important?
12. How does XML fit with the relational model?

This book provides answers to these and many related questions. Overall, it’s meant to help database practitioners
understand relational theory in depth and make good use of that understanding in their professional day-to-day activities.

As the final sentence in this extract indicates, it was my hope that readers of that book would be able to apply
its ideas for themselves, without further assistance from me as it were. But I’ve since come to realize that, contrary
to popular opinion, SQL is such a difficult language that it can be far from obvious how to use it without violating
relational principles. I therefore decided to expand the original book to include explicit, concrete advice on exactly
that issue (how to use SQL relationally, I mean). So my aim in the present book is still the same as before—I want to
help database practitioners understand relational theory in depth and make good use of that understanding in their
professional activities—but I’ve tried to make the material a little easier to digest, perhaps, and certainly easier to
apply. In other words, I’ve included a great deal of SQL-specific material (and it’s this fact, more than anything else,
that accounts for the increase in size over the previous book).

Further Remarks on the Text

I need to take care of several further preliminaries. First of all, my own understanding of the relational model has
evolved over the years, and continues to do so. This book represents my very latest thinking on the subject; thus, if
you detect any technical discrepancies—and there are a few—between this book and other books you might have
seen by myself (including in particular the one the present book is meant to replace), the present book should be
taken as superseding. Though I hasten to add that such discrepancies are mostly of a fairly minor nature; what’s
more, I’ve taken care always to relate new terms and concepts to earlier ones, wherever I felt it was necessary to do
so.
Second, I will, as advertised, be talking about theory—but it’s an article of faith with me that theory is
practical. I mention this point explicitly because so many seem to believe the opposite: namely, that if something’s

1
For reasons that aren’t important here, I’ve replaced a few of the questions in this list by new ones.

sql_final.pdf 12 12/8/11 2:33:05 PM


Preface to the First Edition xiii

theoretical, it can’t be practical. But the truth is that theory (at least, relational theory, which is what I’m talking
about here) is most definitely very practical indeed. The purpose of that theory is not just theory for its own sake; the
purpose of that theory is to allow us to build systems that are 100 percent practical. Every detail of the theory is
there for solid practical reasons. As Stéphane Faroult, a reviewer of the earlier book, wrote: “When you have a bit
of practice, you realize there’s no way to avoid having to know the theory.” What’s more, that theory is not only
practical, it’s fundamental, straightforward, simple, useful, and it can be fun (as I hope to demonstrate in the course
of this book).
Of course, we really don’t have to look any further than the relational model itself to find the most striking
possible illustration of the foregoing thesis. Indeed, it really shouldn’t be necessary to have to defend the notion that
theory is practical, in a context such as ours: namely, a multibillion dollar industry totally founded on one great
theoretical idea. But I suppose the cynic’s position would be “Yes, but what has theory done for me lately?” In
other words, those of us who do think theory is important must continually be justifying ourselves to our critics—
which is another reason why I think a book like this one is needed.
Third, as I’ve said, the book does go into a fair amount of detail regarding features of SQL or the relational
model or both. (It deliberately has little to say on topics that aren’t particularly relational; for example, there isn’t
much on transactions.) Throughout, I’ve tried to make it clear when the discussions apply to SQL specifically, when
they apply to the relational model specifically, and when they apply to both. I should emphasize, however, that the
SQL discussions in particular aren’t meant to be exhaustive. SQL is such a complex language, and provides so many
different ways of doing the same thing, and is subject to so many exceptions and special cases, that to be
exhaustive—even if it were possible, which I tend to doubt—would be counterproductive; certainly it would make
the book much too long. So I’ve tried to focus on what I think are the most important issues, and I’ve tried to be as
brief as possible on the issues I’ve chosen to cover. And I’d like to claim that if you do everything I tell you, and
don’t do anything I don’t tell you, then to a first approximation you’ll be safe: You’ll be using SQL relationally. But
whether that claim is justified, or to what extent it is, must be for you to judge.
To the foregoing I have to add that, unfortunately, there are some situations in which SQL just can’t be used
relationally. For example, some SQL integrity checking simply has to be deferred (usually to commit time), even
though the relational model explicitly rejects such checking as logically flawed. The book does offer advice on what
to do in such cases, but I fear it often boils down to just Do the best you can. At least I hope you’ll understand the
risks involved in departing from the model.
I should say too that some of the recommendations offered aren’t specifically relational anyway but are,
rather, just matters of general good practice—though sometimes there are relational implications (implications that
can be a little unobvious, too, perhaps I should add). Avoid coercions is a good example here.
Fourth, please note that I use the term SQL throughout the book to mean the standard version of that
language exclusively, not some proprietary dialect, barring explicit statements to the contrary. In particular, I follow
the standard in assuming the pronunciation “ess cue ell,” not “sequel” (though this latter is common in the field),
thereby saying things like an SQL table, not a SQL table.
Fifth, the book is meant to be read in sequence, pretty much, except as noted here and there in the text itself
(most of the chapters do rely to some extent on material covered in earlier ones, so you shouldn’t jump around too
much). Also, each chapter includes a set of exercises. You don’t have to do those exercises, of course, but I think it’s
a good idea to have a go at some of them at least. Answers, often giving more information about the subject at hand,
are given in Appendix F.
Finally, I’d like to mention that I have some live seminars available based on the material in this book. See
www.justsql.co.uk/chris_date/chris_date.htm or www.thethirdmanifesto.com for further details. An online version of
one of those seminars is available too, at http://oreilly.com/catalog/0636920010005/.

sql_final.pdf 13 12/8/11 2:33:05 PM


xiv Preface to the First Edition

Using Code Examples


This book is here to help you get your job done. In general, you may use the code in this book in your programs and
documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the
code. For example, writing a program that uses several chunks of code from this book does not require permission.
Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question
by citing this book and quoting example code does not require permission. Incorporating a significant amount of
example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN.
For example: “SQL and Relational Theory, Second Edition, by C.J. Date (O’Reilly). Copyright 2012 C.J. Date,
9781449316402.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at
[email protected].

Comments and Questions


Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.1005 Gravenstein Highway North


Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international or local)
(707) 829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access
this page at http://shop.oreilly.com/product/0636920022879.do.

To comment or ask technical questions about this book, send email to [email protected].

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly.

Follow us on Twitter: http://twitter.com/oreillymedia.

Watch us on YouTube: http://www.youtube.com/oreillymedia.

Safari® Books Online


Safari Books Online is an on-demand digital library that lets you easily search over 7,500 technology and creative
reference books and videos to find the answers you need quickly.

With a subscription, you can read any page and watch any video from our library online. Read books on your cell
phone and mobile devices. Access new titles before they are available for print, and get exclusive access to
manuscripts in development and post feedback for the authors. Copy and paste code samples, organize your
favorites, download chapters, bookmark key sections, create notes, print out pages, and benefit from tons of other
time-saving features.

sql_final.pdf 14 12/8/11 2:33:05 PM


Preface to the First Edition xv

O’Reilly Media has uploaded this book to the Safari Books Online service. To have full digital access to this book
and others on similar topics from O’Reilly and other publishers, sign up for free at http://my.safaribooksonline.com.

Acknowledgments

I’d been thinking for some time about revising the earlier book to include more on SQL in particular, but the spur
that finally got me down to it was sitting in on a class, late in 2007, for database practitioners. The class was taught
by Toon Koppelaars and was based on the book he wrote with Lex de Haan (see Appendix G of the present book),
and very good it was, too. But what struck me most about that class was seeing firsthand the kinds of difficulties the
attendees had in applying relational and logical principles to their use of SQL. Now, I do assume those attendees had
some knowledge of those topics—they were database practitioners, after all—but it seemed to me they really needed
some guidance in the application of those ideas to their daily database activities. And so I put this book together. So
I’m thankful, first of all, to Toon and Lex for providing me with the necessary impetus to get started on this project.
I’m grateful also to my reviewers Herb Edelstein, Sheeri Ktitzer, Andy Oram, Peter Robson, and Baron Schwartz for
their comments on earlier drafts, and Hugh Darwen and Jim Melton for other technical assistance. Next, I’d like to
thank my wife Lindy, as always, for her support throughout this and all of my other database projects over the years.
Finally, I’m grateful to everyone at O’Reilly—especially Isabel Kunkle and Andy Oram—for their encouragement,
contributions, and support throughout the production of this book.

C. J. Date
Healdsburg, California
2008

sql_final.pdf 15 12/8/11 2:33:05 PM


Preface to the Second Edition

This edition differs from its predecessor in a number of ways. The overall objective remains the same, of course—
using SQL relationally is still the emphasis—but the text has been revised throughout to reflect, among other things,
experience gained from teaching live seminars based on the first edition.
One significant change is a deletion: The appendix on design theory has gone. There are two reasons for this
change. First, design theory as such never really did have all that much to do with the book’s main message,
anyway; second, the appendix was getting so extensive that it threatened to overwhelm the rest of the text. (It was
already longer than any chapter or any other appendix in the book. In fact, I’ve since expanded the material into a
separate book in its own right. That book—Normal Forms and All That Jazz: A Database Professional’s Guide to
Database Design Theory—is due to be published soon by O’Reilly. It can be seen as a companion, or perhaps a
sequel, to the present book.)
On the positive side, a lot of new material has been added (including, importantly, a discussion of how to
deal with missing information without using nulls); examples, exercises, and answers have been expanded and
improved in various respects; and the treatment of SQL has been upgraded to cover recent changes to the SQL
standard. A variety of corrections and numerous cosmetic improvements have also been made.2 (In particular, the
Tutorial D examples—Tutorial D being the language I use to illustrate relational concepts—have been upgraded to
reflect several recent improvements to that language. See Appendix D.) The net effect is to make the text rather
more comprehensive—but, sadly, some 25 percent bigger—than its predecessor.
Talking of the text, I’d like to say something about my use of footnotes. Frankly, I’m rather embarrassed at
how many footnotes there are; I’m well aware how annoying they can be—indeed, they can seriously impede
readability. But any text dealing with SQL is more or less forced into a heavy use of footnotes, at least if it wants to
be tutorial in nature and yet reasonably comprehensive at the same time. The reason is that SQL involves so many
inconsistencies, exceptions, and special cases that treating everything “in line”—i.e., at the same level of
description—makes it very difficult to see the forest for the trees. (Indeed, this is one reason why the SQL standard
itself is so difficult to understand.) Thus, there are numerous places in the book where the major idea is described
“in line” in the main body of the text, and exceptions and the like (which must at least be mentioned, for reasons of
accuracy and completeness) are relegated to a footnote. It might be best simply to ignore all footnotes on a first
reading.

C. J. Date
Healdsburg, California
2012

2
In this connection, I’d like to acknowledge the contribution of a reader of the first edition, Thomas Uhren, who found an embarrassingly large
number of errors. I’ll try harder in future. I promise.

sql_final.pdf 16 12/8/11 2:33:05 PM


Chapter 1

Setting the Scene

My soul, sit thou a patient looker-on;


Judge not the play before the play is done;
Her plot hath many changes; every day
Speaks a new scene; the last act crowns the play.
─Francis Quarles: Emblems (1635)

A relational approach to SQL: That’s the theme, or one of the themes, of this book. Of course, to treat such a topic
adequately, I need to cover relational issues as well as issues of SQL per se─and while this remark obviously applies
to the book as a whole, it applies to this first chapter with special force. As a consequence, this chapter has
comparatively little to say about SQL as such. What I want to do is review material that for the most part, at any
rate, I hope you already know. My intent is to establish a point of departure, as it were: in other words, to lay some
groundwork on which the rest of the book can build. But even though I hope you’re familiar with most of what I
have to say in this chapter, I’d like to suggest, respectfully, that you not skip it. You need to know what you need to
know (if you see what I mean); in particular, you need to be sure you have the prerequisites needed to understand
the material to come in later chapters. In fact I’d like to recommend, politely, that throughout the book you not skip
the discussion of some topic just because you think you’re familiar with that topic already. For example, are you
absolutely sure you know what a key is, in relational terms? Or a join?1

THE RELATIONAL MODEL IS MUCH MISUNDERSTOOD

Professionals in any discipline need to know the foundations of their field. So if you’re a database professional, you
need to know the relational model, because the relational model is the foundation (or a large part of the foundation,
at any rate) of the database field in particular. Now, every course in database management, be it academic or
commercial, does at least pay lip service to the idea of teaching the relational model─but most of that teaching
seems to be done very badly, if results are anything to go by. Certainly the model isn’t well understood in the
database community at large. Here are some possible reasons for this state of affairs:

 The model is taught in a vacuum. That is, for beginners at least, it’s hard to see the relevance of the material,
or it’s hard to understand the problems it’s meant to solve, or both.

 The instructors themselves don’t fully understand or appreciate the significance of the material.

1
There’s at least one pundit who doesn’t. The following is a direct quote from a document purporting (like this book!) to offer advice to SQL
users: “Don’t use joins ... Oracle and SQL Server have fundamentally different approaches to the concept ... You can end up with unexpected
result sets ... You should understand the basic types of join clauses ... Equijoins are formed by retrieving all the data from two separate sources
and combining it into one, large table ... Inner joins are joined on the inner columns of two tables. Outer joins are joined on the outer columns of
two tables. Left joins are joined on the left columns of two tables. Right joins are joined on the right columns of two tables.”

sql_final.pdf 17 12/8/11 2:33:05 PM


2 Chapter 1 / Setting the Scene

 Perhaps most likely in practice, the model as such isn’t taught at all─the SQL language, or some specific
dialect of that language, such as the Oracle dialect, is taught instead.

So this book is aimed at database practitioners in general, and SQL practitioners in particular, who have had
some exposure to the relational model but don’t know as much about it as they ought to, or would like to. It’s
definitely not meant for beginners; however, it isn’t just a refresher course, either. To be more specific, I’m sure
you know something about SQL; but─and I apologize for the possibly offensive tone here─if your knowledge of the
relational model derives only from your knowledge of SQL, then I’m afraid you won’t know the relational model as
well as you should, and you’ll probably know “some things that ain’t so.” I can’t say it too strongly: SQL and the
relational model aren’t the same thing. Here by way of illustration are some relational issues that SQL isn’t too
clear on (to put it mildly):

 What databases, relations, and tuples really are

 The difference between relation values and relation variables

 The relevance of predicates and propositions

 The importance of attribute names

 The crucial role of integrity constraints

 The Information Principle and its significance

and so on (this isn’t an exhaustive list). All of these issues, and many others, are addressed in this book.
I say again: If your knowledge of the relational model derives only from your knowledge of SQL, then you
might know “some things that ain’t so.” One consequence is that you might find, in reading this book, that you have
to do some unlearning─and unlearning, unfortunately, is very hard to do.

SOME REMARKS ON TERMINOLOGY

You probably noticed right away, in that bullet list of relational issues in the previous section, that I used the formal
terms relation, tuple (usually pronounced to rhyme with couple), and attribute. SQL doesn’t use these terms, of
course─it uses the more “user friendly” terms table, row, and column instead. And I’m generally sympathetic to the
idea of using more user friendly terms, if they can help make the ideas more palatable. In the case at hand, however,
it seems to me that, regrettably, they don’t make the ideas more palatable; instead, they distort them, and in fact do
the cause of genuine understanding a grave disservice. The truth is, a relation is not a table, a tuple is not a row, and
an attribute is not a column. And while it might be acceptable to pretend otherwise in informal contexts─indeed, I
often do so myself─I would argue that it’s acceptable only if we all understand that the more user friendly terms are
just an approximation to the truth and fail overall to capture the essence of what’s really going on. To put it another
way: If you do understand the true state of affairs, then judicious use of the user friendly terms can be a good idea;
but in order to learn and appreciate that true state of affairs in the first place, you really do need to come to grips
with the formal terms. In this book, therefore, I’ll tend to use those formal terms (at least when I’m talking about the
relational model as opposed to SQL), and I’ll give precise definitions for them at the relevant juncture. In SQL
contexts, by contrast, I’ll use SQL’s own terms.
And another point on terminology: Having said that SQL tries to simplify one set of terms, I must say too
that it does its best to complicate another. I refer to its use of the terms operator, function, procedure, routine, and

sql_final.pdf 18 12/8/11 2:33:05 PM


Other documents randomly have
different content
concealed in the turquoise-studded handle must have been refilled
by Dido!--Dido, for the significant reason that she, inheriting the
traditions of her Ashantee grandmother, alone must have been
capable of manufacturing the deadly drug. To prove this assumption,
a feasible one, the devil-stick was close at hand.

Jen picked it up and slightly pressed the handle. At once the


turquoise gems indented the concealed bag; at once the iron fang
protruded from the end of the stick, and on looking closely the major
at the end of the spike observed an oblong drop of greenish hue.

The evidence of his own eyes was enough, and Jen replaced the
devil-stick upon the table, with the full conviction that the bag had
been filled with a fresh preparation of its original venom. This
discovery, to the major's mind, confirmed the guilt of the negress.

"What is the matter?" asked Lady Meg, as she saw the major's face
grow dark with his thought. "Is anything wrong?"

"Yes, Dido is wrong," he said. "I always thought that black witch was
at the bottom of everything. I am sure of it now."

"Dido!" repeated Lady Meg, thoughtfully. "I have heard Mr. Alymer
and Mr. Sarby talking about her. A negress, is she not?"

"Yes, and a murderess!"

"Major! Do you think--"

"Certainly I do. I believe she killed Maurice; but the evidence is as


yet too slight upon which to accuse her. If I thought that she--" here
the major checked himself and resumed in an altered tone--"but I
must think of these things later on. In the meantime I must
conclude my examination of this man."

"Do you think he knows anything?"


"No. I believe he found the devil-stick as he says. Within the
grounds of Mrs. Dallas, mind you!"

"Well, and what does that prove?"

"Prove!" retorted Jen sharply, "simply that it was dropped there by


that black fiend after she had killed Maurice."

"Do you really think she killed him?" asked Lady Meg, her face
growing pale with the intensity of her excitement.

"I do," replied Jen, decisively. "But the evidence--ah, the evidence.
Well," he added, after a pause, "I have something to go on, in this
refilled devil-stick, and the saturated handkerchief."

"But I don't understand--"

"Never mind, my dear lady, you will later on," retorted Jen, with a
nod. Then turning to Battersea, he resumed his examination. "You
know the negress. Dido, who is in the employment of Mrs. Dallas?"
he asked, mildly.

"Yes, sir, an' hawful female she is!"

"How so?"

"Well, sir." Battersea scratched his shock head. "She knows things as
ain't good for 'er. 'Bout that devil-stick es you talks of."

"Oh," cried Jen, recalling Dido's denial, "she knows of that, does
she?"

"Yes, sir, she do. Arsked me 'bout it, but I knowed nuffin, I didn't."

"What did she say to you concerning it?"

"Well, sir, when I brought a message from Dr. Etwald 'bout that
devil-stick--"
"What!" cried Jen, interrupting sharply. "Did Dr. Etwald know about it
also?"

"He did, sir. Leastways he arsked me to arsk Dido 'bout it."

"I thought as much," said Jen, in an excited tone. Then after a


pause, he added: "Battersea, would you like free quarters and plenty
of food and drink for a week?"

"I ain't a fool, sir," said the tramp, with a sheepish grin. "I should,
you bet."

"In that case go down to the kitchen and tell my servants from me
that you are to stay there. Later on I'll see you."

"Thankee, sir. I'll get free quarters and grub for a week," cried
Battersea, rubbing his grimy hands. "My eye, 'ere's oppolance. Can I
go now, sir?"

"At once," replied Jen, and pointed to the door. Battersea bowed
awkwardly to Lady Meg and his benefactor; then he went out of the
room and left the major alone with his visitor.

"What does all this mean?" asked Meg, quite surprised at Jen's
excitement.

"Mean!" cried Jen, in a tone of conviction. "Why! that Etwald is


mixed up in this business also!"

CHAPTER XVI.

THE EVIDENCE OF JAGGARD.


"Etwald!" repeated Lady Meg, thoughtfully. "Is he not the doctor of
whom you have made so great a friend?"

"Yes. I took a viper to my bosom, and it stung me," replied Jen,


who, in his excitement, was pacing backward and forward with hasty
steps. "But I shall be even with him. In some way or another I
believe it is possible to bring home to him this triple crime."

"Do you think he is guilty?"

"I am certain of it. Etwald prophesied to my poor lad, in his


charlatan way, that if he wed Miss Dallas, or even announced his
engagement with her, his fate would be of life in death."

"What did that mean?"

"Mean? Death without the addition of life. That word was brought in
solely to render the prophecy--if it may be called so--confusing.
Etwald was in love with Miss Dallas. He found in Maurice a
formidable rival. He warned him by his pretended prophecy that he
should slay him if he persisted standing in his path. Maurice
announced his engagement upon the very day when Etwald, the
designing scoundrel, went to pay his addresses to the girl. From that
moment he doomed Maurice to death. Yes, I truly believe that such
was his design, and that he offered to buy the devil-stick in order to
carry out his criminal intention."

"Did he ask to buy the devil-stick?" demanded Lady Meg, in surprise.

"Twice; and both times I refused to part with it. Failing to get it
honestly, he stole it."

"You have no proof of that."


"I don't know so much about that," retorted Jen sharply. "You heard
what Battersea confessed, that he had taken a message from Etwald
to Dido about the devil-stick. Well, this doctor has some mysterious,
influence over this negress--what sort of influence I do not know,
but she appears to be afraid of him. I believe he incited her to steal
the devil-stick, and that by his directions she filled it with a fresh
poison."

"But could she prepare the special kind of poison required?"

"Assuredly. She confessed as much. Her grandmother came from


Ashantee, where this devil-stick is used for the purpose of destroying
people. Dido inherits a knowledge of the family secrets, and knows
how to make this poison. It cures nervous headaches--that is, the
perfume of it does--and Dido made some with which she saturated a
handkerchief to bind round the head of her young mistress."

"How do you know that the poisons are the same?"

"From the peculiar, sickly, heavy odor," explained Jen, promptly; and
continued: "Well, you can see the rest for yourself. Dido filled that
devil-stick with the poison," he pointed to the article on the table,
"some of it remains in the wand yet. Etwald used the devil-stick to
kill Maurice, and on going back to tell Dido of his success I have no
doubt he dropped it inside the gates of Mrs. Dallas' grounds, where,
as you have heard, it was found by Battersea. Oh, it is as plain as
day to me," cried Jen, vehemently. "Etwald killed Maurice and stole
the devil-stick to accomplish the murder."

"You have certainly made out a strong case against this man," said
Meg, after a pause, "but it is all theory. Your proofs?"

"I shall find them."

"That will be difficult."


"Doubtless. I hardly anticipated an easy task when I undertook to
learn who killed my dear lad. Besides, David will help me."

Lady Meg sighed, and rising to her feet, she drew her cloak round
her tall form.

"I shall help you also," she said sadly. "That is, if you will accept of
my help."

"Assuredly. You loved Maurice--"

"To my cost, major; but he did not love me. This girl--this Miss
Dallas," she added in a faltering voice, "she must be very lovely, for
Mr. Sarby loves her also. A woman who has three men at her feet
must be wonderful."

Jen shrugged his shoulders.

"She is certainly beautiful," said he, indifferently, "but she is not


clever, and her weak nature is enslaved by the gross superstitions of
Dido."

"I should not think from your description that she was likely to
attract Maurice," said Lady Meg, in a low voice; "but undoubtedly he
loved her dearly; and I--" She made a gesture of despair and moved
toward the door. On the threshold she paused and held out her
hand. "Good-by, major; should I hear anything further I shall let you
know. But the tramp?"

"I shall keep him here."

"Be careful lest he goes away."

"Oh, there is no fear of that," said Jen, in a confident tone. "Free


quarters and plenty of food will keep Battersea in my kitchen. If he
were guilty of the crime, he would not stay, but as it is he will
remain under my eye. I intend to question him further about the
connection between Dido and Etwald; I wonder what power the
doctor holds over the negress."

"You can learn that only from the woman herself."

"Or from Etwald," rejoined Jen. "If I can only succeed in having him
arrested he may confess all."

"Let us hope he will," replied Lady Meg, and after shaking hands
again with Jen, she took her departure.

When the major had seen her carriage drive away he returned to
look after the devil-stick, and examined it long and carefully.
Undoubtedly it had been filled with fresh poison, and undoubtedly
the poison, from the evidence heretofore set forth, had been
prepared by Dido. Jen was more certain than ever that Etwald and
the negress had stolen the devil-stick and had slain Maurice with it.
But the theft of the body! It was that which puzzled him. He could
understand why Etwald wanted Maurice removed from his path. He
could explain, on those grounds, why the devil-stick had been
stolen. But what reason could the pair have for the removal of the
body? The poor boy had died, and his corpse could be of no use to
those who had murdered him. Yet it had disappeared, and the only
person who could give any evidence as to who had entered the
room on that fatal night was Jaggard. But up to the present moment
Jaggard had remained incapable of giving any clear evidence.
Absolutely certain that Etwald was guilty, that Dido was an
accomplice, Jen could not see his way to proving his case without
the assistance of Jaggard.

At first he thought of going into Deanminster for the purpose of


speaking with Inspector Arkel about the discovery of the devil-stick;
but upon reflection he deemed it wiser not to do so, at all events for
the present. Arkel could come only to the same conclusion as
himself--namely, that Battersea, innocent of the crime, had picked
up the devil-stick on the grounds of Mrs. Dallas. Regarding his
suspicions of Etwald, the major determined to keep these to himself
until he was in a position to prove them; for if Etwald were guilty,
the slightest hint that the police were on his track would be sufficient
to put him on his guard. Against so clever a man as the doctor,
Arkel, with his clumsy methods, could do nothing. For the present,
therefore, Jen decided to hold his tongue.

While the major was thus considering what step he should take,
David, returning from a long and solitary walk, entered the room. Of
late the young man had indulged in these lonely excursions, whence
he always returned more melancholy than ever. His fine face was
lean and worn, there were dark circles under his eyes, and his
manner, formerly noted for its composure, was now nervous and
hesitating. On approaching his guardian he saw the devil-stick on
the table, and at once his pale face grew yet paler.

"Where did you find it?" he asked, pointing a trembling finger at the
terrible piece of evidence.

"I did not find it at all," rejoined the major, gloomily; "Lady Meg
brought it to me."

"And she--she----"

"She has nothing to do with the matter," replied Jen, surprised at the
agitation of the young man. "It was Battersea who found it. He
offered it for sale to Lady Meg, and she brought it and the tramp to
me."

"Battersea!" said David, repeating the name in a puzzled tone. "How


did he become possessed of it? Has he anything to do with the
crime?"

"No. He found the devil-stick within the grounds of Mrs. Dallas, near
the gates."

"Who lost it there?" asked Sarby, abruptly.


"Ah!" replied Jen, in a meaning tone. "Tell me that and I'll have the
assassin of our dear Maurice within the walls of Deanminster jail
before the year is twenty-four hours older."

David looked at Jen in astonishment.

"Have you any idea as to the guilty person?" he asked, in a hurried


tone.

"I think so; it is my belief, David, that Dr. Etwald killed Maurice!"

"Impossible! For what reason?"

"Because he wants to marry Isabella Dallas."

"In that case he should rather have killed me than poor Maurice, for,
as my suit to Isabella was supported by Mrs. Dallas, I was the more
formidable rival of the two."

"I don't think so, my boy. Isabella loved Maurice, and to marry him
she would have rebelled against her mother. But I daresay if you
become engaged to her, Etwald will remove you also from his path."

"There will be no need for him to do that," replied David, coldly. "I
shall never marry Isabella."

"What do you say? I thought you loved the girl?"

"I do love her," cried David, vehemently. "I have always loved her,
and shall continue to do so until the day of my death. All the same, I
shall never become her husband."

"Why?"

"For certain reasons!" said Sarby, evasively.

"What are those reasons?"


"I can't tell you."

"Have they anything to do with the death of Maurice?"

"Don't ask me, major. I would tell you if I could, but it is impossible."

Jen rose to leave the room, more wounded than he chose to


confess.

"Of course, my boy," he said rather bitterly, "if you choose to


withhold your confidence from me, I have no right to force you to
speak. All the same as I have been a second father to you, I think
you should be more open with me."

"I would tell you if I could," said David again, but in rather a sullen
manner; "but I have reasons, strong reasons, for not doing so. Later
on--" he paused nervously.

"Well?" demanded Jen, coldly, seeing the hesitation of the man.

"Later on, I may tell you all I know."

"All you know!" repeated Jen, in a startled tone. "About this crime?"

"Yes. I know something, but what it is I dare not tell you now, Uncle
Jen," he added, gravely looking at the elder. "If you are wise, you
will not pursue your inquiry."

"And why not, may I ask, David?"

"Ah!" said Sarby, walking toward the door, "you will know the reason
when you learn the truth!"

After this enigmatical remark he hurriedly left the room, for the
purpose, without doubt, of escaping further questioning. His
demeanor completely puzzled Jen, who could not make out the
meaning of his conversation. Evidently David knew something which
he was unwilling to reveal--something which might lead to the
solution of the profound mystery which enwrapped the death of
Maurice and the extraordinary disappearance of his body.

The more Jen thought about the matter the more perplexed did he
become. The recovered devil-stick, found in the grounds of Mrs.
Dallas, the saturated handkerchief found in the bedroom of the dead
man; and now the unaccountable hints of David that he knew
something likely to throw a light upon these mysteries, joined with
an equally unaccountable refusal to afford such revelation, all these
things puzzled him; but as it was impossible in the absence of actual
knowledge, to come to any reasonable decision, Jen determined to
see Jaggard and see how he was. If Jaggard could only recover his
senses, argued the major, he would be able to say who had stolen
the body. Moreover, in Jen's opinion, the person who committed the
second crime would most probably, by the force of analogous
reasoning, have committed the first.

To the major's surprise, he found that Jaggard had recovered his


senses, and although still weak from his accident and long
insensibility, he was able to talk fairly well. Jen was puzzled by this
sudden--that is, this comparatively sudden--recovery; and he
expressed himself somewhat forcibly to the housemaid Anne, who
had been watching for so long by the bedside of the sick man. The
woman, with the shrewdness of her class, gave her opinion as to its
reason.

"Ever since that handkerchief has been removed sir," said she,
earnestly, "Jaggard has got well. I do believe, sir, that the scent on it
kept the poor dear stupid."

Another light was let in on Jen's mind. Here was the handkerchief
again--perfumed with the devil-stick decoction of poison by Dido,
applied by the hand of Etwald, and its design was evidently to keep
Jaggard in a state of stupor and prevent him from, making
dangerous disclosures. Dido and Etwald once more in partnership.
Jen was more convinced than ever that the pair were at the bottom
of the whole terrible affair.

"I am glad to see that you are better, Jaggard," he said, while
standing by the bed.

"Yes, sir, thank you, sir," replied the man, in a weak voice. "I'm sorry,
sir, but I couldn't help myself. I was drugged, sir."

"I guessed as much," said Jen, grimly. "And who drugged you?"

"That black devil, Dido, sir," replied Jaggard, faintly.

"I guessed as much," said the major once more.

CHAPTER XVII.

THE STORY OF THE NIGHT.

Exhausted by the few words which he had spoken, Jaggard fell back
on his pillows in a dead faint. Seeing that further conversation was
impossible at the present moment, Jen left the patient to the tender
attention of Anne, and withdrew to seek David. He found him in a
melancholy mood, pacing up and down the lawn before the window
of the smoking-room. On perceiving his guardian, Sarby turned pale,
for he thought that Jen had come to continue their previous
conversation, and so force his confidence. But the first words of the
major at once undeceived him.
"Well, David!" said the newcomer, with significance, "I have made
one discovery without your help."

"A discovery. What is it?"

"I know who drugged Jaggard. I have learned who stole the body of
Maurice!"

"Then you know more than I do," replied David, with all the
appearance of truth. "My knowledge extends only to the death; not
to the seizure of the body."

"And you refuse to aid me," said the major, reproachfully; "well,
keep your secret, I may be able to do without your help. But," added
Jen, fixing a piercing glance on the young man, "I notice that you do
not ask me the name of the person who drugged Jaggard."

"Because I guess the name."

"Ah!"

"Mrs. Dallas," said David, faintly. "It was Mrs. Dallas."

Jen drew back a step and looked at his ward with marked surprise.

"No," he said, at length. "Mrs. Dallas has had nothing to do with it."

"But I thought from what you said of the handkerchief dropped in


the room--"

"That being the property of Mrs. Dallas, she had lost it there,"
interrupted Jen, smartly. "No. I told you also that Isabella had
confessed to having dropped it at the time of her midnight visit. But
now I know that she told me a lie!"

"Isabella! A lie! Impossible!"


"Not at all," rejoined Jen, coldly. "I can understand her reason for
telling the lie. She wanted to shield--"

"Her mother!" cried David, quickly interrupting in his turn.

"Your mind seems to run on the mother, David," said Jen, looking
again at Sarby with keen inquisitiveness. "Can you prove by any
chance that she committed the crime?"

Sarby flushed and drew back with cold reserve.

"No, Uncle Jen, I can't. I have my suspicions."

"Against Mrs. Dallas?"

"Well, yes; but I can prove nothing against her."

"It pleases you to be mysterious, David. Shortly I shall insist upon an


explanation."

"Insist!" repeated the young man, annoyed by the peremptory tone


of his guardian.

"Yes. You owe it to me--your second father--to tell the truth. You
owe it to your dead brother's memory--for assuredly Maurice was
your brother."

David stared sullenly at the ground, but in a moment or two he lifted


his head in a defiant manner.

"I owe you much more than I can ever repay," said he, in harsh
tones. "All the same, Uncle Jen, I cannot reveal, even to you, what I
know. If I did so, you would be the first to blame me."

"I don't understand you."

"I don't understand myself," said the young man, despondently,


"save that I am the most miserable man alive."
"You must be, if you know who killed Maurice, yet refuse to
confess," retorted Jen, with some heat. "Will you tell me the truth? I
ask you for the last time."

"And I answer for the last time that the truth is not mine to tell,"
replied David, coldly. "If you doubt me question Etwald."

"What! that criminal?"

David looked up quickly.

"How do you know he is a criminal?"

"I can't give you my reasons. They would take too long to explain.
But I believe that out of jealousy he killed Maurice."

"Oh," said Sarby, ironically; "and out of jealousy he stole the body?"

"No. Dido did that."

"Dido?"

An expression of surprise appeared on the pale face of the younger


man.

"Yes, Dido!" repeated Jen, firmly. "Jaggard has just informed me that
it was Dido who drugged him. Why did she drug him? To steal the
body of my poor lad. Why did she steal the body! To conceal the
crime committed by Etwald."

"I don't quite understand."

"Listen, then, and I shall explain," resumed the major, with growing
excitement. "I firmly believe that Etwald stole the devil-stick, and
with it killed Maurice."

"From a motive of jealousy?"


"Precisely. As you know the body was stolen before the post-mortem
examination could be made. Why was this? Does not your own
reason find an answer to that question?"

"No," replied David, still obstinately unconvinced.

"Why," said Jen, with a nod, "if a post-mortem examination had


been made, traces of poison would have been discovered. The
poison would have been proved as identical with that of the devil-
stick. Thus, beyond all doubt, we should have learned that Maurice
had been killed by the devil-stick."

"Well?"

"Well!" repeated Jen, in an irritated tone, "can you not rouse that
dull brain of yours to some understanding? To avert the discovery,
and to prevent the analysis of the poison in the body. Dido, under
the direction of Dr. Etwald, committed the third crime."

"But why should Dido act so under Etwald?"

"Because the man has some power over her. What that power may
be, I know no more than you do. Although," added Jen, with an
afterthought, "you may be able to explain."

"No. I have no idea why Dido should serve Etwald."

Evidently it was impossible to extract information from so


impenetrable a man. Jen was thoroughly enraged by this display of
obstinacy in a quarter where he least expected to find it. Usually
sweet-tempered--especially toward his boys--the major quite lost
control of his passion at the moment.

"Take care, David," he said, in an angry manner. "You are forcing me


to believe that you are acting in this way from an unworthy motive.
It is your duty to aid me in discovering and punishing the murderer
of Maurice. Yet you leave me to do all the work and refuse your
assistance in any way. Unless you alter your manner, and take me
into your confidence regarding the reason of this strange behavior, a
breach not easily mended may occur between us."

He paused, waiting for his ward to make some reply in defense of


his conduct. The young man neither moved nor spoke, but, paler
than usual, he stood before the major with his eyes on the ground.
More in sorrow than in anger, Jen looked at him, then turned on his
heel with a shrug, and walked into the house. David looked after him
with quivering lips.

"If he only knew the truth," said he, wiping the perspiration from his
face, "what would he say? What would he do? He blames me now;
would he blame me then?"

In the meantime, while Sarby was indulging in this enigmatical


soliloquy. Major Jen was pursuing his way toward the room of
Jaggard. Despairing of obtaining information from David he thought
it possible to learn the truth--at all events of that fatal night--from
Jaggard. Honestly speaking the major was puzzled by the conduct of
his ward. Hitherto, he had always considered David to be an honest
man, but at the present time his conduct savored of duplicity. Did he
know of anything relative to the triple crime which had been
committed? If so, why did he not speak? Finally, was David also
under the fatal influence of Dr. Etwald--the man who, Jen verily
believed, was the source of all these woes?

To none of these questions could the major find feasible answers;


therefore for the time being--i.e., pending the narration of Jaggard--
he dismissed them from his mind. It was possible that the story of
the invalid might throw light on the darkness which overshadowed
the case.

As Jen anticipated, he found that Jaggard had recovered from his


faint, and having had a sleep during the long absence of his master,
was much better. As usual, Anne, the ill-favored housemaid, was
watching by his bedside; but on a sign from Jen, she left the room.
Finding himself alone with his servant, Jen addressed himself
immediately to the business in hand.

"Do you feel stronger, Jaggard?" he asked.

"Much stronger, sir."

"Are you able to talk?"

"I think so, major--for half-an-hour, at least!"

"Half-an-hour will be sufficient," said the major, in a serious voice. "I


wish you to tell me what took place on the night you were drugged."

"About Dido, sir?"

"Yes, Jaggard, about Dido."

The invalid remained silent for a time, then began to speak slowly
and with some little difficulty.

"After you left me, sir," he said in a weak voice, "I remained seated
in my chair beside the bedside of my poor young master. If you
remember there was only one candle in the room, which was placed
on the table, some little distance away. I examined the window and
found it closed."

"You are sure of that?" demanded Jen, anxiously.

"Quite sure, sir. It was bolted and barred. The door was simply
closed, for I never thought of locking it, as I fancied, sir, that you
might return after midnight to see if all was right."

"I did not, however, Jaggard. I fell asleep in the library, after Mr.
Sarby had gone to bed; and, of course, I had every confidence in
you."
"Please don't say that, major," said Jaggard, imploringly, "as I did my
best. It was not my fault that Dido drugged me. I'm sure I don't
know why she did so," continued Jaggard, half to himself. "I never
did her any harm."

The major looked fixedly at the man.

"Do you not know what occurred during the time you were
insensible?" he asked, gravely.

"No, sir. I've only got my wits about me now."

"Has not Anne told you?"

"She hasn't told me anything, sir."

"Well," said Jen, seeing that the man spoke in all good faith, "the
body of Mr. Maurice was stolen on that night."

"The body stolen!" repeated Jaggard, in amazement. "For why, sir?"

"I can't tell, nor can anybody else. All we know is that at three
o'clock in the morning we entered Mr. Maurice's room and found the
window open, the body gone, and you insensible."

"The window open," said Jaggard, thoughtfully. "Then it must have


been opened from the inside, sir."

"By Dido, no doubt."

"I'm certain of it, major; and it was that black witch who stole the
body."

"How did she get into the room?"

"She was hidden under the bed, sir."


"Under the bed! Are you sure?" said Jen, greatly startled by this
information.

"Yes, major. It was this way. I was seated by the bed, at the foot of
it, with my face to the door. The window, as I said, was locked. She
could not have got in at the window, and had she entered by the
door I should have seen her. Besides," added Jaggard, in a faint
voice, "she grabbed me from behind."

"From behind?"

"Yes, sir. I was not quite asleep, but a kind of dozing in my chair. I
don't know what it was made me sleepy, as I was wideawake when
you left, sir. But there was a kind of heavy, sleepy smell about."

"I know, I know--the devil-stick perfume."

"Well, sir, the smell made me sleepy; and though I heard a noise
behind me I could not turn my head. I was just as if in a nightmare,
sir. Then the black arm of that witch came from behind me and
grabbed at my throat, and she held a handkerchief with that stuff on
it to my nose."

"Ah," said Jen, to himself, "I knew that Isabella was speaking falsely.
Go on, Jaggard," he added aloud. "Why did you not call out?"

"I couldn't, sir. I felt as in a dream; but I turned and tried to fight
her. She pushed me over, and I fell like a log. I think I must have hit
my head on a corner of the bed, for I felt a cruel pain at the back of
it."

"You did wound your head, Jaggard; and after that fall you
remembered no more?"

"No, sir, not till to-day. I don't know what it all means, sir, but I'm
sure I know how Dido got into the room."
"Ah! That is what I wish to learn. Well?"

"If you remember, sir. Dido called to see you that day."

"Yes. To ask if I would see her mistress; a most unnecessary


question."

"It was a blind, sir; and when she left the room I don't believe she
left the house."

"What makes you think so?"

"Sir, I took Dido out to the door, and while I was telling her to go
away. Dr. Etwald came out. He told me he would see after her, and I
left them alone. Now, sir," said Jaggard, with emphasis, "I do believe
as Dr. Etwald took that black jade to the room of Mr. Maurice and hid
her under the bed."

CHAPTER XVIII.

THE DEVIL-STICK THIEF.

This long conversation had somewhat exhausted Jaggard, who was


yet weak, so, telling him to cease from talking, Jen recalled the
housemaid, and left the room to think over all that he had learned.
The story of Jaggard convinced him more than ever that Dr. Etwald
was the cause of all the terrible events which had occurred within
the last few weeks. Without doubt it was he who had treacherously
hidden Dido in the chamber of death. After drugging Jaggard, the
negress no doubt had opened the window to admit Etwald, and
between them this precious pair had carried off the dead body. But
for what reason? This Jen could not determine.

To learn the truth, he thought it advisable to call at "The Wigwam"


and interrogate Dido. With the evidence of Jaggard to go on, the
major felt satisfied that he could by threatening her with arrest,
force her into confessing the whole nefarious plot. Who had thieved
the devil-stick? Who had slain Maurice? Who had stolen the body?
Undoubtedly, Etwald was the villain who was guilty of all three
crimes, and the evidence of Dido would be sufficient to convict him
of the deeds.

"Yes," said Jen to himself that night, as he retired to bed, "to-day I


have learned sufficient to implicate Etwald; to-morrow I shall be able
to convict him. Dido must confess or go to prison."

Angered by the selfish way in which David had acted, Jen did not
communicate his discoveries to the young man. During the night he
took counsel with himself, and the next morning he acted upon the
plans which he had formed. These were, to see Dido and force the
truth from her, to send Battersea to Deanminster to fetch both Arkel
and Dr. Etwald to "Ashantee," and finally to communicate his
discoveries to the inspector and get him to arrest Etwald. Once in
prison, and the doctor, intimidated by a fear of death at the hands of
justice, might confess his crimes, and his reasons for committing
them. This straightforward course was the only one to pursue.

After breakfast, therefore, the major wrote two notes. One for Arkel,
asking him to be at "Ashantee" by noon, as the writer had important
matters to discuss; the other for Etwald, requesting him to call and
see Jaggard, who, added Jen, significantly in the letter, had
recovered his senses. Having thus prepared his trap for the doctor to
walk into, Jen delivered the letters to Battersea, with instructions to
set off at once for Deanminster. The tramp, anxious to keep in favor
with Jen for cupboard reasons, lost no time in departing, and when
the major had seen him safely out of the gates, he took his way
toward "The Wigwam" for the all-important interview with Dido.

Before his departure he had left a message for David, who had not
made his appearance at breakfast, requesting the young man to be
in the library at noon.

"If I can force the truth out of Dido," thought Jen, strolling slowly
along in the hot sunshine, "I may get the better of Etwald. Then,
when David sees that the doctor is in the trap, and in danger of
arrest for murder, he may relate what he knows. Though upon my
word," considered the major, frowning, "I don't see what information
he can possibly add to what I have obtained from Jaggard, or what I
am likely to wring from the unwilling lips of Dido. Etwald is the guilty
person. David can tell me no more than that."

On arriving at "The Wigwam," Jen presented his card, and was


shown into the drawing-room, there to wait the arrival of Mrs.
Dallas. Although it was nearly eleven o'clock the indolent Creole was
not yet out of bed, but on hearing that the major had called to see
her, she sent Dido to inform him that she would shortly accord him
an interview. The negress, as gloomy and sullen as ever, delivered
this message with folded arms and bent head. Then, without even a
look at him, she turned to leave the room, when Jen placed himself
between her and the door.

"Not yet. Dido," he said, in a cold voice. "It is true that I called to
see your mistress; but I wish to speak to you also."

Dido started, and cast an inquiring look at the impassive face of the
white man.

"What you wish, sah?" she said, in a grave voice, as emotionless as


that of Jen's.

"To ask you a few questions about the devil-stick."


"Massa, I say all I know ob de debble-stick!"

"Indeed, you did not. Dido. You did not inform me that by Dr.
Etwald's directions you filled the devil-stick with poison, or that you
steeped the handkerchief found in the room of Mr. Alymer in the
same poison for the purpose of drugging my servant; or again, that
you concealed yourself under the bed, and afterward drugged him."

A kind of terror showed itself in the dilated eyes of the negress. She
could not understand how Jen had become possessed of a
knowledge of her crimes, and at first was struck with stupor by the
recital.

Speedily, however, she recovered herself, and with a dark smile of


contempt and pity she was about to deny all, when Jen brought out
his last accusation.

"Nor," said he, fixing his eyes on the woman, "did you confess that
you opened the window of Mr. Alymer's room, and aided Dr. Etwald
to carry away the dead body?"

"De--de--dead--dead!" she stammered, shrinking back.

"Yes, the dead body of Mr. Alymer, which you and Dr. Etwald took to
his house at Deanminster. No denial, woman," said Jen, raising his
voice, as she was about to speak. "I see by your face that you are
guilty."

Dido trembled all over, whether from rage or fear Jen could not
determine, and opened her mouth to give the lie to her accuser.
Then she shut it again, as a heavy step was heard outside the door.
A moment later and Mrs. Dallas, with a face expressive of
astonishment, was standing on the threshold of the room; and Dido
at her feet was making the room resound like a jungle with howlings
like those of a wild beast. All the savage nature of the woman was
now on the surface, and had broken through the sullen restraint of
her impassive demeanor. "What is the meaning of this?" demanded
Mrs. Dallas, with an uneasy glance at the frantic negress.

"I shall explain when Dido stops her howling," said Jen, quite
undisturbed.

"Dido! Dido!" remonstrated Mrs. Dallas, shaking the woman. "Rise;


stop."

"Oh, missy! missy!" wept the negress, getting onto her feet. "It all
am a lie, what dat massa say. Poo' ole Dido know nuffin'--do nuffin'.
Lordy! Lordy! de big lie."

Major Jen took Dido by the shoulder, and giving her a good shake,
commanded her to be silent. At once the negress--who was
evidently acting a part--ceased her outcries, and after casting her
eyes significantly at her mistress, stared sullenly at the floor. Mrs.
Dallas turned pale at this rapid glance, and was obliged to take a
seat to prevent herself from falling. Not a detail of this by-play was
lost upon Jen, who saw in the conduct of mistress and servant a
confirmation of his suspicions. However, he added nothing to his
previous speech, but merely recapitulated--for the benefit of Mrs.
Dallas--the points of his accusation against the negress. Dido heard
him in silence, but this time she made neither outcry nor denial.

Mrs. Dallas appeared to be horrified by the recital. Every now and


then she cast a look of terror at Dido, while passing her
handkerchief over her white lips. When the major concluded she
could only shake her head and stammer a few words.

"It can not be true," she murmured. "It is impossible."

"It is a fact," insisted Jen. "I have the evidence of Jaggard to prove
that Dido was in the room on that night."

"Dido," cried Mrs. Dallas, in a trembling voice, "is this true?"


The negress raised her wild eyes slowly to the face of her mistress.
What she saw therein evidently determined her reply. Without a
word she bent her head.

"Ah," cried Jen, "you admit your guilt?"

"No," said Dido, bluntly, "I say dat I in de room, but I no kill dat
man."

"But you filled the devil-stick with fresh poison?"

"No," said Dido again. "I saw no debble-stick."

"It was found in these grounds."

"Dat so; but I not see dat debble-stick."

"Woman," cried Jen, with energy, "no one but you could
manufacture the poison with which the devil-stick was filled."

"Dat I know; but I no fill de debble-stick."

"Then who did?"

Dido hesitated, looked at Mrs. Dallas, and came out with a lie.

"I don't know," she said, in a stolid tone.

Her mistress rose to her feet and approached the major.

"Do you mean to say that Dido killed Mr. Alymer?" she asked,
nervously.

"No; but she supplied the means to the man who did."

"The man who did!"

"Yes; Dr. Etwald."


"Dr. Etwald!" repeated Mrs. Dallas, in what seemed to Jen to be a
tone of relief. "Why do you think he killed Mr. Alymer?"

"Because Maurice was engaged to your daughter, whom he wished


to marry. Etwald killed my poor lad, so as to remove a dangerous
rival from his path."

"Impossible."

"By no means; and Dido manufactured the poison which was used."

Mrs. Dallas considered.

"I know to what you allude," she said, after a pause. "Dido does
manufacture the drug, but only for the cure of nervous headaches."

"Or to kill men with," rejoined Jen, ironically; "or to drug the
watchers of the dead."

"The watchers of the dead!" echoed Mrs. Dallas, with a start.

"Well, let us say my servant, Jaggard. He was drugged by Dido, and


she stole the body, or rather she aided Etwald to do so."

"Dido, is this true?"

"Yis," said the negress, coldly; "de great massa told me to do dat."

"The great master," repeated Jen; "you mean Dr. Etwald?"

"Yis. Dat so."

"He took away the body of Mr. Alymer, and you helped him?"

"Yis."

"Why did you steal the body?"


Dido shrugged her shoulders.

"Ask de great massa."

"Where did you take it to?" demanded Jen, baffled in one direction
and trying another.

"Ask de great massa," said Dido once more.

"The law will do that."

"The law, Major Jen?" said Mrs. Dallas, alarmed.

"Yes. I intend to have Dr. Etwald arrested."

"You dare not. Why?"

"On three charges. First, that he thieved the devil-stick; second, that
he killed Maurice; and third, that he stole the lad's body."

Mrs. Dallas fell back on the sofa, with a white face. Dido laughed in
a guttural fashion, and shrugged her shoulders contemptuously.

"Voodoo!" she said, and laughed again.

The major guessed that she meant that African witchcraft would
avert disaster from Etwald, and at once flung the word back in her
face.

"Voodoo will not help the doctor," said he, quietly. "This is a civilized
country, and we who inhabit it are above being influenced by such
degrading superstitions. You believe in Voodoo; in Obi; let us see if
such things will protect you."

"Do you mean that Dido is in danger of arrest?" cried Mrs. Dallas, in
a terrified tone.

"Certainly, as the accomplice of Etwald."


"But she did not kill Mr. Alymer."

"She filled the devil-stick with the poison which was used to kill
him," retorted the major, coldly, "and she confesses to having aided
him in stealing the body."

"Ah!" murmured Mrs. Dallas, casting a haggard look around. "All is


lost."

"Are you alluding to Dido?" demanded Jen, rather surprised at her


tone.

Mrs. Dallas was about to speak, when the negress silenced her with
a look, and raised her head proudly.

"Yis. It ole Dido," she said. "But ole Dido not lost. Dat great massa,
he look after ole Dido."

"If you mean Dr. Etwald, he will have enough to do to look after
himself. Well, Mrs. Dallas, as I have learned what I wished to know,
I shall now take my leave."

"You go to ruin us," wept Mrs. Dallas.

"No," said Jen, in an inflexible voice. "I go to punish the man who
killed my boy."

Without another word he left the room. His last glance showed that
Dido had gathered her sobbing mistress in her arms, and was
staring after him in a defiant manner. At the front door Jen heard his
name called softly, and Isabella, with a rich color in her usually pale
cheeks, came flying after him.

"Major, major, I have heard all! I have been listening at the window."

"Then you know that I am aware of your deception about the


handkerchief?"
"Yes. I did not speak truly," stammered Isabella, "but I could not act
otherwise. It was to save a certain person."

"Dr. Etwald?"

"No, not Dr. Etwald, but the person who stole the devil-stick."

"Ah! you know who committed the first of the crimes," cried Jen,
seizing the young girl's arm. "Confess. It was Dr. Etwald who stole
the wand of sleep."

"No! no! It was--it was--"

"Dido?"

"Not Dido. Oh!" cried Isabella, in a tone of anguish, "it was my


mother."

CHAPTER XIX.

FURTHER EVIDENCE.

Major Jen recoiled from the young girl in amazement.

"Your mother," he muttered, hardly believing the evidence of his own


senses. "Your mother stole the devil-stick?"

"Yes; but she did not know what she was doing!"

Jen frowned.
"That is impossible!" he said, positively. "Quite impossible!"

"No! no! Wait! Listen!" said Isabella, much agitated. "I told you
falsehoods before to shield my mother. Now that I know that you
have discovered so much, that you are bent on punishing Dr. Etwald,
I must tell you the truth, so that she may not be dragged down to
ruin. But not here--not here: my mother may see us--and Dido," the
girl shuddered. "Dido, of whom I am afraid. Come with me, major.
Quickly!"

Without glancing toward the house Isabella ran down a secluded


path which led through a kind of shrubbery to the flower-garden,
and then disappeared into a light cane summer-house, constructed
in the Chinese fashion, and which was overgrown with greenery.
Major Jen followed her as rapidly as his more mature age would
permit him; and as he hastened, he felt a wild thrill of delight that at
last he was about to hear the truth. That it should be told to him by
so unexpected a person as Isabella Dallas, was not the least strange
part of this strange affair.

"Major," she said, when somewhat out of breath he had taken his
seat beside her in the summer-house, "although I relate what
inculpates my mother, it is to save her that I do so. Both she and I
are in a net woven by Dido."

"Ah! poor Maurice always mistrusted that negress!"

"He was right to do so. Oh, you do not know what a terrible woman
she is. For years both I and my mother have been under her
influence; and have submitted to her will. Now, I see her in her true
colors, and I am determined to speak the truth. Save myself and my
mother, major; for we are innocent. Dr. Etwald and Dido are the
guilty persons."

"They killed Maurice!"

"Yes. I am sure of it."


Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like