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

Database Design and Implementation 2nd Edition -- download

The document provides information about the book 'Database Design and Implementation 2nd Edition' and its educational focus on database systems from a software developer's perspective. It outlines the structure of the text, including chapters on database systems, JDBC, and efficient query processing, as well as the use of a simplified database system called SimpleDB for practical learning. Additional resources and related books are also mentioned for further exploration of database topics.

Uploaded by

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

Database Design and Implementation 2nd Edition -- download

The document provides information about the book 'Database Design and Implementation 2nd Edition' and its educational focus on database systems from a software developer's perspective. It outlines the structure of the text, including chapters on database systems, JDBC, and efficient query processing, as well as the use of a simplified database system called SimpleDB for practical learning. Additional resources and related books are also mentioned for further exploration of database topics.

Uploaded by

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

Database Design and Implementation 2nd Edition

-- download

https://textbookfull.com/product/database-design-and-
implementation-2nd-edition/

Download more ebook from https://textbookfull.com


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

Database Systems: Design, Implementation, and


Management 13th Edition Carlos Coronel

https://textbookfull.com/product/database-systems-design-
implementation-and-management-13th-edition-carlos-coronel/

Database Systems Design Implementation Management 12th


Edition Carlos Coronel

https://textbookfull.com/product/database-systems-design-
implementation-management-12th-edition-carlos-coronel/

Pro SQL Server Relational Database Design and


Implementation 5th Edition Louis Davidson

https://textbookfull.com/product/pro-sql-server-relational-
database-design-and-implementation-5th-edition-louis-davidson/

Database Principles: Fundamentals of Design,


Implementation, and Management 3rd Edition Carlos
Coronel

https://textbookfull.com/product/database-principles-
fundamentals-of-design-implementation-and-management-3rd-edition-
carlos-coronel/
Pro SQL Server Relational Database Design and
Implementation Sixth Edition Louis Davidson

https://textbookfull.com/product/pro-sql-server-relational-
database-design-and-implementation-sixth-edition-louis-davidson/

Pro SQL Server Relational Database Design and


Implementation: Best Practices for Scalability and
Performance Louis Davidson

https://textbookfull.com/product/pro-sql-server-relational-
database-design-and-implementation-best-practices-for-
scalability-and-performance-louis-davidson/

A Practical Guide to Database Design 2nd Edition Rex


Hogan

https://textbookfull.com/product/a-practical-guide-to-database-
design-2nd-edition-rex-hogan/

A Practical Guide to Database Design 2nd Edition Rex


Hogan

https://textbookfull.com/product/a-practical-guide-to-database-
design-2nd-edition-rex-hogan-2/

Electronic Design Automation for IC Implementation


Circuit Design and Process Technology 2nd Edition
Luciano Lavagno

https://textbookfull.com/product/electronic-design-automation-
for-ic-implementation-circuit-design-and-process-technology-2nd-
edition-luciano-lavagno/
Data-Centric Systems and Applications

Edward Sciore

Database
Design and
Implementation
Second Edition
Data-Centric Systems and Applications

Series editors
Michael J. Carey
Stefano Ceri

Editorial Board Members


Anastasia Ailamaki
Shivnath Babu
Philip A. Bernstein
Johann-Christoph Freytag
Alon Halevy
Jiawei Han
Donald Kossmann
Gerhard Weikum
Kyu-Young Whang
Jeffrey Xu Yu
Edward Sciore
Boston College
Chestnut Hill, MA, USA

ISSN 2197-9723 ISSN 2197-974X (electronic)


Data-Centric Systems and Applications
ISBN 978-3-030-33835-0 ISBN 978-3-030-33836-7 (eBook)
https://doi.org/10.1007/978-3-030-33836-7

The first edition of this book was published by John Wiley & Sons, Inc.

© Springer Nature Switzerland AG 2020


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology
now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this
book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or
the editors give a warranty, expressed or implied, with respect to the material contained herein or for any
errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

This Springer imprint is published by the registered company Springer Nature Switzerland AG.
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface

A database system is a common, visible tool in the corporate world—employees


frequently interact directly with database systems to submit data or create reports.
Database systems are also common, but invisible, as components of software
systems. For example, consider an e-commerce website that uses a server-side
database to hold customer, product, and sales information. Or consider a GPS
navigation system that uses an embedded database to manage the road maps. In
both of these examples, the presence of the database system is hidden from the user;
the application code performs all of the database interaction.
From the point of view of a software developer, learning to use a database directly
is rather mundane, because modern database systems contain sophisticated front
ends that make the creation of queries and reports straightforward. On the other
hand, the possibility of incorporating database functionality into a software applica-
tion is exciting, because it opens up a wealth of new and unexplored opportunities.
But what does “incorporating database functionality” mean? A database system
provides many things, such as persistence, transactional support, and query
processing. Which of these features are needed, and how should they be integrated
into the software? Suppose, for example, that a programmer is asked to modify an
existing application, say to add the ability to save state, or to increase reliability, or to
improve the efficiency of file access. The programmer is faced with several archi-
tectural options. She could:
• Purchase a full-featured general-purpose database system and then modify the
application to connect to the database as a client
• Obtain a more specialized system that contains only the desired features and
whose code can be embedded directly into the application
• Write the necessary functionality herself
In order to make the proper choice, the programmer needs to understand what
each of these options entail. She needs to know not only what database systems do
but also how they do it and why.

v
vi Preface

This text examines database systems from the point of view of the software
developer. This perspective allows us to investigate why database systems are the
way they are. It is, of course, important to be able to write queries, but it is equally
important to know how they are processed. We don’t want to just use JDBC, we
want to know why the API contains the classes and methods that it does. We need a
sense of how hard is it to write a disk cache or logging facility. And what exactly is a
database driver, anyway?

Organization of the Text

The first two chapters provide a quick overview of database systems and their use.
Chapter 1 discusses the purpose and features of a database system and introduces
you to the Derby and SimpleDB systems. Chapter 2 explains how to write a database
application using Java. It presents the basics of JDBC, which is the fundamental API
for Java programs that interact with a database.
Chapters 3–11 examine the internals of a typical database engine. Each of its
chapters covers a different database component, starting with the lowest level of
abstraction (the disk and file manager) and ending with the highest (the JDBC client
interface). The chapter for each component explains the issues and considers possi-
ble design decisions. As a result, you can see exactly what services each component
provides and how it interacts with the other components in the system. By the end of
this part, you will have witnessed the gradual development of a simple but
completely functional system.
The remaining four chapters focus on efficient query processing. They examine
the sophisticated techniques and algorithms that can replace the simple design
choices described earlier. Topics include indexing, sorting, intelligent buffer
usage, and query optimization.

Text Prerequisites

This text is intended for upper-level undergraduate or beginning graduate courses in


computer science. It assumes that the reader is comfortable with basic Java pro-
gramming; for example, it uses the classes in java.util extensively, particularly
collections and maps. Advanced Java concepts (such as RMI and JDBC) are fully
explained in the text.
The material in this book is typically studied as a second course in database
systems. However, I have had success teaching it to students with no database
experience. To that end, this book assumes no prior database knowledge other
than a passing acquaintance with SQL. And students without such knowledge of
SQL will find it easy to pick up what they need.
Preface vii

The SimpleDB Software

In my experience, it is much easier for students to grasp conceptual ideas (such as


concurrency control, buffer management, and query optimization algorithms) than to
grasp how these ideas interact. Ideally, a student should write an entire database
system as part of his coursework, just as the student would write an entire compiler
in a compiler course. However, a database system is much more complex than a
compiler, so that approach is not practical. My solution was to write a simple but
fully functional database system, called SimpleDB. Students can apply their concep-
tual knowledge by examining SimpleDB code and modifying it.
SimpleDB “looks” like a commercial database system, both in its function and
structure. Functionally, it is a multiuser, transaction-oriented database server that
executes SQL statements and interacts with clients via JDBC. Structurally, it con-
tains the same basic components as a commercial system, with similar APIs. Each
component of SimpleDB has a corresponding chapter in the text, which discusses the
component’s code and the design decisions behind it.
SimpleDB is a useful educational tool because its code is small, easily readable,
and easily modifiable. It omits all unnecessary functionality, implements only a tiny
portion of SQL, and uses only the simplest (and often very impractical) algorithms.
There consequently are numerous opportunities for students to extend the system
with additional features and more efficient algorithms; many of these extensions
appear as end-of-chapter exercises.
SimpleDB can be downloaded from the http://cs.bc.edu/~sciore/simpledb.
Details on installing and using SimpleDB appear on that web page and in Chap. 1.
I welcome suggestions for improving the code, as well as reports of any bugs. You
can email me at sciore@bc.edu.

End-of-Chapter Readings

This text is motivated by two questions: What functionality do database systems


provide? What algorithms and design decisions will best implement this function-
ality? Entire shelves can be filled with books that address different aspects of these
questions. Since there is no way that a single text could hope to be comprehensive, I
have chosen to present only those algorithms and techniques that most clearly
illustrate the issues involved. My overriding goal is to teach the principles behind
a technique, even if it means omitting (or reducing) discussion of the most commer-
cially viable version of it. Instead, the end of each chapter contains a “suggested
readings” section. Those sections discuss interesting ideas and research directions
that went unmentioned in the text and provide references to relevant web pages,
research articles, reference manuals, and books.
viii Preface

End-of-Chapter Exercises

The end of each chapter contains numerous exercises. Some exercises are of the
pencil-and-paper variety, designed to reinforce concepts taught in the chapter. Other
exercises suggest interesting modifications to SimpleDB, and many of them make
excellent programming projects. I have written solutions to most of the exercises. If
you are the instructor of a course using this textbook and would like a copy of the
solution manual, please email me at sciore@bc.edu.
Contents

1 Database Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Why a Database System? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 The Derby Database System . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Database Engines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 The SimpleDB Database System . . . . . . . . . . . . . . . . . . . . . . 10
1.5 The SimpleDB Version of SQL . . . . . . . . . . . . . . . . . . . . . . . 11
1.6 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.7 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2 JDBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1 Basic JDBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Advanced JDBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3 Computing in Java vs. SQL . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.4 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.5 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3 Disk and File Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.1 Persistent Data Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.2 The Block-Level Interface to the Disk . . . . . . . . . . . . . . . . . . 60
3.3 The File-Level Interface to the Disk . . . . . . . . . . . . . . . . . . . . 61
3.4 The Database System and the OS . . . . . . . . . . . . . . . . . . . . . . 65
3.5 The SimpleDB File Manager . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.6 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
3.7 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4 Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.1 Two Principles of Database Memory Management . . . . . . . . . 79
4.2 Managing Log Information . . . . . . . . . . . . . . . . . . . . . . . . . . 81

ix
x Contents

4.3 The SimpleDB Log Manager . . . . . . . . . . . . . . . . . . . . . . . . . 83


4.4 Managing User Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.5 The SimpleDB Buffer Manager . . . . . . . . . . . . . . . . . . . . . . . 93
4.6 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
4.7 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
4.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
5 Transaction Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
5.1 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
5.2 Using Transactions in SimpleDB . . . . . . . . . . . . . . . . . . . . . . 108
5.3 Recovery Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
5.4 Concurrency Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
5.5 Implementing SimpleDB Transactions . . . . . . . . . . . . . . . . . . 145
5.6 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
5.7 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
5.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
6 Record Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
6.1 Designing a Record Manager . . . . . . . . . . . . . . . . . . . . . . . . . 159
6.2 Implementing a File of Records . . . . . . . . . . . . . . . . . . . . . . . 165
6.3 SimpleDB Record Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
6.4 SimpleDB Table Scans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
6.5 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
6.6 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
6.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
7 Metadata Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
7.1 The Metadata Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
7.2 Table Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
7.3 View Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
7.4 Statistical Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
7.5 Index Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
7.6 Implementing the Metadata Manager . . . . . . . . . . . . . . . . . . . 205
7.7 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
7.8 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
7.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
8 Query Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
8.1 Relational Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
8.2 Scans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
8.3 Update Scans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
8.4 Implementing Scans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
8.5 Pipelined Query Processing . . . . . . . . . . . . . . . . . . . . . . . . . . 226
8.6 Predicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
8.7 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
8.8 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
8.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Contents xi

9 Parsing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
9.1 Syntax Versus Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
9.2 Lexical Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
9.3 The SimpleDB Lexical Analyzer . . . . . . . . . . . . . . . . . . . . . . 241
9.4 Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
9.5 Recursive-Descent Parsers . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
9.6 Adding Actions to the Parser . . . . . . . . . . . . . . . . . . . . . . . . . 250
9.7 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
9.8 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
9.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
10 Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
10.1 Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
10.2 The Cost of Evaluating a Query Tree . . . . . . . . . . . . . . . . . . . 268
10.3 Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
10.4 Query Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
10.5 Update Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
10.6 The SimpleDB Planner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
10.7 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
10.8 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
10.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
11 JDBC Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
11.1 The SimpleDB API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
11.2 Embedded JDBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
11.3 Remote Method Invocation . . . . . . . . . . . . . . . . . . . . . . . . . . 300
11.4 Implementing the Remote Interfaces . . . . . . . . . . . . . . . . . . . . 305
11.5 Implementing the JDBC Interfaces . . . . . . . . . . . . . . . . . . . . . 306
11.6 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
11.7 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
11.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
12 Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
12.1 The Value of Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
12.2 SimpleDB Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
12.3 Static Hash Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
12.4 Extendable Hash Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
12.5 B-Tree Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
12.6 Index-Aware Operator Implementations . . . . . . . . . . . . . . . . . 345
12.7 Index Update Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
12.8 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
12.9 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
12.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
13 Materialization and Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
13.1 The Value of Materialization . . . . . . . . . . . . . . . . . . . . . . . . . 363
13.2 Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
xii Contents

13.3 Materialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364


13.4 Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
13.5 Grouping and Aggregation . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
13.6 Merge Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
13.7 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
13.8 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
13.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
14 Effective Buffer Utilization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
14.1 Buffer Usage in Query Plans . . . . . . . . . . . . . . . . . . . . . . . . . 397
14.2 Multibuffer Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
14.3 Multibuffer Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
14.4 Determining Buffer Allocation . . . . . . . . . . . . . . . . . . . . . . . . 402
14.5 Implementing Multibuffer Sorting . . . . . . . . . . . . . . . . . . . . . 403
14.6 Implementing Multibuffer Product . . . . . . . . . . . . . . . . . . . . . 404
14.7 Hash Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
14.8 Comparing the Join Algorithms . . . . . . . . . . . . . . . . . . . . . . . 412
14.9 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
14.10 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
14.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
15 Query Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
15.1 Equivalent Query Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
15.2 The Need for Query Optimization . . . . . . . . . . . . . . . . . . . . . 426
15.3 The Structure of a Query Optimizer . . . . . . . . . . . . . . . . . . . . 430
15.4 Finding the Most Promising Query Tree . . . . . . . . . . . . . . . . . 430
15.5 Finding the Most Efficient Plan . . . . . . . . . . . . . . . . . . . . . . . 440
15.6 Combining the Two Stages of Optimization . . . . . . . . . . . . . . 441
15.7 Merging Query Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
15.8 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
15.9 Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
15.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
About the Author

Edward Sciore is a recently retired associate professor in the Computer Science


Department at Boston College. He is the author of numerous research articles about
database systems, which span both theory and practice. His favorite activity, how-
ever, is to teach database courses to captive students. These teaching experiences,
accumulated over a 35-year period, are what led to the writing of this text.

xiii
Chapter 1
Database Systems

Database systems play an important role in the computer industry. Some database
systems (such as Oracle) are enormously complex and typically run on large, high-
end machines. Others (such as SQLite) are small, streamlined, and intended for the
storage of application-specific data. Despite their wide range of uses, all database
systems have similar features. This chapter examines the issues that a database
system must address and the capabilities it is expected to have. It also introduces
the Derby and SimpleDB database systems, which will be discussed in this book.

1.1 Why a Database System?

A database is a collection of data stored on a computer. The data in a database is


typically organized into records, such as employee records, medical records, sales
records, etc. Figure 1.1 depicts a database that holds information about students in a
university and the courses they have taken. This database will be used as a running
example throughout the book. The database of Fig. 1.1 contains five types of
records:
• There is a STUDENT record for each student that has attended the university.
Each record contains the student’s ID number, name, graduation year, and ID of
the student’s major department.
• There is a DEPT record for each department in the university. Each record
contains the department’s ID number and name.
• There is a COURSE record for each course offered by the university. Each record
contains the course’s ID number, title, and the ID of the department that offers it.
• There is a SECTION record for each section of a course that has ever been given.
Each record contains the section’s ID number, the year the section was offered,
the ID of the course, and the professor teaching that section.

© Springer Nature Switzerland AG 2020 1


E. Sciore, Database Design and Implementation, Data-Centric Systems and
Applications, https://doi.org/10.1007/978-3-030-33836-7_1
2 1 Database Systems

STUDENT SId SName GradYear MajorId DEPT DId DName


1 joe 2021 10 10 compsci
2 amy 2020 20 20 math
3 max 2022 10 30 drama
4 sue 2022 20
COURSE CId Title DeptId
5 bob 2020 30
12 db systems 10
6 kim 2020 20
22 compilers 10
7 art 2021 30
32 calculus 20
8 pat 2019 20
42 algebra 20
9 lee 2021 10
52 acting 30
ENROLL EId StudentId SectionId Grade 62 elocution 30
14 1 13 A
SECTION SectId CourseId Prof YearOffered
24 1 43 C
13 12 turing 2018
34 2 43 B+ 23 12 turing 2016
44 4 33 B 33 32 newton 2017
54 4 53 A 43 32 einstein 2018
64 6 53 A 53 62 brando 2017

Fig. 1.1 Some records for a university database

• There is an ENROLL record for each course taken by a student. Each record
contains the enrollment ID number, the ID numbers of the student and the section
of the course taken, and the grade the student received for the course.
Figure 1.1 is just a conceptual picture of some records. It does not indicate
anything about how the records are stored or how they are accessed. There are
many available software products, called database systems, which provide an
extensive set of features for managing records.
What does it mean to “manage” records? What features must a database system
have, and which features are optional? The following five requirements seem
fundamental:
• Databases must be persistent. Otherwise, the records would disappear as soon as
the computer is turned off.
• Databases can be shared. Many databases, such as our university database, are
intended to be shared by multiple concurrent users.
• Databases must be kept accurate. If users cannot trust the contents of a database,
it becomes useless and worthless.
• Databases can be very large. The database of Fig. 1.1 contains only 29 records,
which is ridiculously small. It is not unusual for a database to contain millions
(or even billions) of records.
• Databases must be usable. If users are not able to easily get at the data they want,
their productivity will suffer, and they will clamor for a different product.
1.1 Why a Database System? 3

Fig. 1.2 Implementing the STUDENT records in a text file

The following subsections examine the implications of these requirements. Each


requirement forces the database system to contain increasingly more features,
resulting in more complexity than you might have expected.

1.1.1 Record Storage

A common way to make a database persistent is to store its records in files. The
simplest and most straightforward approach is for a database system to store records
in text files, one file per record type; each record could be a line of text, with its
values separated by tabs. Figure 1.2 depicts the beginning of the text file for the
STUDENT records.
This approach has the advantage that a user could examine and modify the files
with a text editor. Unfortunately, the approach is too inefficient to be useful, for two
reasons.
The first reason is that large text files take too long to update. Suppose, for
example, that someone deletes Joe’s record from the STUDENT file. The database
system would have no choice but to rewrite the file beginning at Amy’s record,
moving each succeeding record to the left. Although the time required to rewrite a
small file is negligible, rewriting a 1 gigabyte file could easily take several minutes,
which is unacceptably long. A database system needs to be much more clever about
how it stores records, so that updates to the file require only small, local rewrites.
The second reason is that large text files take too long to read. Consider searching
the STUDENT file for the students in the class of 2019. The only way is to scan the file
sequentially. Sequential scanning can be very inefficient. You probably know several
in-memory data structures, such as trees and hash tables, which enable fast searching.
A database system needs to use analogous data structures to implement its files. For
example, a database system might organize the records in a file using a structure that
facilitates one particular type of search (e.g., on student name, graduation year or
major), or it might create multiple auxiliary files, each facilitating a different type of
search. These auxiliary files are called indexes and are the subject of Chap. 12.

1.1.2 Multi-user Access

When many users share a database, there is a good chance that they will be accessing
some of its data files concurrently. Concurrency is a good thing, because each user
can be served quickly without having to wait for the other users to finish. But too
4 1 Database Systems

much concurrency is bad, because it can cause the database to become inaccurate.
For example, consider a travel-planning database. Suppose that two users try to
reserve a seat on a flight that has 40 seats remaining. If both users concurrently read
the same flight record, they both will see the 40 available seats. They both then
modify the record so that the flight now has 39 available seats. Oops. Two seats have
been reserved, but only one reservation has been recorded in the database.
A solution to this problem is to limit concurrency. The database system should
allow the first user to read the flight record and see the 40 available seats and then
block the second user until the first user finishes. When the second user resumes, it
will see 39 available seats and modify it to 38, as it should. In general, a database
system must be able to detect when a user is about to perform an action that conflicts
with an action of another user and then (and only then) block that user from
executing until the first user has finished.
Users also may need to undo database updates they have made. For example,
suppose that a user has searched the travel-planning database for a trip to Madrid and
found a date for which there is both an available flight and a hotel with a vacancy.
Now suppose that the user reserves the flight, but while the reservation process is
occurring, all of the hotels for that date fill up. In this case, the user may need to undo
the flight reservation and try for a different date.
An update that is undoable should not be visible to the other users of the database.
Otherwise, another user may see the update, think that the data is “real,” and make a
decision based on it. The database system must therefore provide users with the
ability to specify when their changes are permanent; the user is said to commit the
changes. Once a user commits, the changes become visible and cannot be undone.
Chapter 5 examines these issues.

1.1.3 Dealing with Catastrophe

Suppose that you are running a program that gives a pay raise to all professors, when
the database system unexpectedly crashes. After the system restarts, you realize that
some of the professors have a new salary, but others don’t. What should you do?
You can’t just rerun the program because that would give some professors a double
pay raise. Instead, you need the database system to recover gracefully from the crash,
undoing the updates of all programs that were running when the crash occurred. The
mechanism for doing so is interesting and nontrivial, and is examined in Chap. 5.

1.1.4 Memory Management

Databases need to be stored in persistent memory, such as disk drives or flash drives.
Flash drives are about 100 times faster than disk drives but are also significantly
more expensive. Typical access times are about 6 ms for disk and 60 μs for flash.
However, both of these times are orders of magnitude slower than main memory
1.1 Why a Database System? 5

(or RAM), which has access times of about 60 ns. That is, RAM is about 1000 times
faster than flash and 100,000 times faster than disk.
To see the effect of this performance difference and the consequent problems
faced by a database system, consider the following analogy. Suppose you crave a
chocolate chip cookie. There are three ways to get one: from your kitchen, at the
neighborhood grocery store, or via mail order. In this analogy, your kitchen corre-
sponds to RAM, the neighborhood store corresponds to a flash drive, and the mail
order company corresponds to a disk. Suppose that it takes 5 seconds to get the
cookie from your kitchen. Getting the cookie from the analogous store would require
5000 seconds, which is over an hour. This means going to the store, waiting in a very
long line, buying the cookie, and returning. And getting the cookie from the
analogous mail order company would require 500,000 seconds, which is over
5 days. That means ordering the cookie online and having it shipped using standard
delivery. From this point of view, flash and disk memory look terribly slow.
Wait! It gets worse. Database support for concurrency and reliability slows things
down even more. If someone else is using the data you want, then you may be forced
to wait until the data is released. In our analogy, this corresponds to arriving at the
grocery store and discovering that the cookies are sold out, forcing you to wait until
they are restocked.
In other words, a database system is faced with the following conundrum: It must
manage more data than main memory systems, using slower devices, with multiple
people fighting over access to the data, and make it completely recoverable, all the
while maintaining a reasonable response time.
A large part of the solution to this conundrum is to use caching. Whenever the
database system needs to process a record, it loads it into RAM and keeps it there for
as long as possible. Main memory will thus contain the portion of the database that is
currently in use. All reading and writing occur in RAM. This strategy has the
advantage that fast main memory is used instead of slow persistent memory but
has the disadvantage that the persistent version of the database can become out of
date. The database system needs to implement techniques for keeping the persistent
version of the database synchronized with the RAM version, even in the face of a
system crash (when the contents of RAM is destroyed). Chapter 4 considers various
caching strategies.

1.1.5 Usability

A database is not very useful if its users cannot easily extract the data they want. For
example, suppose that a user wants to know the names of all students who graduated
in 2019. In the absence of a database system, the user would be forced to write a
program to scan the student file. Figure 1.3 gives the Java code for such a program,
assuming that the file is stored as text. Note that most of the Java code deals with
decoding the file, reading each record and splitting it into an array of values to be
examined. The code to determine the desired student names (in bold) is hidden
within the uninteresting file-manipulation code.
6 1 Database Systems

public static List<String> getStudents2019() {


List<String> result = new ArrayList<>();
FileReader rdr = new FileReader("students.txt");
BufferedReader br = new BufferedReader(rdr);
String line = br.readLine();
while (line != null) {
String[] vals = line.split("\t");
String gradyear = vals[2];
if (gradyear.equals("2019"))
result.add(vals[1]);
line = br.readLine();
}
return result;
}

Fig. 1.3 Retrieving the name of students graduating in 2019

Consequently, most database systems support a query language, so that users can
easily specify their desired data. The standard query language for relational data-
bases is SQL. The code of Fig. 1.3 can be expressed by the single SQL statement:

select SName from STUDENT where GradYear = 2019

This SQL statement is much shorter and clearer than the Java program, primarily
because it specifies the values to be extracted from the file without having to specify
how to retrieve them.

1.2 The Derby Database System

Learning database concepts is much more effective if you can use a database system
to follow along interactively. Although there are a wide variety of available database
systems, I suggest that you use Derby database system because it is Java-based, free,
easy to install, and easy to use. The latest version of Derby can be downloaded from
the downloads tab at the URL db.apache.org/derby. The downloaded
distribution file unpacks to a folder containing several directories. For example,
the docs directory contains reference documentation, the demo directory contains a
sample database, and so on. The full system contains many more features than can be
covered here; the interested reader can peruse the various guides and manuals in the
docs directory.
Derby has many features that are not needed in this book. In fact, you only need to
add four files from Derby’s lib directory to your classpath: derby.jar,
derbynet.jar, derbyclient.jar, and derbytools.jar. There are
many ways to change your classpath, depending on your Java platform and operat-
ing system. I will explain how to do it using the Eclipse development platform. If
you are not familiar with Eclipse, you can download its code and documentation
1.2 The Derby Database System 7

from eclipse.org. If you use a different development platform, then you should
be able to adapt my Eclipse directions to fit your environment.
First, create an Eclipse project for Derby. Then configure its build path, as
follows. From the Properties window, select “Java Build Path.” Click on the
“Libraries” tab and then “Add External JARS,” and use the file chooser to select the
four jar files you need. That’s it.
The Derby distribution contains an application, called ij, which enables you to
create and access Derby databases. Because Derby is written completely in Java, ij
is actually the name of a Java class, located in the package org.apache.derby.
tools. You run ij by executing its class. To execute the class from Eclipse, go to
“Run Configurations” in the Run menu. Add a new configuration to your Derby
project; call it “Derby ij.” In the field for the configuration’s main class, enter “org.
apache.derby.tools.ij.” When you run the configuration, ij displays a console
window that asks for input.
Input to ij is a sequence of commands. A command is a string that ends with a
semicolon. Commands can be split over several lines of text; the ij client will not
execute a command until it encounters a line ending in a semicolon. Any SQL
statement is a legal command. In addition, ij supports commands to connect and
disconnect from a database and to exit the session.
The connect command specifies the database that ij should connect to, and
the disconnect command disconnects from it. A given session can connect and
disconnect multiple times. The exit command ends the session. Figure 1.4 shows
an example ij session. The session has two parts. In the first part, the user connects
to a new database, creates a table, inserts a record into that table, and disconnects. In
the second part, the user reconnects to that database, retrieves the inserted values,
and disconnects.
The argument to the connect command is called its connection string. The
connection string has three substrings, separated by colons. The first two substrings
are “jdbc” and “derby,” indicating that you want to connect to a Derby database
using the JDBC protocol. (JDBC is the topic of Chap. 2.) The third substring

ij> connect 'jdbc:derby:ijtest;create=true';


ij> create table T(A int, B varchar(9));
0 rows inserted/updated/deleted
ij> insert into T(A,B) values(3, 'record3');
1 row inserted/updated/deleted
ij> disconnect;
ij> connect 'jdbc:derby:ijtest';
ij> select * from T;
A |B
---------------------
3 |record3

1 row selected
ij> disconnect;
ij> exit;

Fig. 1.4 An example ij session


8 1 Database Systems

identifies the database. The string “ijtest” is the name of the database; its files will be
in a folder named “ijtest”, located in the directory from which the ij program was
launched. For example, if you ran the program from Eclipse, the database folder will
be in the project directory. The string “create ¼ true” tells Derby to create a new
database; if it is omitted (as in the second connection command), then Derby expects
to find an existing database.

1.3 Database Engines

A database application such as ij is comprised of two independent parts: the user


interface (or UI), and the code to access the database. This latter code is called the
database engine. Separating the UI from the database engine is good system design,
as it simplifies the development of the application. A well-known example of this
separation occurs in the Microsoft Access database system. It has a graphical UI that
allows a user to interact with the database by clicking the mouse and filling in values,
and an engine that handles the data storage. When the UI determines that it needs
information from the database, it constructs a request and sends it to the engine. The
engine then executes the request and sends values back to the UI.
This separation also adds flexibility to the system: an application designer can use
the same user interface with different database engines or build different user
interfaces for the same database engine. Microsoft Access provides an example of
each case. A form built using the Access UI can connect to the Access engine or any
other database engine. And the cells in an Excel spreadsheet can contain formulas
that query the Access engine.
A UI accesses a database by connecting to the desired engine and then calling
methods from the engine’s API. As an example, note that the Derby ij program is
really just a UI. Its connect command establishes a connection to the specified
database engine, and each SQL command sends the SQL statement to the engine,
retrieves the results, and displays them.
Database engines typically support multiple standard APIs. When a Java program
connects to an engine, the API of choice is called JDBC. Chapter 2 discusses JDBC
in detail and shows how to write an ij-like application using JDBC.
A connection from a UI to a database engine can be embedded or server-based. In
an embedded connection, the code for the database engine runs in the same process
as the code for the UI, which gives the UI exclusive access to the engine. An
application should use an embedded connection only when the database “belongs”
to that application and is stored on the same machine as the application. Other
applications need to use server-based connections.
In a server-based connection, the code for the database engine executes inside a
dedicated server program. This server program is always running, waiting for client
connections, and need not be on the same machine as its clients. After a client
establishes a connection with the server, the client sends JDBC requests to it and
receives responses.
1.3 Database Engines 9

A server can be connected to multiple clients simultaneously. While the server is


processing one client’s request, other clients can be sending their own requests. The
server contains a scheduler, which queues up requests waiting for service and
determines when they get executed. Each client is unaware of the other clients and
(apart from delays due to scheduling) has the pleasant illusion that the server is
dealing with it exclusively.
The ij session of Fig. 1.4 used an embedded connection. It created the database
“ijtest” on the machine that was running the session, and no server was involved. To
execute an analogous server-based ij session, two things must change: the Derby
engine must run as a server, and the connect command must be modified so that it
identifies the server.
The code for the Derby server is in the Java class NetworkServerControl,
in the package org.apache.derby.drda. To run the server from Eclipse, go to
“Run Configurations” in the Run menu. Add a new configuration to your Derby
project and call it “Derby Server.” In the field for the main class, enter “org.apache.
derby.drda.NetworkServerControl.” In the Arguments tab, enter the program argu-
ment “start -h localhost.” Each time you run the configuration, a console window
should appear indicating that the Derby server is running.
What is the purpose of the program argument “start -h localhost”? The first word
is the command “start,” which tells the class to start the server. You can stop the
server by executing the same class with the argument “shutdown” (or you can simply
terminate the process from the console window). The string “-h localhost” tells the
server to only accept requests from clients on the same machine. If you replace
“localhost” by a domain name or IP address, then the server will only accept requests
from that machine. Using the IP address “0.0.0.0” tells the server to accept requests
from anywhere.1
A connection string for a server-based connection must specify the network or IP
address of the server machine. In particular, consider the following ij connect
commands:

ij> connect 'jdbc:derby:ijtest'


ij> connect 'jdbc:derby://localhost/ijtest'
ij> connect 'jdbc:derby://cs.bc.edu/ijtest'

The first command establishes an embedded connection to the “ijtest” database.


The second command establishes a server-based connection to “ijtest” using the
server running on the machine “localhost,” that is, on the local machine. The third
command establishes a server-based connection to “ijtest” using the server running
on the machine “cs.bc.edu.”
Note how the connect string completely encapsulates the decision to use an
embedded or server-side connection. For example, consider again Fig. 1.4. You
can modify the session to use server-side connections instead of embedded ones by

1
Of course, if you allow clients to connect from anywhere, then you expose the database to hackers
and other unscrupulous users. Typically, you would either place such a server inside of a firewall,
enable Derby’s authentication mechanism, or both.
10 1 Database Systems

simply changing the connect commands. The other commands in the session are
unaffected.

1.4 The SimpleDB Database System

Derby is a sophisticated, full-featured database system. This complexity, however,


means that its source code is not readily understandable or modifiable. I wrote the
SimpleDB database system to be the opposite of Derby—its code is small, easily
readable, and easily modifiable. It omits all unnecessary functionality, implements
only a tiny portion of SQL, and uses only the simplest (and often very impractical)
algorithms. Its purpose is to give you a clear look at each component of a database
engine and how these components interact.
The latest version of SimpleDB can be downloaded from its website at the URL
cs.bc.edu/~sciore/simpledb. The downloaded file unpacks to the folder
SimpleDB_3.x; this folder contains directories simpledb, simpleclient,
and derbyclient. The simpledb folder contains code for the database engine.
Unlike Derby, this code is not packed into a jar file; instead, every file is explicit
within the folder.
To install the SimpleDB engine, you must add the simpledb folder to your
classpath. To do so using Eclipse, first, create a new project; call it “SimpleDB
Engine.” Then from the operating system, copy the subfolder of your
SimpleDB_3.x folder named “simpledb” to the src folder of the project. Finally,
refresh the project from Eclipse, using the refresh command in the File menu.
The derbyclient folder contains example programs that call the Derby
engine. Use the operating system to copy the contents of this folder (not the folder
itself) to the src folder of your Derby project, and refresh it. These client programs
will be discussed in Chap. 2.
The simpleclient folder contains example programs that call the SimpleDB
engine. You should create a new project for them; call it “SimpleDB Clients.” To
ensure that the example programs can find the SimpleDB engine code, you should
add the SimpleDB Engine project to the build path of SimpleDB Clients.
Then use the operating system to copy the contents of simpleclient into the
src directory of SimpleDB Clients.
SimpleDB supports both embedded and server-based connections. One of the
programs in the simpleclient folder is SimpleIJ, which is a simplified
version of the Derby ij program. One difference from ij is that you can only
connect once, at the beginning of the session. When you execute the program, it asks
you for a connection string. The syntax of the connection string is similar to that in
ij. For example, consider the following SimpleDB connection strings:

jdbc:simpledb:testij
jdbc:simpledb://localhost
jdbc:simpledb://cs.bc.edu
1.5 The SimpleDB Version of SQL 11

The first connection string specifies an embedded connection to the “testij”


database. Like Derby, the database will be located in the directory of the executing
program, which is the SimpleDB Clients project. Unlike Derby, SimpleDB will
create the database if it does not exist, so there is no need for an explicit
“create ¼ true” flag.
The second and third connection strings specify a server-based connection to a
SimpleDB server running on the local machine or on cs.bc.edu. Unlike Derby,
the connection string does not specify a database. The reason is that the SimpleDB
engine can handle only one database at a time, which is specified when the server is
started.
SimpleIJ repeatedly prints a prompt asking you to enter a single line of text
containing an SQL statement. Unlike Derby, the line must contain the entire
statement, and no semicolon is needed at the end. The program then executes that
statement. If the statement is a query, then the output table is displayed. If the
statement is an update command, then the number of affected records is printed. If
the statement is ill-formed, then an error message will be printed. SimpleDB
understands a very limited subset of SQL, and SimpleIJ will throw an exception
if given an SQL statement that the engine does not understand. These limitations are
described in the next section.
The SimpleDB engine can be run as a server. The main class is StartServer in the
package simpledb.server. To run the server from Eclipse, go to “Run Configura-
tions” in the Run menu. Add a new configuration to your SimpleDB Engine
project called “SimpleDB Server.” In the field for the main class, enter “simpledb.
server.StartServer.” Use the Arguments tab to enter the name of the desired database.
For convenience, the server will use the database named “studentdb” if you omit the
argument. When you run the configuration, a console window should appear indi-
cating that the SimpleDB server is running.
The SimpleDB server accepts client connections from anywhere, corresponding
to Derby’s “-h 0.0.0.0” command-line option. The only way to shut down the server
is to kill its process from the console window.

1.5 The SimpleDB Version of SQL

Derby implements nearly all of standard SQL. SimpleDB, on the other hand,
implements only a tiny subset of standard SQL and imposes restrictions not present
in the SQL standard. This section briefly indicates these restrictions. Other chapters
of the book explain them in more detail, and many end-of-chapter exercises will ask
you to implement some of the omitted features.
A query in SimpleDB consists only of select-from-where clauses in which the
select clause contains a list of field names (without the AS keyword), and the
from clause contains a list of table names (without range variables).
The terms in the optional where clause can be connected only by the boolean
operator and. Terms can only compare constants and fieldnames for equality.
12 1 Database Systems

Unlike standard SQL, there are no other comparison operators, no other boolean
operators, no arithmetic operators or built-in functions, and no parentheses. Conse-
quently, nested queries, aggregation, and computed values are not supported.
Because there are no range variables and no renaming, all field names in a query
must be disjoint. And because there are no group by or order by clauses,
grouping and sorting are not supported. Other restrictions are:
• The “” abbreviation in the select clause is not supported.
• There are no null values.
• There are no explicit joins or outer joins in the from clause.
• The union keyword is not supported.
• An insert statement takes explicit values only. That is, an insertion cannot be
specified by a query.
• An update statement can have only one assignment in the set clause.

1.6 Chapter Summary

• A database is a collection of data stored on a computer. The data in a database is


typically organized into records. A database system is software that manages the
records in a database.
• A database system must be able to handle large shared databases, storing its data
on slow persistent memory. It must provide a high-level interface to its data and
ensure data accuracy in the face of conflicting user updates and system crashes.
Database systems meet these requirements by having the following features:
– The ability to store records in a file, using a format that can be accessed more
efficiently than the file system typically allows
– Complex algorithms for indexing data in files, to support fast access
– The ability to handle concurrent accesses from multiple users over a network,
blocking users when necessary
– Support for committing and rolling back changes
– The ability to cache database records in main memory and to manage the
synchronization between the persistent and main-memory versions of the
database, restoring the database to a reasonable state if the system crashes
– A language compiler/interpreter, for translating user queries on tables to
executable code on files
– Query optimization strategies, for transforming inefficient queries into more
efficient ones
• The database engine is the component of the database system that maintains the
data. A database application is responsible for user input and output; it calls the
database engine to obtain the data it needs.
• A connection to the database engine can be either embedded or server-based. A
program having an embedded connection has exclusive access to the database
1.8 Exercises 13

engine. A program having a server-based connection shares the engine with other
concurrent programs.
• Two Java-based database systems are Derby and SimpleDB. Derby implements
the full SQL standard, whereas SimpleDB implements only a limited subset of
SQL. SimpleDB is useful because its code is easy to understand. The rest of this
book starting in Chap. 3 will examine this code in detail.

1.7 Suggested Reading

Database systems have undergone dramatic changes over the years. A good account
of these changes can be found in Chap. 6 of National Research Council (1999) and in
Haigh (2006). The Wikipedia entry at en.wikipedia.org/wiki/Data
base_management_system#History is also interesting.
The client-server paradigm is useful in numerous areas of computing, not just
databases. A general overview of the field can be found in Orfali et al. (1999).
Documentation on the various features and configuration options of the Derby server
can be found at the URL db.apache.org/derby/manuals/index.html.
Haigh, T. (2006). “A veritable bucket of facts”. Origins of the data base management
system. ACM SIGMOD Record, 35(2), 33–49.
National Research Council Committee on Innovations in Computing and Commu-
nications. (1999). Funding a revolution. National Academy Press. Available from
www.nap.edu/read/6323/chapter/8#159
Orfali, R., Harkey, D., & Edwards, J. (1999). Client/server survival guide (3rd ed.).
Wiley.

1.8 Exercises

Conceptual Exercises
1.1. Suppose that an organization needs to manage a relatively small number of
shared records (say, 100 or so).
(a) Would it make sense to use a commercial database system to manage these
records?
(b) What features of a database system would not be required?
(c) Would it be reasonable to use a spreadsheet to store these records? What are
the potential problems?
1.2. Suppose you want to store a large amount of personal data in a database. What
features of a database system wouldn’t you need?
1.3. Consider some data that you typically manage without a database system (such
as a shopping list, address book, checking account info, etc.).
14 1 Database Systems

(a) How large would the data have to get before you would break down and
store it in a database system?
(b) What changes to how you use the data would make it worthwhile to use a
database system?
1.4. If you know how to use a version control system (such as Git or Subversion),
compare its features to those of a database system.
(a) Does a version control system have a concept of a record?
(b) How does check-in/checkout correspond to database concurrency control?
(c) How does a user perform a commit? How does a user undo uncommitted
changes?
(d) Many version control systems save updates in difference files, which are
small files that describe how to transform the previous version of the file
into the new one. If a user needs to see the current version of the file, the
system starts with the original file and applies all of the difference files to
it. How well does this implementation strategy satisfy the needs of a
database system?
Project-Based Exercises
1.5. Investigate whether your school administration or company uses a database
system. If so:
(a) What employees explicitly use the database system in their job?
(As opposed to those employees who run “canned” programs that use the
database without their knowledge.) What do they use it for?
(b) When a user needs to do something new with the data, does the user write
his own query, or does someone else do it?
1.6. Install and run the Derby and SimpleDB servers.
(a) Run the ij and SimpleIJ programs from the server machine.
(b) If you have access to a second machine, modify the demo clients and run
them remotely from that machine as well.
Chapter 2
JDBC

A database application interacts with a database engine by calling the methods of its
API. The API used by Java applications is called JDBC (for Java DataBase Con-
nectivity). The JDBC library consists of five Java packages, most of which implement
advanced features useful only in large commercial applications. This chapter is
interested in the core JDBC functionality found in the package java.sql. This
core functionality can be divided into two parts: basic JDBC, which contains the
classes and methods required for rudimentary usage, and advanced JDBC, which
contains optional features that provide added convenience and flexibility.

2.1 Basic JDBC

The basic functionality of JDBC is embodied in five interfaces: Driver, Con-


nection, Statement, ResultSet, and ResultSetMetadata. Moreover,
only a very few methods of these interfaces are essential. Figure 2.1 lists these
methods.
The example programs of this section illustrate the use of these methods. The first
example program is CreateTestDB, which illustrates how a program connects to
and disconnects from a Derby engine. Its code appears in Fig. 2.2, with the JDBC-
related code highlighted in bold. The following subsections examine this code in
detail.

2.1.1 Connecting to a Database Engine

Each database engine will have its own (and possibly proprietary) mechanism for
making connections with clients. Clients, on the other hand, want to be as server
independent as possible. That is, a client doesn’t want to know the nitty-gritty details

© Springer Nature Switzerland AG 2020 15


E. Sciore, Database Design and Implementation, Data-Centric Systems and
Applications, https://doi.org/10.1007/978-3-030-33836-7_2
16 2 JDBC

Driver
public Connection connect(String url, Properties prop)
throws SQLException;
Connection
public Statement createStatement() throws SQLException;
public void close() throws SQLException;

Statement
public ResultSet executeQuery(String qry) throws SQLException;
public int executeUpdate(String cmd) throws SQLException;
public void close() throws SQLException;

ResultSet
public boolean next() throws SQLException;
public int getInt() throws SQLException;
public String getString() throws SQLException;
public void close() throws SQLException;
public ResultSetMetaData getMetaData() throws SQLException;

ResultSetMetaData
public int getColumnCount() throws SQLException;
public String getColumnName(int column) throws SQLException;
public int getColumnType(int column) throws SQLException;
public int getColumnDisplaySize(int column) throws SQLException;

Fig. 2.1 The APIs for basic JDBC

import java.sql.Driver;
import java.sql.Connection;
import org.apache.derby.jdbc.ClientDriver;

public class CreateTestDB {


public static void main(String[] args) {
String url = "jdbc:derby://localhost/testdb;create=true";
Driver d = new ClientDriver();
try {
Connection conn = d.connect(url, null);
System.out.println("Database Created");
conn.close();
}
catch(SQLException e) {
e.printStackTrace();
}
}
}

Fig. 2.2 The JDBC code for the CreateTestDB client


2.1 Basic JDBC 17

of how to connect to an engine; it simply wants the engine to provide a class for the
client to call. Such a class is called a driver.
JDBC driver classes implement the interface Driver. Derby and SimpleDB
each have two driver classes: one for server-based connections and one for embed-
ded connections. A server-based connection to the Derby engine uses the class
ClientDriver, whereas an embedded connection uses EmbeddedDriver;
both classes are in package org.apache.derby.jdbc. A server-based connec-
tion to the SimpleDB engine uses the class NetworkDriver (in package
simpledb.jdbc.network), whereas an embedded connection uses
EmbeddedDriver (in package simpledb.jdbc.embedded).
A client connects to a database engine by calling a Driver object’s connect
method. For example, the following three lines of Fig. 2.2 make a server-based
connection to a Derby database:

String url = "jdbc:derby://localhost/testdb;create=true";


Driver d = new ClientDriver();
Connection conn = d.connect(url, null);

The connect method takes two arguments. The first argument to the method is
a URL that identifies the driver, the server (for server-based connections), and the
database. This URL is called the connection string and has the same syntax as the ij
(or SimpleIJ) server-based connection strings of Chap. 1. The connection string
in Fig. 2.2 consists of four parts:
• The substring “jdbc:derby:” describes the protocol used by the client. Here, the
protocol says that this client is a Derby client that speaks JDBC.
• The substring “//localhost” describes the machine where the server is located.
Instead of localhost, you could substitute any domain name or IP address.
• The substring “/testdb” describes the path to the database on the server. For a
Derby server, the path begins at the current directory of the user that started the
server. The end of the path (here, “testdb”) is the directory where all data files for
this database will be stored.
• The remainder of the connection string consists of property values to be sent to
the engine. Here, the substring is “;create ¼ true”, which tells the engine to create
a new database. In general, several property values can be sent to a Derby engine.
For example, if the engine requires user authentication, then values for the
properties username and password would also be specified. The connection
string for the user “einstein” might look like this:
"jdbc:derby://localhost/testdb;create=true;user=einstein;
password=emc2"

The second argument to connect is an object of type Properties. This


object provides another way to pass property values to the engine. In Fig. 2.2, the
value of this argument is null because all properties are specified in the connection
string. Alternatively, you could have put the property specification into the second
argument, as follows:
Random documents with unrelated
content Scribd suggests to you:
ingenuity in devising the most extreme cases by which to illustrate the
inviolability of what has become known as the seal of confession. Human
nature being what it is, and priestly nature being subject to human
infirmities, the violation of the seal has, at all times, been a source of
anxiety and the object of rigorous punishment, administered to the secular
clergy by the spiritual courts, and to the regulars by their superiors. The
Roman Inquisition, in the first half-century of its existence, assumed
exclusive cognizance of the offence, and demanded that all offenders,
whether secular or regular, should be tried by its tribunals, but, in 1609, it
abandoned its jurisdiction and left them to their bishops and prelates.[834]
As the heresy involved in betraying the confidence of the penitent was
only an inferential error as to the sacrament—an artificial pretext like that
devised with regard to solicitation—the Spanish Inquisition did not hold it
to be comprised in the general delegation of faculties, but that a special
papal commission was requisite. No attempt seems to have been made to
obtain this until 1639, when, on October 11th, the Suprema addressed Philip
IV a consulta setting forth that numerous denunciations were received by
the tribunals against confessors who revealed confessions, and that
inquisitors were asking urgently for permission to prosecute such cases as
violations of divine, natural and political law, rendering culprits suspect in
the faith, this being even more derisory of the sacrament than solicitation. It
was notorious that the Ordinaries did not check it among the secular clergy,
nor their prelates among the regulars, nor could, in such hands, any remedy
be efficacious, because in public trials the witnesses would be bought off or
frightened off, and there were no secret prisons to assure the necessary
segregation of the accused. The king was therefore asked to procure from
the pope, for the Inquisition, exclusive jurisdiction over the offence.[835]
The Suprema probably did not exaggerate as to the denunciations received
by the tribunals, for, in the minor one of the Canaries, we find it, in 1637,
receiving testimony against Diego Artiaga, priest of Hierro, for this offence,
in 1643, against Diego Salgado, priest of la Palma and, in 1644 against Fray
Matías Pinto of Teneriffe.[836]
There can be no doubt that Philip, as usual, acceded to the request of the
Suprema, but Urban VIII seems not to have been responsive. He had a
plausible reason for declining, in the fact that the Roman Inquisition had
abandoned its jurisdiction over the matter and, at the moment, he was at
odds with the Spanish over the question of censorship and of the Plomos del
Sacromonte. The offence was never included in the Edict of Faith, but
occasionally it is enumerated among the charges against confessors on trial
for solicitation, as in the cases of the Franciscan Fray Juan Pachon de Salas,
in Mexico in 1712, of the Carmelite Ventura de San Joaquin in 1794, and of
Fray Antonio Ortuño in 1807.[837] It was difficult to eradicate belief in the
competence of the Inquisition and, as lately as 1808, José Antonio Alvárez,
priest of Horcajo de los Montes, was denounced for this offence to the
Toledo tribunal, but the trial was suspended, probably through doubt as to
jurisdiction.[838] When the question was brought up squarely, in the case of
Doctor Don Francisco Torneo, before the Valencia tribunal, after due
discussion it decided, March 28, 1816, that it had no jurisdiction, and the
case was accordingly dismissed.[839]

General Utility.
The efficient organization of the Inquisition and the
dread which it inspired caused it to be invoked in GENERAL
UTILITY
numberless contingencies, most diverse in character and
wholly foreign to the objects of its institution. A brief enumeration of a few
of these will serve to complete our survey of its activity and, trivial as they
may seem, to illustrate how powerful was the influence which it exercised
over the social life of Spain.
The value of its services, arising from the indefinite extent of its powers,
was recognized early. In 1499, a Benedictine monastery complained to
Ferdinand that it had pledged a cross to a certain Pedro de Santa Cruz and
could not recover it, as he had placed himself under protection of
Dominicans, who claimed exemption from legal processes. Ferdinand
thereupon ordered the inquisitors of the city to settle the matter; they
neglected it and he wrote again peremptorily, instructing them to seize the
cross and do justice between the parties. In April, 1500, the king instructs
the Valencia tribunal to recover for Don Ramon López, of the royal guard,
two runaway slaves and some plate which they had stolen.[840] Evidently
there was no little variety of duties expected of the Holy Office.
In 1518 a nunnery of Clares, in Calatayud, complained that, within ten
paces of their house, there had been built a Mercenarian convent of which
the inmates were disorderly; the nuns could not walk in their garden
without being seen and great scandals were apprehended. Charles V applied
to Leo X to have the Mercenarians replaced by Benedictines or Gerónimites
and the Inquisition was invoked to assist.[841] Parties sometimes obtained
papal briefs to have their suits transferred to the tribunals. In 1548 Doña
Aldonza Cerdan did this in a litigation with Don Hernando de la Caballería
and, in 1561, Doña Isabel de Francia in a suit with Don Juan de Heredia. In
both cases the inquisitors of Saragossa refused to act until Inquisitor-general
Valdés ordered them to do so.[842] All inquisitors were not thus self-
restrained, for when, about this time, a general command was issued
forbidding them to prosecute for perjury committed in other courts, it shows
that they had been asked to do so and that some of them, at least, were
ready to undertake such business.[843] In 1647, when the prevalence of
duelling called for some effective means of repression, among the remedies
proposed was that sending a challenge should be made a matter for the
Inquisition, on the ground that the infamy accruing to the offender and his
descendants would be the most effective discouragement to punctilious
gentlemen.[844] The suggestion apparently was not adopted, but it illustrates
the readiness to have recourse to the elastic jurisdiction of the Holy Office.
The Jesuits found the Inquisition of much service when, through the
favor of Olivares, they were enabled to invoke its intervention in one of
their quarrels with the Dominicans. In 1634, Fray Francisco Roales issued a
pamphlet against the Society and Dr. Espino, an ex-Carmelite, published
two others. They were answered by Padre Salazar and there the matter
might have ended, but the Jesuits appealed to Philip IV and to Olivares,
who promised satisfaction and ordered the Inquisitor-general Sotomayor
(himself a Dominican) to take action, with the significant hint that he would
be watched. A royal decree of January 29, 1635, rebuked the Suprema for
lack of zeal, and ordered it to act with all diligence and to inflict severe
punishment. It responded promptly on February 1st with an edict
suppressing the pamphlet of Roales under heavy penalties, but this did not
suffice and, on June 30th, it prohibited every one, layman or ecclesiastic,
from saying anything in private or in public, derogatory to any religious
Order or the members thereof, under exemplary penalties, to be rigorously
executed—a decree which had to be repeated in 1643.
On June 27, 1635 the three obnoxious pamphlets were burned with
unprecedented ceremony. There was a solemn procession of the officials
and familiars, with the standards of the Inquisition, while a mule with
carmine velvet trappings bore a chest painted with flames in which were the
condemned writings. It traversed the principal streets to the plaza, where a
fire was lighted; a herald, with sound of trumpet, proclaimed that the
Company of Jesus was relieved of all that had been said against it and that
these papers were false, calumnious, impious and scandalous; they were
cast by the executioner into the flames and then the box and the procession
wended their way solemnly back to the Dominican College of San Tomas.
The effect of the demonstration, however, was somewhat marred by the
populace believing that the box contained the bones of a misbelieving Jew,
and accompanying the procession with shouts of “Death to the dogs!” and
other pious ejaculations.
Espino was arrested and incarcerated—not for the last
time for, in 1643, he boasted that he had been imprisoned General Utility
fifteen times for his attacks on the Jesuits. Roales was
more fortunate; he was a chaplain of Philibert of Savoy; his pamphlet had
been printed in Milan and he was safe in Rome, but a printer who had
issued an edition in Saragossa was arrested and presumably sent to the
galleys, and a Dominican Fray Cañamero, who had circulated the three
pamphlets, was ordered to be arrested but seems to have saved himself by
flight. Still the irrepressible conflict continued and the Inquisition was kept
busy in prosecuting offenders and suppressing obnoxious utterances. It even
construed its duty so rigidly that it condemned a memorial of the
unfortunate creditors who suffered by the bankruptcy, in 1645, of the Jesuit
College of San Hermengildo in Seville, when some three hundred
depositors lost four hundred and fifty thousand ducats, and were struggling
to rescue the remaining assets from the hands of the Jesuits.[845]
The Granada tribunal did not pause to enquire as to its jurisdiction when,
in May 1646, owing to the scarcity of wheat, there were bread-riots and the
mob had control of the city. It summoned all the grain-measurers and
porters, under pain of excommunication, to appear before it on a matter of
importance. By examining them, considerable stores of hidden corn were
revealed; the corregidores registered it and the price was fixed at forty-two
reales.[846] This was volunteer action but, in 1648, when a pestilence was
raging in Valencia, the tribunal was called upon to maintain the quarantine
at one of the city gates. The king, on February 1, 1649, notified the
Suprema that the pest had ceased in Valencia, but that it was violent at
Cádiz, San Lucar and other places, and urged continued vigilance, to which
the Suprema replied that it had, since April, done its full duty, but that the
municipal officials were very negligent, and it asked him to order them to
do their share.[847] Apparently the Inquisition was relied upon for
quarantine work. As lately as July 2, 1818, the Suprema wrote to all the
tribunals that the plague had appeared at Tangier and threatened Spain with
the most terrible of calamities. The king had ordered energetic precautions,
in which all branches of the Government must coöperate, and it was no time
for hesitation or scruples. The tribunals were therefore instructed to keep
watch on the officials of all departments and see that they did their duty
and, if they could devise more effective measures, they were invited to
make suggestions.[848]
The unlimited interference of the Inquisition with matters pertaining to
episcopal supervision is seen in two or three cases tried by the Madrid
tribunal. May 5, 1656, it sentenced the priest, Francisco Pérez Lozano, to
exile for a year from various places for his share in founding a confraternity
with what were called “statutos execrables.” February 6, 1688, Juan
Moreno de Piedrola, a priest of the Congregation of San Salvador, who
proposed to establish a congregation, in the rules of which the tribunal
discovered censurable propositions, was ordered to surrender all the papers
and not to discuss it in word or writing and was exiled until he should have
permission to return, with warning that otherwise he would be prosecuted
with the full rigor of the law. As he was not required to abjure even de levi,
it shows that there was no suspicion of heresy involved. Then, in 1697, Fray
Juan Maldonado, of the Order of San Juan de Dios, had three years of exile
for preaching, in the church of his convent at Ciudad Real, a sermon
characterized as burlesque and scandalous, though there is no hint of its
being in any way heretical.[849]
This perpetual intrusion into all manner of affairs,
irrespective of heresy rather increased towards the last. In General Utility
1788, Antonio López was prosecuted in Valencia for
selling rosaries with bones made of clay as relics. In 1789, Andrés Joáñez, a
coachman, for a conversation on a superstitious subject. In 1791, the
Carmelite Fray Bonifacio de San Pablo, for attempting to print a satirical
paper; Josef de la Rosa, in Cordova, for carrying a consecrated wafer in a
relic-bag; Vicente Felerit, in Valencia, for a “vain observance.” In 1795,
Don Miguel Catalá, fiscal in Buñol and Josef Sánchez Masquifa, a
scrivener, were prosecuted for using, in drafting testaments, the words
“diversos atributos,” when alluding to the Trinity. In 1799, Juan Rodríguez,
a priest in Santiago, for assisting and performing ceremonies in a mock-
marriage. In 1808, Josef Várquez de la Torre, a scrivener of Valencia, for
drawing a deed of separation between spouses. In 1818, in Valencia,
Vicente Maicas, priest of Cedrillos, for not wanting his parishioners to die
in the Franciscan habit.[850] As all these cases presuppose denunciation,
they illustrate the popular estimate of the all-embracing powers of the
Inquisition and the espionage under which every Spaniard lived.
In fact, there was scarce anything in which the Inquisition did not feel
itself authorized to intervene. The latitude with which inquisitors construed
their own powers is manifest in their assuming to issue licences to hunt in
prohibited places, sometimes for their own benefit and sometimes for that
of others. This was an abuse which the Suprema strove to correct by
forbidding it in 1527, but it was so persistent that the prohibition had to be
repeated in 1530 and again in 1566.[851]
As the Inquisition was supreme within its jurisdiction and claimed the
right to define the extent of its powers, there was no one to call it to account
for their arbitrary exercise. If any other body in the State felt that its rights
were invaded, the only recourse was to the sovereign and we have seen
how, under the Hapsburgs, the crown, with scarce an exception, decided in
its favor.
BOOK IX.

CONCLUSION.

CHAPTER I.

DECADENCE AND EXTINCTION.

THE Inquisition may be said to have reached its apogee under Philip IV.
We have had ample opportunity to see how that pious monarch yielded to
its aggressiveness, until it became a virtually independent organization
within the State, obeying the royal mandates or not, as best suited its
convenience, and engaged in almost perpetual controversies with the other
branches of the government, while the king, with rare exceptions, submitted
to its exigencies. It is true that, in his financial distress, he compelled the
restitution of a small part of the confiscations and that he asserted the royal
prerogative of making and unmaking inquisitors-general and of appointing
members of the Suprema but, when once he had exercised the power, his
appointees acted in independence. It would not be easy to imagine a more
complete assertion of irresponsible authority than the sudden arrest of
Villanueva—of a leading minister in the absence of the sovereign, at a time
of the utmost confusion, when nothing would have been risked by delay,
save perhaps that the sovereign might have refused assent. Yet not only did
Philip condone this but he threw himself into the persecution of his favorite
with such ardor that he could scarce restrain himself from risking a rupture
with the Holy See in defence of the Holy Office. Under the disastrous
regency of Maria Ana of Austria and the reign of Carlos II, the royal
authority almost disappeared and, although this gave such men as Nithard
and Valladares opportunity to assert still further the independence of the
Inquisition, it also enabled Don John of Austria to banish Nithard and the
other governmental departments to emulate its disregard of the royal
authority. There was an omen of the future when they united, in 1696, in the
Junta Magna, to protest against the encroachments of the Inquisition and to
demand its withdrawal into its proper limits, although by dextrous
management the attempt was baffled.

The Bourbons.
With the advent of the Bourbon dynasty a new element entered into the
political organization of Spain. The absolutism of Louis XIV had embraced
the Church as well as the State, and the Gallican theories as to the power of
the Holy See were encouraged in order to assure the headship of the crown.
It was inevitable that Philip V and his French advisers should entertain very
different views as to the relations between the king and the Inquisition from
those which had been current for a century. Even at the height of the War of
Succession, we have seen how Philip, in the affair of Froilan Díaz,
intervened as master and regulated the relations between the inquisitor-
general and the Suprema, how he undertook to reform the Inquisition and
how, in many ways he curbed its audacity. But for a court intrigue, working
through Philip’s uxoriousness, Macanaz might have succeeded in his
project of rendering the Inquisition wholly subordinate to the crown, and
though the vindictiveness of the Holy Office inflicted on him life-long
punishment for the attempt, this did not prevent the continued assertion of
the royal supremacy, as we have had occasion to see in repeated instances
and in many different directions.
Philip’s assertion of the royal prerogative, however, by
no means implied any lack of zeal for the faith and, as long PHILIP V
as the Inquisition confined itself to its duties of
exterminating heresy, it had his cordial support. Frequent allusions have
been made above to its renewed activity during the period following the
close of the War of Succession. Full statistics are lacking, but in sixty-four
autos, between 1721 and 1728, there appeared nine hundred and sixty-two
culprits and effigies, of whom one hundred and fifty-one were relaxed.[852]
That this met his hearty approbation is manifested by the letter which he
addressed, January 14, 1724, to his son Luis, when abdicating in his favor.
In this the exhortations breathing a lofty morality are accompanied with
earnest injunctions to maintain and protect the Inquisition, as the bulwark of
the faith, for to it is attributable the preservation of religion in all its purity
in the states of Spain, so that the heresies which have afflicted the other
lands of Christendom, causing in them ravages so deplorable and horrible,
have never gained a foothold there.[853] Small-pox cut short the reign of
Luis to seven months, after which Philip was obliged to resume the weary
burden, till death released him, July 9, 1746, and if, during this later portion
of his government, the Inquisition was less busy, this may safely be
attributed to flagging energies and lack of material and not to any restraint
on the part of the sovereign. The punishment which he allowed it to inflict
on Belando, for the history of his reign of which he and his queen, after
careful scrutiny, had accepted the dedication, shows how untrammelled was
its exercise of its recognized functions.
Yet Philip unwittingly started the movement that was ultimately to
undermine the foundations on which the Inquisition rested. He brought with
him from France the conviction that the king should be the patron of letters
and learning, and he had the ambition to rule over a people of culture. He
aroused the slumbering intellect of Spain by founding the Academies of
Language and of History and of Medicine, the Seminary of the Nobles, and
the National Library, and he replaced for Catalonia the University of Lérida
by that of Cervera. Notwithstanding the vigilance of the censorship, it was
impossible that the awakening intelligence of the nation, thus stimulated,
should not eagerly grasp at the forbidden fruit of modern philosophism, all
the more attractive in that it had to be enjoyed in secret. Fernando VI, from
1746 to 1759, followed his father’s example, in encouraging the spread of
culture. Carlos III was even more energetic in urging the enlightenment of
his subjects, and thus there was gradually formed a public, few in numbers,
it is true, but including the statesmen in power, which had lost the old
Spanish conception that purity of faith was the first essential, and regarded
the Inquisition as an incumbrance, save in so far as it might be used for
political ends. The Inquisition still inspired fear, and the case of Olavide
shows that these opinions had to be cherished in secret, but the number who
entertained them was indicated when the bonds of society were loosened
and the national institutions crumbled in the earthquake of the Napoleonic
invasion.
Possibly the diffusion of this modern rationalistic spirit, insensibly
affecting even those opposed to it, may partly explain the rapidly
diminishing activity of the Inquisition. The great tribunal of Toledo, in the
fifty-five years, from 1740 to 1794 inclusive, despatched but fifty-seven
cases, or an average of but one a year.[854] This cannot be attributed to a
lack of culprits, for bigamy, blasphemy, solicitation, sorcery and similar
offences, which furnished so large a portion of the penitents of old, were as
rife as ever. The fact is, that the officials were becoming indifferent and
careless, except in the matter of drawing their salaries. When, on May 22,
1753, the priest Miguel de Alonso García was to be sentenced in the
audience-chamber with closed doors and in the presence of the officials, it
happened that there were no witnesses of the solemnity because none of the
officials were to be found in the secreto.[855]
The personnel of the Inquisition was visibly
deteriorating and consequently forfeiting the respect of the CARLOS III
community. There had long been complaint of the
insufficiency of the salaries, which had remained stationary while the
purchasing power of money had greatly diminished, and there had been no
reduction in the official staffs to correspond with the dwindling business.
Thus, in spite of the empleomanía characteristic of the nation, and of the
privileges and exemptions attached to official position, it became
increasingly difficult to fill the offices properly. As early as 1719, the
inquisitors of Barcelona complained to the Suprema of the trouble they
experienced getting people to serve, on account of lack of desire for the
offices and the absence of advantage accruing from them.[856] In 1737 we
find that the Toledo tribunal had neither a commissioner nor a notary in
Guadalajara, the capital of a province which, in 1787, numbered 112,750
souls.[857] In 1750, a writer deplores that the stipend of eight hundred
ducats is insufficient to support the dignity of an inquisitor, so that the
inquisitor-general is not always able to make fitting nominations. This
necessitates the appointment of calificadores to examine the doctrines
brought under review, resulting in the indefinite prolongation of cases, and
also in lack of vigilance to suppress the errors perpetually propagated in
books; when the calificadores are not paid, they are slow in their work and,
to escape paying them, many things which ought to be referred to them are
passed over.[858] That the respect felt for the Inquisition should diminish
under these circumstances was inevitable and altogether, at this period, it
presents the aspect of an institution which had survived the causes of its
creation and was hastening to its end. Yet it had exercised too powerful an
influence in moulding the Spanish character for it to disappear when its
mission was accomplished, and we shall see how violent were the struggles
attendant upon its dissolution.
Meanwhile it dragged on its existence under constantly increasing
limitations. Fernando VI, it is true, gave it obstinate support in its quarrel
with Benedict XIV over the works of Cardinal Noris, but he dealt a severe
blow when, in 1751, he deprived of the fuero the officials of the tribunal of
Lima. Carlos III, who succeeded in 1759, came from Naples with the
highest ideals of royal supremacy, coupled with less respect for
ecclesiastical claims than was current in Spain; he surrounded himself with
advisers such as Roda, Campomanes, Aranda and Floridablanca, who were
more than suspected of leanings to modern philosophism, and his reign of
benevolent despotism was marked with a series of measures designed to
diminish or abolish the privileges of inquisitorial officials, to repress abuses
and to tame arrogance. The complete control which he assumed over its
functions is exhibited in the rules imposed, in 1768, on its censorship and,
in 1770 and 1777, on its jurisdiction over bigamy, when he ordered it in
future to limit its operations to the suppression of heresy and not to
embarrass the royal courts. The theory thus developed of the relations
between the crown and the Holy Office is formulated in a consulta of the
Council of Castile, November 30, 1768: “The king as patron, founder and
endower of the Inquisition, possesses over it the rights inherent in all royal
patronage.... As father and protector of his vassals, he can and ought to
prevent the commission of violence and extortion on their persons, property
and reputation, indicating to ecclesiastical judges, even in their exercise of
spiritual jurisdiction, the path pointed out by the canons, so that these may
be observed. The regalías of protection and of this indubitable patronage
have established solidly the authority of the prince, in issuing the
instructions which he has deigned to give to the Holy Office acting as an
ecclesiastical tribunal.”[859] Under such conditions, he was quite content
with its existence and, when Roda suggested its suppression and presented
various documents to show that this had been discussed under Charles V,
Philip II and Philip V, he merely replied “The Spaniards want it and it gives
me no trouble.”[860] In fact, the time had not arrived for such drastic
measures. The Abbé Clément reports a conversation with Aranda, October
29, 1768, in which the count warned him that it was necessary to speak of
the Inquisition with great reserve, for people imagined that all religion
depended on it; it was, in truth, an obstacle to all improvement, but time
would be required to deal with it, and he advised Clément to allude to it
only to Roda and Campomanes.[861]

With the accession, in 1788, of Carlos IV, there opened for Spain a new
and disastrous epoch. Timid, irresolute, indolent, he had fallen completely
under the influence of his wife María Luisa, an energetic and self-willed
woman. Until 1792 he kept in office Floridablanca, who was succeeded for
a short time by Aranda, and then power was grasped by Manuel Godoy,
subsequently known as Prince of Peace. Cadet of an obscure family of
Badajoz, he had entered the royal body-guard, where he attracted the
attention of the queen, whose favored lover he was universally believed to
be, as well as the favorite of her husband. He speedily rose to the highest
dignities and became omnipotent; although a court intrigue occasioned his
dismissal in 1798, he was restored in 1800, remaining arbiter of the
destinies of Spain, until the “Tumult of Lackeys,” at Aranjuez, in 1808,
directed against him, caused the abdication of Carlos in favor of his son
Fernando VII. Light-headed, selfish, vain and unscrupulous, he was mainly
responsible for the misfortunes which overwhelmed his country and from
which it may be said not to have as yet recovered.
The outbreak of the French Revolution gave a new
importance to the Inquisition. When the seductive theories ALTERED
FUNCTIONS
of the French philosophers were preached as the
foundation of practical politics, overturning thrones and threatening
monarchical institutions with the doctrines of the social compact, the
sovereignty of the people and the universal brotherhood of man, the Holy
Office might claim that, as the foundations of social order were based on
religion, its labors were essential for the safety of the State, while the State
recognized that it was the most available instrumentality for the suppression
and exclusion of the heresies of liberty and equality.
In this tumultuous breaking down of the standards of thought and belief,
in this emergence of a new order on the ruins of the old, the functions of the
Inquisition adapted themselves to the exigencies of the times, in other ways
besides the increased sharpness and vigilance of its censorship. I have
frequently had occasion above to refer to an alphabetical list of all the
persons denounced to the various tribunals, from 1780 to 1820, some five
thousand in all, and this, taken as a whole, affords us an insight into the
change in the objects of inquisitorial activity. Judaism and Islam and
Protestantism no more claim its attention. The Church is no longer
threatened by enemies from without; what it has to dread is revolt among its
own children. Three-fifths of the denunciations are for “propositions,”
largely among the cultured classes, including a fair proportion of
ecclesiastics. Their precise errors are not stated, but doubtless many were
Jansenistic and more were hostile to the claims of the Church Militant and
to the absolutism of the monarchy. There is also a large class of cases,
virtually unknown a century earlier, significant of a vital change in the
intellectual tendencies of the nation, calling for the special vigilance of the
Inquisition. Popular indifferentism is revealed in the numerous prosecutions
for inobservance or contempt of church observances. Even more
noteworthy are those for outrages on images of Christ, the Virgin and the
saints, and even for sacrilegious treatment of the Venerable Sacrament. In
many other ways was manifested the weakening of the profound and
unquestioning veneration which, for three centuries, had been the peculiar
boast of the Spanish race. On the other hand it is not a little remarkable that
there are very few cases of offences against the Inquisition, for, in all these
forty years, there are but nine that can in any way be included in this class.
[862]
At the same time, when we recall the old-time punctilious enforcement
of profound respect, it argues no little decline in popular awe when, in
1791, a simple parish priest, Dr. Joseph Gines of Polop (Alicante) dared to
address the Valencia tribunal in terms of violent indignation at the conduct
of its secretary, Dr. Pasqual Pérez, when on a mission to collect testimony.
He tells the tribunal that, if it does not dismiss Pérez it will sink greatly in
his estimation, and his whole epistle breathes a spirit of independence and
equality wholly impossible at an earlier time.[863] It was not without reason
that, in 1793, the tribunal, in appealing for increase of salaries, complained
of the decline in popular respect for its officials, which it attributed to their
meagre pay and the curtailment of their privileges.[864] How completely the
tribunals had lost their former energy is indicated by the abandonment,
about this time, as we have seen (Vol. II, p. 98) of the publication of the
Edict of Faith, which of old had been so impressively solemnized and had
proved at once so fruitful a source of denunciations and so powerful a
means of maintaining popular awe.
Coincident with this, and as though the Inquisition felt
that it was on trial before the people, there was a marked POLITICAL
FUNCTIONS
tendency towards amelioration of procedure, coupled with
benignity in treatment of culprits. Allusion has been made above to the
introduction of the audiencia de cargos, through which the accused was
afforded an opportunity of knowing what was alleged against him, and
frequently of clearing himself without the disgrace of arrest and trial. There
is a very suggestive instance of merciful consideration, in 1791, in the case
of Josef Casals, a weaver, charged before the Barcelona tribunal with the
utterance of shocking blasphemies in the church of Santa Catalina. A
century earlier he would have been arrested and, on proof of the offence, he
would have been sentenced to scourging or the galleys. In place of this
Padre Miguel Alberch was instructed to report secretly as to the character of
the accused, which he did to the effect that Casals had regular certificates of
confession, but was of quick temper and occasionally broke out in curses.
Then a commission was issued to Alberch to summon Casals and to
represent to him the gravity of his offence and of the punishment incurred,
and the mercy shown by the tribunal, which would keep a watch on him.
In pursuance of this the good priest reported that Casals was deeply
repentant and desired to be heard in confession, which he had permitted.
[865] The case is trivial, but of such was the bulk of inquisitorial business,
and the temper in which it was conducted was of no little import to the
people at large.
Partly this may be attributable to the modern softening of manners,
partly to a growing sense of insecurity, and partly to the inertia which led
the officials to shun all avoidable labor. It was becoming more and more a
political machine and neglectful of the objects of its creation. During the
inquisitor-generalship of Manuel Abad y la Sierra, from 1792 to 1794, we
are told that, in all Spain, there were but sixteen condemnations to public
penance. Abad was an enlightened man; he thought of assimilating the
inquisitorial procedure to that of other courts of justice, and consulted with
Llorente as to the formula for such a reform, but conservatism, however
relaxed in practice, was not ready for total abandonment of the old methods.
His design became known: he was forced to resign and was relegated to the
Benedictine monastery of Sopetran, under a charge, as we have seen of
Jansenism.[866]
In fact, an absolute renunciation of the old procedure would have largely
deprived the Inquisition of its usefulness in its new political functions, to
which its established methods were peculiarly adapted. When, in 1796, a
powerful intrigue was formed for the overthrow of Godoy, the Inquisition
was naturally selected as the only weapon with which to strike at the
favorite. Three friars were found to denounce him, because for eight years
he had avoided confession and communion, and because of his scandalous
relations with women. Had Inquisitor-general Lorenzana been resolute,
Godoy’s fate might have been that of Olavide, but he was timid. Archbishop
Despuig of Seville and Bishop Muzquiz, then of Avila, who were the
leaders of the plot, vainly assured him that Godoy’s arrest would insure
success; he refused to act except under orders from Pius VI. Despuig then
prevailed upon his friend Cardinal Vincenti to induce the pope to write to
Lorenzana reproaching him with his indifference to a scandal so hurtful to
religion. It chanced that Vincenti’s letter, inclosing that of Pius, was
intercepted at Genoa by Napoleon who, to ingratiate himself with Godoy,
forwarded to him the correspondence. Godoy assured his position and took
a mild revenge, which does credit to his sense of humor, by sending
Lorenzana, Despuig and Muzquiz into honorable exile as special envoys to
condole with the pope on the occupation of his territories by the French.
[867] In fact, Capmany describes the Inquisition of the period as devoted to
the unholy work of an Inquisition of State, in order to preserve its
imperilled existence, and its ministers as trembling at the sight of the
infamous favorite, when they had the honor of joining the crowd of his
flatterers.[868]
Inquisitors might reasonably feel anxious as to their position, for projects
of reform were in the air. Gaspar Melchor de Jovellanos, the most
conspicuous Spaniard of his time for intellectual ability and rectitude, had
been exiled from the court, in 1790, and had betaken himself to his native
Gijon, where for years he labored in founding the Instituto Asturiense.
Desiring to endow it with a library of scientific works, he applied, in 1795,
to Lorenzana for licence to import them, but Lorenzana refused on the
ground that there were good Spanish writers, rendering recourse to
foreigners unnecessary, especially as foreign books had corrupted the
professors and students in various universities—a process of reasoning
applied to works on physics and mineralogy, which Jovellanos
characterized as a monumento de barbarie. The attention thus drawn to his
library aroused the suspicions of the commissioner of the Inquisition,
Francisco López Gil, priest of Somió, who secretly entered it one day while
the owner was taking his siesta. Word was brought to him and he hastened
thither, finding Gil examining a volume of Locke. Jovellanos turned him
out, telling him that his office rendered him an object of suspicion and
forbidding him to enter the building without permission. Gil became a spy
and was probably the author of a denunciation which cost Jovellanos years
of captivity.[869]
He was suddenly recalled from his exile, November 23,
1797, to assume the position of minister of Gracia y JOVELLANOS
Justicia, where he speedily gave the Inquisition abundant
cause to dread him. A competencia had arisen between the Seville tribunal
and the episcopal authorities over a confessional which it had ordered to be
closed. The matter came before Carlos, who instructed Jovellanos to obtain
the opinion of Tavira, Bishop of Osma, which he duly transmitted to the
king, February 15, 1798, with a Representation arguing that the time had
come to restore to the bishops their old jurisdiction in matters of faith; the
object for which the Inquisition was established had been attained; its
processes were cumbrous and inefficient, and its members were ignorant.
The jurisdiction of the bishops could alone furnish an effective remedy for
existing evils—a jurisdiction more natural, more authoritative, more
grateful to the people, and fuller of humanity and gentleness, as emanating
from the power granted to them by the Holy Ghost, wherefore the authority
that had been usurped from them should be restored. Moreover he took into
consideration the condition of the Holy See, deprived of its temporalities by
the French Republic. Everything, he said, pointed to a fearful schism at the
death of Pius VI, in which case each nation must gather itself under its own
pastors. The papacy would endeavor to retain the cumbrous and costly
organization of the curia, by increasing its exactions, and it would have to
be reduced to the functions exercised during the first eight centuries.[870]
Jovellanos was a sincere Catholic, but after utterances so hardy it was
not difficult for his enemies to convince the king that he was inclined to
heresy and atheism. Godoy had grown alarmed at the ascendancy which he
was acquiring over Carlos; his fellow-minister Caballero conspired with the
Inquisition, and on August 15th the king signed the dismissal of his
minister, whose official life had endured but eight months. A fortnight later
a royal carta orden declared it to be his unalterable will that the Holy Office
should permanently enjoy its jurisdiction and prerogatives without
modification.[871] Jovellanos returned to Gijon where he lived in dignified
retirement for two years and a half. His offence however had been too great
for pardon and his influence was still dreaded. An anonymous denunciation
of the flimsiest character was laid before Carlos, describing him as having
abandoned all religion and as being at the head of a highly dangerous party,
engaged in schemes for the overthrow of Catholicism and the monarchy.
The pusillanimous king adopted the course suggested to him by the secret
accuser. Before day-break of March 13, 1801, the house of Jovellanos was
surrounded by a troop of horse; he was aroused from sleep, his papers were
seized and transmitted to the ministry of State; he was kept in his house
incomunicado for twenty-four hours, then thrust into a coach and carried,
still incomunicado, across Spain to Barcelona and thence to Majorca, where
he lay in prison until the abdication of Carlos, in 1808, and the consequent
troubles effected his release.[872]
A case nearly parallel was that of Mariano Luis de
Urquijo, who followed Jovellanos in the ministry of Gracia ATTEMPTED
SUPPRESSION
y Justicia. He had no cause to love the Inquisition. Among
his youthful indiscretions was a translation of Voltaire’s Mort de César,
which led the Inquisition to make secret investigations, resulting in the
conviction that he was dangerously infected with philosophism. He was
about to be arrested when Aranda, who recognized his merit, recommended
him to the king and, in 1792, he was appointed to a position in Aranda’s
office. The Inquisition had learned respect for royal officials and substituted
for a decree of arrest a summons to an audiencia de cargos, ending in a
sentence of light suspicion of sharing philosophic errors, absolution ad
cautelam, some secret penances and the suppression of his book, though his
name was considerately omitted in the edict of prohibition. His official
promotion was rapid and, at the age of thirty, he found himself a minister,
employing his power, possibly with more zeal than discretion, in
encouraging enlightenment and all humanizing influences. On the death of
Pius VI he incurred Ultramontane hostility by inducing the king to sign the
decree of September 5, 1799, restoring to the bishops the right of issuing
dispensations—a measure which provoked long and bitter discussion. This
was followed, as we have seen above (Vol. III, p. 504) October 11th by a
sharp rebuke to the Inquisition, ordering it to confine itself to its proper
duties and, soon afterwards, he presented to Carlos for signature, a decree
suppressing the institution and applying its property to purposes of charity
and public utility. This was too bold a measure; the king shrank from the
responsibility and Urquijo only succeeded in concentrating upon himself
clerical hostility, which was reinforced by the enmity of First Consul
Bonaparte, whose policy he had opposed. Godoy, who commenced to fear
him as a rival, and who was irritated by some imprudent jests, withdrew his
support. A triple prosecution was commenced against him by three
inquisitors and he fell in December, 1801. He was sent to Pampeluna, to the
cell which had been occupied by Floridablanca, and there he lay for a year
or two, deprived of fire, lights, books and writing materials. He was
liberated under surveillance; in 1808 he refused to accompany Carlos and
Fernando to Bayonne, but he attended the so-called Junta of Notables there,
accepted the French domination, served as secretary of State and, with the
other Afrancesados, sought refuge in France in 1813, dying in Paris in
1817.[873]
It is evident from all this that the opposition to the Inquisition was
gathering strength and boldness, but that its foundations were too deep and
solid to be overthrown without an upheaval that should shatter the social
fabric. A well-intentioned, but somewhat absurd, attempt was made by
Grégoire, Constitutional Bishop of Blois, whose fervent Catholicism,
combined with equally fervent liberalism, was of service so essential in
piloting the Church of France through the storms of the Revolution. In
1798, he addressed a letter to the Spanish inquisitor-general, urging the
suppression of the Inquisition and universal toleration, as a preliminary to
the redemption of Spain from despotism, and to enabling it to take its place
among the nations which had recovered their rights. This was translated into
Spanish and some thousands of copies were circulated; it may have made
some secret converts but the only visible result was to elicit several replies.
One of these, by Pedro Luis Blanco, told Grégoire, with more or less
courtesy, to mind his own business; assured him that, if the Inquisition was
suppressed, Spain would remain as intolerant as ever, and asserted that no
Spaniard had ever imagined that coercion could be employed to obtain
conversion. It was probably this, mingled with some skilful adulation of the
king and his ministers, that procured for the author, in 1800, the episcopate
of Leon.[874] There was also an anonymous “Discurso historico-legal,”
evidently by a well-informed inquisitor, probably Riesco of Llerena. It was
the most rational history of the Inquisition that had as yet appeared,
although it assures us that experience showed that penitents were most
grateful for the benevolence shown to them, and that it was a tribunal full of
gentleness, the centre of benignity, compassion and mercy, but also of
justice.[875]
A third was by Lorenzo Villanueva, a calificador of the Valencia tribunal,
whose defence of the reading of Scripture has been alluded to above. It was
published under the transparent pseudonym of Lorenzo Astengo, his
maternal name. In view of his subsequent career it is not without interest to
see his indignation at the advocacy of toleration and his dithyrambic
denunciation of the horrors to which philosophism has led in the assertion
of human liberty. The first portion of his work is an impassioned and
rhetorical defence of persecution, supported by ample learning. Vigorous is
his denunciation of the modern theories of philosophism and the rights of
man—since original sin, he asks, what rights has man save to slavery, to
punishment, to ruin? So he combats at length the doctrine of the sovereignty
of the people, which he stigmatizes as a delirium, a dream and a deception.
Yet he admits that the Inquisition is not perfect—that it has committed
errors through imprudence, through ignorance, through excessive zeal, and
through human frailty, and that it has prevented the development of some
things which would aid the prosperity of the nation.[876] If, as has been
asserted, he expected a bishopric in reward for this, he was disappointed.
Thus, at this period the Inquisition was inert and its
very existence seemed to be threatened, but its potentiality POLITICAL
UPHEAVAL
of evil was undiminished. It was still an object of terror to
all inclined to liberal opinions, and it was regarded by the Conservatives as
the bulwark protecting the land from the deluge of modern thought.
Feeble though it might be in appearance we shall see how prolonged and
stubborn was the contest required for its final suppression.

The Cortes.
The treaty of Fontainebleau, October 27, 1807, dismembered Portugal,
of which Godoy was to have the southern portion, as an independent
kingdom, and the King of Etruria (Ferdinand of Parma) the northern
portion. Napoleon sent Junot with an army which, accompanied by Spanish
troops, speedily overran the land, when Junot issued a decree declaring
Portugal annexed to the empire. Simultaneously French armies, under
Dupont and Moncey, entered Spain and occupied the strongholds of
Pampeluna, Barcelona, Figueras and other places. Murat was sent as
commander in chief and took possession of Madrid. The Tumult of
Aranjuez drove Godoy from power and, on March 19, 1808, Carlos
abdicated in favor of his son, Fernando VII, whose accession was received
with enthusiasm by the nation. Beauharnais, the French ambassador at
Madrid, and Murat, however, refused to recognize him; Carlos protested to
Napoleon that his abdication had been coerced; by various devices, Carlos
and his queen, Fernando and his younger brother Don Carlos, were induced
to go to Bayonne to lay their respective pretensions before the emperor.
There, on May 5, Fernando was obliged to renounce the crown to his father
and the latter to transfer it to Napoleon. Carlos and María Luisa were sent to
Compiègne and Fernando to Valençay, where he remained until 1814.
Meanwhile in Madrid, Murat, under instructions, ordered the Infantes
Antonio and Francisco, the remaining members of the royal family, to
depart for Bayonne on May 2d. The indignant populace rose, with the aid of
a few officers and soldiers and, after a gallant struggle against the veterans
of Napoleon, the insurrection was repressed with heavy slaughter, followed
by numerous executions. The heroic “Dos de Mayo” was the signal of
resistance to the invader and, in a few weeks, Spain was aflame; the
desperate six years’ War of Liberation was commenced, and the nation
showed what a people could do when abandoned by its incapable and
cowardly rulers. With a soldier’s contempt for an unorganized militia,
Napoleon pursued his plans. Joseph was called from Naples to occupy the
vacant throne and was acknowledged as king by an Assembly of Notables,
convoked at Bayonne in June, which transformed itself into Córtes and
adopted a Constitution.
This summary of the situation is necessary to an understanding of the
position of the Inquisition. Whatever may have been the views of some of
the local tribunals, the central body accepted the intrusive domination and
was afrancesado—a term which, to the patriots, became one of the bitterest
contempt. The Constitution of Bayonne provided that, in Spanish territories,
no religion save Roman Catholicism should be tolerated. Raimundo
Ethenard, Dean of the Suprema, was a member of the Córtes and, when he
took the oath of allegiance to Joseph, the latter assured him that Spain was
fortunate in that the true faith alone was there honored. When the
Constitution was under consideration, two members, Pablo Arribas and José
Gómez Hermosilla, advocated the suppression of the Inquisition, but
Ethenard and his colleagues of the Inquisition, Galarza, Hevia Noriega and
Amarillas, successfully opposed it, although they admitted that, in
conformity with public opinion, its procedure should be made to conform to
that of the spiritual courts in criminal cases.[877]
The Inquisition thus deemed itself safe and earnestly
supported the Napoleonic government. After the SUPPRESSION
sanguinary suppression of the Madrid rising on May 2d, it BY NAPOLEON
made haste to counteract the impression produced and, on the 6th, the
Suprema addressed a circular letter to the tribunals, describing the affair as
a scandalous attack by the lowest mob on the troops of a friendly nation,
who had given no offence and had observed the strictest order and
discipline. Such demonstrations, it said, could only result in turbulence and
in destroying the confidence due to the government, which was the only one
that could advantageously direct patriotic energies. The tribunals were
therefore instructed to impress on their subordinates, and the commissioners
and familiars in their districts, the urgent necessity of unanimously
contributing to the preservation of public tranquillity. This communication
was received by the Valencia tribunal on May 9th and, on the 11th, it was
read to the assembled officials, calificadores, notaries and familiars of the
city, with exhortations to comply strictly with its commands—action which
was doubtless taken by the other tribunals.[878]
The Inquisition thus remained in Madrid under the protection of the
French arms, but its freedom of action was curtailed. The Abate Marchena,
a fine classical scholar, but revolutionary and tinctured with atheism, had
abandoned Spain early in the French Revolution and had barely escaped the
guillotine during the Terror. He returned, in 1808, as Murat’s secretary,
when the Inquisition thought fit to arrest him, but Murat sent a file of
grenadiers and forcibly released him.[879] When Napoleon reached Madrid,
December 4, 1808, the capitulation granted to the city provided that no
religion but Catholicism should be tolerated but, on the same day, he issued
a decree which suppressed the Inquisition, as contrary to sovereignty and to
civil authority, and confiscated its property to the crown.[880] The Inquisitor
Francisco Riesco stated, during the debate in the Córtes of Cádiz, that this
sudden decree was motived by the refusal of the members of the Suprema
to take the oath of allegiance to the new dynasty, but this is evidently
incorrect, as most of them had already done so at Bayonne, and Arce y
Reynoso, who resigned his inquisitor-generalship, adhered to the French
and accompanied them on the final evacuation. Riesco further asserts that
Napoleon ordered them to be imprisoned, but they escaped and scattered to
places of safety.[881] The Inquisition was thus left in an anomalous position
and without a head, for correspondence with Pius VII was cut off, and
neither his acceptance of Arce’s resignation nor his delegation of powers to
a successor could be had. The Junta Central, which was striving to govern
the country, attempted to fill the vacancy with Pedro de Quevedo y
Quintano, Bishop of Orense, but he could obtain no papal authorization and
made no attempt to act. It was argued that during a vacancy the jurisdiction
continued with the Suprema, but this was denied and it remained an open
question.[882]
During the period which followed, the tribunals maintained their
organization and exercised their functions after a fashion, when not
prevented by the French occupation. Thus when the invaders reached
Seville, February 1, 1810, the Inquisition was suppressed, but its members
took refuge in Ceuta. Valencia remained in operation until the city was
captured by Suchet, in 1811, while Barcelona at one time transferred itself
to Tarragona. Activity was intermittent and, in the excitement of that
stirring time, there was little energy for the prosecution of heresy while,
even when the enemy had withdrawn, in many cases the buildings had been
ruined. The Valencia record shows that the total number of cases brought
before all the tribunals in 1808 was 67; in 1809, 22; in 1810, 17; in 1811,
25; in 1812, 1; in 1813, 6. Probably few of these cases were regularly heard,
if we may judge from that of Don Vicente Valdés, captain of volunteers
who, in 1810, was denounced to the Valencia tribunal for blasphemous
propositions. October 27th it was ordered that, in view of the
circumstances, a fitting occasion should be awaited for the audiencia de
cargos demanded by the fiscal—a postponement which proved to be
protracted for it was not until 1816 that he was tried.[883] Still, where the
Inquisition itself was concerned it could act swiftly and effectively. In 1809
the French took possession of Santiago. Felipe Sobrino Taboada, professor
of civil law in the university, was acting as police-magistrate and, by order
of the director-general of police, he issued a proclamation exhorting the
people to lay down their arms and praising the suppression of the
Inquisition. When the French retired, the university refused to readmit him
to his chair. He obtained a decision of the tribunal of Public Safety of
Coruña re-establishing him and then the Inquisition arrested him, without
the prescribed preliminary formalities, and kept him for five months in the
secret prison. Afterwards he was allowed to keep his house as a prison and,
when finally the bounds were enlarged to the province of Galicia, it was
with the condition that he would accept no public office.[884]

The Junta Central, which had endeavored to govern,


amid much opposition from the particularist tendencies of ASSEMBLING
OF THE
the provincial juntas, retired to Cádiz when the French CORTES
occupied Andalusia.
On January 1, 1810, it issued a convocation for the assembling of Córtes,
and on the 31st it dissolved, after appointing a Regency and imposing on it
the duty of convoking the Córtes by March 1st. The Regency delayed until,
forced by the pressure of public opinion, on June 18th it published a decree
ordering elections where they had not been held, and summoning the
deputies to meet in August in Isla de Leon, now San Fernando, near Cádiz.
Suffrage was virtually universal and, in the letters of convocation, the
nation was called upon to assemble in general Córtes “to establish and
improve the fundamental constitution of the monarchy,” while the
commissions of the delegates empowered them to decide all points
contained in the letters and all others, without exception or limitation.[885]
The Córtes accordingly assumed the title of Majesty, as embodying the will
of the people and occupying the throne of the absent sovereign. When they
were opened, September 24th, about a hundred deputies were present, two-
thirds of whom were elected by the provinces not occupied by the French
armies, and the rest selected in Cádiz from among natives of the
unrepresented districts, including the colonies, then more or less in open
revolt, while, as the vicissitudes of the war permitted, deputies came
straggling in from districts unrepresented at first. As a whole, the body
fairly reflected existing public opinion. The Liberals numbered forty-five,
and the majority consisted of ecclesiastics, men of the privileged classes
and government employees.[886] It was an unavoidably hazardous
experiment, this sudden wrenching of Spain from the old moorings and
launching it on the tempestuous waters of modern ideas, under the conduct
of men without training or experience in self-government. Grave mistakes
were inevitable and their constructive work was idealistic and doomed to
failure—a failure bound to result in blood and misery. At the moment,
however, there were no misgivings and the Córtes were regarded as the
salvation of the nation.[887]
The oath administered to the members bound them to maintain
Catholicism as the exclusive religion of Spain and to preserve for their
beloved monarch Fernando VII all his dominions. Their first act was to
adopt a series of five resolutions, offered by an ecclesiastic, Diego Muñoz
Torrero, rector of the University of Salamanca, of which one provided that
the Regency should be continued as the executive power, on taking an oath
recognizing the sovereignty of the nation as embodied in the Córtes and
promising obedience to their enactments. Rather than do this, the Regency
proposed to break up the Córtes, but the threatening aspect of the people
and the army caused a change of heart, and that same night they took the
oath, except the implacable conservative Quevedo Bishop of Orense, who
resigned both from the Regency and the Córtes. His resignations were
accepted but he was forced to take the oath required of all prelates and
officials before he was allowed to retire to his diocese. It was evident that
the Córtes and the Regency could not pull together; on October 28th, the
latter was dismissed, its membership was reduced from five to three and a
new Regency was installed with which the Córtes could work in harmony.
[888]
After settling relations with the other departments of the
State, the first attention of the Córtes was given to the THE
INQUISITION
freedom of the press. Two days after the opening session ASSAILED
the subject was introduced and referred to a committee; no
time was lost, a decree was reported October 8th, and on the 18th, in spite
of the reclamations of the opposition, it was passed by a vote of 68 to 32.
This was regarded as a preliminary attack on the Inquisition, which was
thus deprived by implication of the function of censorship. Some members
desired this to be explicitly stated, giving rise to a hot debate in which
Inquisitor Riesco, a member of the Córtes, pleaded in vain for some
honorable mention of the Holy Office. There was also indignation excited
by the provision subjecting prohibition by the bishops to revision by the
secular power, which was subversive of the imprescriptible rights of the
Church, whose judgements are final.[889] If this was really the first move in
a campaign against the Inquisition, it was not unskilful, for it set at liberty
the pens which had hitherto been restrained. At once there arose a crowd of
pamphleteers and journalists, not only in Cádiz but throughout Spain, who
attacked the institution unsparingly, raising a clamor which showed how
severe had been the repression. Sturdy defenders were not lacking and the
wordy war was vigorously waged. The two most prominent champions on
either side were Antonio Puigblanch, who, under the pseudonym of
Natanael Jomtob, issued a series of pamphlets, collected under the title of
“La Inquisicion sin Máscara” or “The Inquisition unmasked,” and Padre
Maestro Fray Francisco Alvarado, a Dominican of high repute for learning
and eloquence, whose letters under the name of El Filósofo Rancio or
Antiquated Philosopher, continued for two years to keep up the struggle
against all the innovations of the Liberals.[890]
Puigblanch was no exception to the general rule that those who attacked
the Inquisition were careful to profess the highest veneration for the faith
and in no way to advocate toleration. His work commences with an
eloquent description of religion as the foundation of all civil constitutions
and Catholicism as the noblest adornment of enlightenment and liberty, the
only question being whether the Inquisition is the fitting institution for its
protection. He is careful to maintain to the last his abhorrence of heresy and
his desire for its suppression, which he proposes to effect by reviving
episcopal jurisdiction under certain limitations.[891] With all this his
denunciation of the Inquisition was unsparing, and he had ample store of
atrocities with which to justify his attacks, although there was unfairness in
attributing to it, in the nineteenth century, the cruelties which had stained its
previous career.
Alvarado was a man of extensive learning, but of little claim to the title
of philosopher, whether antiquated or modern. Though his methods were
not such as to make converts, they were well adapted to stimulate those of
his own side, for he was an effective partizan writer, fluent, sarcastic, often
coarse, vulgar and vituperative, using assertion for argument and indifferent
as to truth. The chief value of his letters is the flood of light which they
shed on the conservative attitude of the time, which explains much in the
subsequent vicissitudes of Spain. Philosophers, he says, are wolves, robbers
and devils, monsters who cannot be regarded without horror, enlighteners
who are nothing but ignoramuses and cheats and emissaries sent by hell. To
seek to undermine popular confidence in the priesthood he holds to be a
crime greater than the crucifixion of Christ. The ferocity of his intolerance
shows how little Spanish churchmen had changed since the days of
Torquemada. As to the relations of religion and the State, he assumes that
the only function of the civil power is to punish him who offends the faith;
the Catholic religion is as intolerant as light is of darkness, or as truth is of
falsehood, and this intolerance distinguishes it from all religions invented
by man. Repeatedly and savagely he proclaims that burning is the proper
remedy for unbelief, and he tells his adversaries that, if they wish free
thought, they may go to England or to the United States, but in Spain what
they had to expect was the quemadero.[892] Such advocacy could only
render the Liberals more eager to accomplish their work.

While this controversy was contributing to the greater


enlightenment or obscuration of public opinion, the Córtes THE
CONSTITUTIO
were engaged in framing a Constitution. The committee N OF 1812
entrusted with this task had a majority of conservatives,
including several ecclesiastics, but these were quite willing to circumscribe
the royal power, while seeking to extend the privileges of the Church, and
all the members signed the project as presented.[893] It commenced by
asserting the sovereignty of the nation, which had the exclusive right to
establish its fundamental laws, and could never be the patrimony of any
person or family, and it affirmed that the religion of the nation was, and
always forever would be the Catholic, Apostolic, Roman, the only true one,
which the nation protects by wise and just laws, and prohibits the exercise
of any other.[894] This apparent concession to intolerance was denounced,
when too late, as a trap, for it placed in the hands of the representatives of
the nation the power of deciding what the wise and just laws should be for
the protection of religion. Be this as it may, the Córtes were resolved that
there should be no refusal to accept the new framework of government. In
secret session of March 16, 1812, it was decreed that whosoever should
refuse to swear to it should be declared an unworthy Spaniard and be driven
from Spain, and measures were taken to have it read in every parish church,
where the assembled people should swear to obey it and to be faithful to the
king. As the French armies were driven back, the Spanish commanders
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!

textbookfull.com

You might also like