0% found this document useful (0 votes)
4 views

Getting Started with SQL and Databases: Managing and Manipulating Data with SQL 1st Edition Mark Simon instant download

The document provides information about the book 'Getting Started with SQL and Databases: Managing and Manipulating Data with SQL' by Mark Simon, including its ISBN numbers and copyright details. It outlines the contents of the book, which covers fundamental SQL concepts and techniques for managing databases. Additionally, it includes links to other related eBooks available for download.

Uploaded by

moeuncodioti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Getting Started with SQL and Databases: Managing and Manipulating Data with SQL 1st Edition Mark Simon instant download

The document provides information about the book 'Getting Started with SQL and Databases: Managing and Manipulating Data with SQL' by Mark Simon, including its ISBN numbers and copyright details. It outlines the contents of the book, which covers fundamental SQL concepts and techniques for managing databases. Additionally, it includes links to other related eBooks available for download.

Uploaded by

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

Getting Started with SQL and Databases: Managing

and Manipulating Data with SQL 1st Edition Mark


Simon pdf download

https://ebookmeta.com/product/getting-started-with-sql-and-
databases-managing-and-manipulating-data-with-sql-1st-edition-
mark-simon/

Download more ebook from https://ebookmeta.com


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

SQL QuickStart Guide The Simplified Beginner s Guide to


Managing Analyzing and Manipulating Data With SQL
Walter Shields

https://ebookmeta.com/product/sql-quickstart-guide-the-
simplified-beginner-s-guide-to-managing-analyzing-and-
manipulating-data-with-sql-walter-shields/

Python Data Persistence With SQL and NOSQL Databases


1st Edition Lathkar

https://ebookmeta.com/product/python-data-persistence-with-sql-
and-nosql-databases-1st-edition-lathkar/

Leveling Up with SQL: Advanced Techniques for


Transforming Data into Insights 1st Edition Mark Simon

https://ebookmeta.com/product/leveling-up-with-sql-advanced-
techniques-for-transforming-data-into-insights-1st-edition-mark-
simon/

Asian Development Bank Sustainability Report 2018


Investing for an Asia and the Pacific Free of Poverty
1st Edition Asian Development Bank

https://ebookmeta.com/product/asian-development-bank-
sustainability-report-2018-investing-for-an-asia-and-the-pacific-
free-of-poverty-1st-edition-asian-development-bank/
Friends with Benefits Goals Friends To Lovers Bad Boy
Sports Romance Romance Goals Book 4 1st Edition Barbi
Cox

https://ebookmeta.com/product/friends-with-benefits-goals-
friends-to-lovers-bad-boy-sports-romance-romance-goals-
book-4-1st-edition-barbi-cox/

Philosophical Trends in the Feminist Movement 2nd


Edition Anuradha Ghandy

https://ebookmeta.com/product/philosophical-trends-in-the-
feminist-movement-2nd-edition-anuradha-ghandy/

The Appraisal of Real Estate 15th Edition Appraisal


Institute

https://ebookmeta.com/product/the-appraisal-of-real-estate-15th-
edition-appraisal-institute/

THE WATCHER I spy with my little eye someone is going


to die 1st Edition Lisa Sell

https://ebookmeta.com/product/the-watcher-i-spy-with-my-little-
eye-someone-is-going-to-die-1st-edition-lisa-sell/

Handbook of Epigenetics : The New Molecular and Medical


Genetics 3rd Edition Trygve O. Tollefsbol

https://ebookmeta.com/product/handbook-of-epigenetics-the-new-
molecular-and-medical-genetics-3rd-edition-trygve-o-tollefsbol/
Management 12th Edition Ricky W. Griffin

https://ebookmeta.com/product/management-12th-edition-ricky-w-
griffin/
Getting Started
with SQL and
Databases
Managing and Manipulating Data
with SQL

Mark Simon
Getting Started with
SQL and Databases
Managing and Manipulating Data
with SQL

Mark Simon
Getting Started with SQL and Databases: Managing and Manipulating Data
with SQL

Mark Simon
Ivanhoe VIC, VIC, Australia

ISBN-13 (pbk): 978-1-4842-9492-5 ISBN-13 (electronic): 978-1-4842-9493-2


https://doi.org/10.1007/978-1-4842-9493-2
Copyright © 2023 by Mark Simon
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.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Smriti Srivastava
Development Editor: Laura Berendson
Editorial Assistant: Mark Powers
Cover image designed by eStudioCalamar
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza,
Suite 4600, New York, NY 10004-1562, USA. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@
springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole
member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc
is a Delaware corporation.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub. For more detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
To Sachiko. Thanks for your patience, forbearance, and trust.
Table of Contents
About the Author�����������������������������������������������������������������������������������������������������xv

About the Technical Reviewer�������������������������������������������������������������������������������xvii


Acknowledgments��������������������������������������������������������������������������������������������������xix

Introduction������������������������������������������������������������������������������������������������������������xxi

Chapter 1: Starting with SQL������������������������������������������������������������������������������������ 1


Basic SELECT Statement��������������������������������������������������������������������������������������������������������������� 2
Case Sensitivity����������������������������������������������������������������������������������������������������������������������� 3
Spacing������������������������������������������������������������������������������������������������������������������������������������ 3
Clause Ordering����������������������������������������������������������������������������������������������������������������������� 4
The Semicolon (;)��������������������������������������������������������������������������������������������������������������������� 4
Selecting Specific Columns���������������������������������������������������������������������������������������������������������� 5
Column Order�������������������������������������������������������������������������������������������������������������������������� 6
Layout�������������������������������������������������������������������������������������������������������������������������������������� 6
Using SELECT *������������������������������������������������������������������������������������������������������������������������ 7
Calculated Columns����������������������������������������������������������������������������������������������������������������� 7
Aliases������������������������������������������������������������������������������������������������������������������������������������� 8
Comments������������������������������������������������������������������������������������������������������������������������������������� 9
Block Comments������������������������������������������������������������������������������������������������������������������� 10
Uses of Comments���������������������������������������������������������������������������������������������������������������� 10
Filtering Rows����������������������������������������������������������������������������������������������������������������������������� 11
Clause Ordering��������������������������������������������������������������������������������������������������������������������� 12
Placing the Semicolon����������������������������������������������������������������������������������������������������������� 13
Ordering the Results������������������������������������������������������������������������������������������������������������������� 13
Clause Order�������������������������������������������������������������������������������������������������������������������������� 14
Distinct Rows������������������������������������������������������������������������������������������������������������������������������ 15

v
Table of Contents

Summary������������������������������������������������������������������������������������������������������������������������������������ 18
Writing SQL���������������������������������������������������������������������������������������������������������������������������� 19
Columns��������������������������������������������������������������������������������������������������������������������������������� 20
Comments����������������������������������������������������������������������������������������������������������������������������� 20
Filtering Data������������������������������������������������������������������������������������������������������������������������� 20
Row Order������������������������������������������������������������������������������������������������������������������������������ 21
Clause Order�������������������������������������������������������������������������������������������������������������������������� 21
Coming Up����������������������������������������������������������������������������������������������������������������������������������� 21

Chapter 2: Database����������������������������������������������������������������������������������������������� 23
About the Sample Database�������������������������������������������������������������������������������������������������������� 23
Database������������������������������������������������������������������������������������������������������������������������������� 24
Tables������������������������������������������������������������������������������������������������������������������������������������ 26
Normalized Tables����������������������������������������������������������������������������������������������������������������� 27
Multiple Values���������������������������������������������������������������������������������������������������������������������� 33
Summary������������������������������������������������������������������������������������������������������������������������������� 37
Coming Up����������������������������������������������������������������������������������������������������������������������������� 39

Chapter 3: Filtering Data���������������������������������������������������������������������������������������� 41


The WHERE Clause���������������������������������������������������������������������������������������������������������������������� 41
Unrelated Assertions������������������������������������������������������������������������������������������������������������� 44
All and Nothing���������������������������������������������������������������������������������������������������������������������� 44
Dealing with NULL����������������������������������������������������������������������������������������������������������������������� 45
Deliberately Ignoring NULLs�������������������������������������������������������������������������������������������������� 46
Finding NULLs������������������������������������������������������������������������������������������������������������������������ 47
Numbers������������������������������������������������������������������������������������������������������������������������������������� 49
Discrete vs. Continuous Values��������������������������������������������������������������������������������������������� 49
Strings����������������������������������������������������������������������������������������������������������������������������������������� 52
Quotes����������������������������������������������������������������������������������������������������������������������������������� 53
More on MySQL/MariaDB Modes������������������������������������������������������������������������������������������� 54
More on Double and Single Quotes��������������������������������������������������������������������������������������� 55
Case Sensitivity��������������������������������������������������������������������������������������������������������������������� 57
Trailing Spaces���������������������������������������������������������������������������������������������������������������������� 58

vi
Table of Contents

Filtering with String Functions���������������������������������������������������������������������������������������������� 59


Handling Quotes and Apostrophes���������������������������������������������������������������������������������������� 61
Before and After Strings�������������������������������������������������������������������������������������������������������� 62
Dates������������������������������������������������������������������������������������������������������������������������������������������� 63
Dates Are Not Strings������������������������������������������������������������������������������������������������������������ 64
Alternative Date Formats������������������������������������������������������������������������������������������������������� 65
Date Comparisons����������������������������������������������������������������������������������������������������������������� 66
Filtering with a Date Calculation������������������������������������������������������������������������������������������� 69
Multiple Assertions��������������������������������������������������������������������������������������������������������������������� 70
AND and OR��������������������������������������������������������������������������������������������������������������������������� 70
The IN Operator��������������������������������������������������������������������������������������������������������������������� 76
Derived Lists�������������������������������������������������������������������������������������������������������������������������� 78
Wildcard Matches����������������������������������������������������������������������������������������������������������������������� 81
Case Sensitivity and Patterns������������������������������������������������������������������������������������������������ 83
Pattern Characters���������������������������������������������������������������������������������������������������������������� 84
Wildcards with Non-strings��������������������������������������������������������������������������������������������������� 87
Extensions to Wildcards�������������������������������������������������������������������������������������������������������� 89
A Simple Pattern Match Example������������������������������������������������������������������������������������������ 91
Summary������������������������������������������������������������������������������������������������������������������������������������ 92
NULL�������������������������������������������������������������������������������������������������������������������������������������� 93
Numbers�������������������������������������������������������������������������������������������������������������������������������� 93
Strings����������������������������������������������������������������������������������������������������������������������������������� 93
Dates������������������������������������������������������������������������������������������������������������������������������������� 94
Multiple Assertions���������������������������������������������������������������������������������������������������������������� 94
The IN Operator��������������������������������������������������������������������������������������������������������������������� 94
Wildcard Matches������������������������������������������������������������������������������������������������������������������ 94
Coming Up����������������������������������������������������������������������������������������������������������������������������������� 95

Chapter 4: Ordering Results����������������������������������������������������������������������������������� 97


Using the ORDER BY Clause�������������������������������������������������������������������������������������������������������� 97
Sort Direction������������������������������������������������������������������������������������������������������������������������� 99
Missing Data (NULL)������������������������������������������������������������������������������������������������������������������ 100

vii
Table of Contents

Data Types��������������������������������������������������������������������������������������������������������������������������������� 102


Case Sensitivity and Collation��������������������������������������������������������������������������������������������� 106
Multiple Columns���������������������������������������������������������������������������������������������������������������������� 107
Interdependence of Columns����������������������������������������������������������������������������������������������� 109
Sort Direction on Multiple Columns������������������������������������������������������������������������������������� 110
Sorting by Calculated Columns������������������������������������������������������������������������������������������������� 112
Limiting the Number of Results������������������������������������������������������������������������������������������������ 115
Paging��������������������������������������������������������������������������������������������������������������������������������� 116
Using LIMIT … OFFSET … (MySQL/MariaDB, SQLite, and PostgreSQL)������������������������������ 117
Using TOP (MSSQL)�������������������������������������������������������������������������������������������������������������� 117
Fetching a Random Row����������������������������������������������������������������������������������������������������������� 118
Nonalphabetical String Order���������������������������������������������������������������������������������������������������� 119
Special Strings�������������������������������������������������������������������������������������������������������������������������� 120
Summary���������������������������������������������������������������������������������������������������������������������������������� 121
Sorting with ORDER BY�������������������������������������������������������������������������������������������������������� 121
Limiting Results������������������������������������������������������������������������������������������������������������������� 122
Sorting Strings��������������������������������������������������������������������������������������������������������������������� 122
Coming Up��������������������������������������������������������������������������������������������������������������������������������� 122

Chapter 5: Calculating Column Values������������������������������������������������������������������ 123


Testing Calculations������������������������������������������������������������������������������������������������������������������ 125
Emulating Variables������������������������������������������������������������������������������������������������������������������ 126
Some Basic Calculations����������������������������������������������������������������������������������������������������������� 127
Basic Number Calculations������������������������������������������������������������������������������������������������� 127
Basic String Calculations����������������������������������������������������������������������������������������������������� 128
Basic Date Calculations������������������������������������������������������������������������������������������������������� 129
Working with NULL�������������������������������������������������������������������������������������������������������������������� 129
Using Aliases����������������������������������������������������������������������������������������������������������������������������� 135
Aliases Without AS��������������������������������������������������������������������������������������������������������������� 136
Awkward Aliases����������������������������������������������������������������������������������������������������������������� 138
Calculating with Numbers��������������������������������������������������������������������������������������������������������� 140

viii
Table of Contents

Arithmetic Operators����������������������������������������������������������������������������������������������������������� 140


Integers������������������������������������������������������������������������������������������������������������������������������� 141
Remainder��������������������������������������������������������������������������������������������������������������������������� 143
Extra Decimals��������������������������������������������������������������������������������������������������������������������� 144
Mathematical Functions������������������������������������������������������������������������������������������������������ 145
Approximation Functions����������������������������������������������������������������������������������������������������� 146
Formatting Functions���������������������������������������������������������������������������������������������������������� 147
Calculating with Dates�������������������������������������������������������������������������������������������������������������� 149
Simple Calculations������������������������������������������������������������������������������������������������������������� 149
Age Calculations������������������������������������������������������������������������������������������������������������������ 151
Extracting Parts of a Date���������������������������������������������������������������������������������������������������� 153
Formatting a Date���������������������������������������������������������������������������������������������������������������� 155
Strings��������������������������������������������������������������������������������������������������������������������������������������� 160
Character Functions������������������������������������������������������������������������������������������������������������ 161
Subqueries�������������������������������������������������������������������������������������������������������������������������������� 165
The CASE Expression���������������������������������������������������������������������������������������������������������������� 169
Casting to Different Data Types������������������������������������������������������������������������������������������������� 173
The cast( ) Function������������������������������������������������������������������������������������������������������������� 174
Casting to a String��������������������������������������������������������������������������������������������������������������� 175
Casting Date Literals����������������������������������������������������������������������������������������������������������� 177
Creating a View������������������������������������������������������������������������������������������������������������������������� 177
Using Views in Microsoft SQL���������������������������������������������������������������������������������������������� 180
Summary���������������������������������������������������������������������������������������������������������������������������������� 181
Data Types��������������������������������������������������������������������������������������������������������������������������� 181
NULLs���������������������������������������������������������������������������������������������������������������������������������� 181
Aliases��������������������������������������������������������������������������������������������������������������������������������� 182
Subqueries�������������������������������������������������������������������������������������������������������������������������� 182
The CASE Expression����������������������������������������������������������������������������������������������������������� 182
Casting a Value�������������������������������������������������������������������������������������������������������������������� 182
Views����������������������������������������������������������������������������������������������������������������������������������� 183
Coming Up��������������������������������������������������������������������������������������������������������������������������������� 183

ix
Table of Contents

Chapter 6: Joining Tables������������������������������������������������������������������������������������� 185


How a Join Works��������������������������������������������������������������������������������������������������������������������� 186
Joining the Tables���������������������������������������������������������������������������������������������������������������� 189
Alternative Syntax��������������������������������������������������������������������������������������������������������������� 189
Selecting the Results����������������������������������������������������������������������������������������������������������� 191
Table Aliases������������������������������������������������������������������������������������������������������������������������ 193
Developing a Price List������������������������������������������������������������������������������������������������������������� 194
Join Types��������������������������������������������������������������������������������������������������������������������������������� 195
The INNER JOIN������������������������������������������������������������������������������������������������������������������� 197
The LEFT OUTER JOIN and RIGHT OUTER JOIN�������������������������������������������������������������������� 197
The “Preferred” Outer Join�������������������������������������������������������������������������������������������������� 199
Some Recommendations on JOINS������������������������������������������������������������������������������������� 200
Finishing the Price List�������������������������������������������������������������������������������������������������������������� 201
Joining Many Tables������������������������������������������������������������������������������������������������������������������ 202
Building a Larger JOIN��������������������������������������������������������������������������������������������������������� 204
Revisiting Some Subqueries������������������������������������������������������������������������������������������������ 209
A More Complex Join���������������������������������������������������������������������������������������������������������������� 211
Using a Self-Join����������������������������������������������������������������������������������������������������������������������� 216
Summary���������������������������������������������������������������������������������������������������������������������������������� 220
Syntax���������������������������������������������������������������������������������������������������������������������������������� 220
Table Aliases������������������������������������������������������������������������������������������������������������������������ 220
The ON Clause��������������������������������������������������������������������������������������������������������������������� 220
Join Types���������������������������������������������������������������������������������������������������������������������������� 221
Coming Up��������������������������������������������������������������������������������������������������������������������������� 221

Chapter 7: Aggregating Data�������������������������������������������������������������������������������� 223


Counting Data��������������������������������������������������������������������������������������������������������������������������� 224
Counting Values������������������������������������������������������������������������������������������������������������������� 224
How Aggregates Work��������������������������������������������������������������������������������������������������������������� 225
Counting Selectively����������������������������������������������������������������������������������������������������������������� 226
Distinct Values�������������������������������������������������������������������������������������������������������������������������� 232

x
Table of Contents

Summarizing Numbers������������������������������������������������������������������������������������������������������������� 233


Bad Examples���������������������������������������������������������������������������������������������������������������������� 235
Scales of Measurement������������������������������������������������������������������������������������������������������� 236
Aggregating Calculated Data���������������������������������������������������������������������������������������������������� 237
Other Aggregate Functions������������������������������������������������������������������������������������������������������� 239
Using Aggregates As Filters������������������������������������������������������������������������������������������������������ 240
Grouping����������������������������������������������������������������������������������������������������������������������������������� 243
Using the GROUP BY Clause������������������������������������������������������������������������������������������������ 245
GROUP BY vs. DISTINCT������������������������������������������������������������������������������������������������������� 250
Grouping with Multiple Tables��������������������������������������������������������������������������������������������������� 251
Redundant Groups�������������������������������������������������������������������������������������������������������������������� 254
Preparing Data for Aggregating������������������������������������������������������������������������������������������������ 256
Using CASE in a CTE������������������������������������������������������������������������������������������������������������ 259
Using a Join in the CTE�������������������������������������������������������������������������������������������������������� 260
Summarizing Strings����������������������������������������������������������������������������������������������������������� 262
Filtering Grouped Results with HAVING������������������������������������������������������������������������������������� 264
Using Results in a CTE��������������������������������������������������������������������������������������������������������� 268
Finding Duplicates��������������������������������������������������������������������������������������������������������������� 269
Using Aggregates on Aggregates���������������������������������������������������������������������������������������� 272
Summary���������������������������������������������������������������������������������������������������������������������������������� 275
Coming Up��������������������������������������������������������������������������������������������������������������������������� 276

Chapter 8: Working with Tables���������������������������������������������������������������������������� 277


How Tables Are Created������������������������������������������������������������������������������������������������������������ 278
Creating a Table������������������������������������������������������������������������������������������������������������������� 279
Column Names�������������������������������������������������������������������������������������������������������������������� 280
Data Type����������������������������������������������������������������������������������������������������������������������������� 281
Primary Keys����������������������������������������������������������������������������������������������������������������������� 282
Constraints�������������������������������������������������������������������������������������������������������������������������������� 284
NOT NULL����������������������������������������������������������������������������������������������������������������������������� 285
UNIQUE�������������������������������������������������������������������������������������������������������������������������������� 286
DEFAULT������������������������������������������������������������������������������������������������������������������������������� 286

xi
Table of Contents

CHECK���������������������������������������������������������������������������������������������������������������������������������� 287
Foreign Keys������������������������������������������������������������������������������������������������������������������������ 287
Indexes�������������������������������������������������������������������������������������������������������������������������������� 289
Adding Rows to a Table������������������������������������������������������������������������������������������������������������� 290
Deleting Rows from a Table������������������������������������������������������������������������������������������������������ 292
Adding More Rows�������������������������������������������������������������������������������������������������������������������� 294
Updating Rows�������������������������������������������������������������������������������������������������������������������������� 295
Altering the Table���������������������������������������������������������������������������������������������������������������������� 297
DML in Real Life������������������������������������������������������������������������������������������������������������������������ 299
Security������������������������������������������������������������������������������������������������������������������������������� 299
Front-End Software������������������������������������������������������������������������������������������������������������� 300
Summary���������������������������������������������������������������������������������������������������������������������������������� 301
Data Types��������������������������������������������������������������������������������������������������������������������������� 301
Constraints�������������������������������������������������������������������������������������������������������������������������� 301
Foreign Keys������������������������������������������������������������������������������������������������������������������������ 302
Indexes�������������������������������������������������������������������������������������������������������������������������������� 302
Manipulating Data��������������������������������������������������������������������������������������������������������������� 302

Chapter 9: Set Operations������������������������������������������������������������������������������������� 303


Unions��������������������������������������������������������������������������������������������������������������������������������������� 303
Selective Unions������������������������������������������������������������������������������������������������������������������ 307
SELECT Clauses Must Be Compatible���������������������������������������������������������������������������������� 309
Only Column Names from the First SELECT Statement Are Used���������������������������������������� 311
Sorting Results�������������������������������������������������������������������������������������������������������������������� 312
Intersections����������������������������������������������������������������������������������������������������������������������������� 314
Differences�������������������������������������������������������������������������������������������������������������������������������� 317
Some Tricks with Set Operations���������������������������������������������������������������������������������������������� 321
Comparing Results�������������������������������������������������������������������������������������������������������������� 321
Virtual Tables����������������������������������������������������������������������������������������������������������������������� 323
Mixing Aggregates��������������������������������������������������������������������������������������������������������������� 326
Summary���������������������������������������������������������������������������������������������������������������������������������� 330

xii
Table of Contents

Appendix 1: Differences Between SQL Dialects���������������������������������������������������� 333

Appendix 2: A Crash Course in PDO���������������������������������������������������������������������� 341

Appendix 3: Additional Notes������������������������������������������������������������������������������� 357

Index��������������������������������������������������������������������������������������������������������������������� 369

xiii
About the Author
Mark Simon has been involved in training and education
since the beginning of his career. He started as a teacher
of mathematics but soon moved into IT consultancy and
training because computers are much easier to work
with than high school students. He has worked with and
trained in several programming and coding languages and
currently focuses mainly on web development and database
languages. When not involved in work, you will generally
find him listening to or playing music, reading, or just
wandering about.

xv
About the Technical Reviewer
Atul Tyagi is a database developer who has worked
extensively in the field of data analytics for over eight years.
He has worked with various industries, including general
insurance and banking domains, and has contributed
significantly to several projects involving reporting,
datamarts, automation, data model development, and
project migration.
Atul is skilled in SQL, SAS, Python, and ETL tools such as
Informatica, SAS DI, Datastage, and SAS Visual Analytics. His
expertise in these areas has helped numerous organizations
effectively manage and analyze their data, leading to
improved decision-making and business outcomes. Atul has worked with leading
companies such as Accenture Solutions, Wipro Pvt Ltd, Acxiom Technologies, and EXL
Services.
Apart from his professional work, Atul is also passionate about sharing his
knowledge, cloud platforms, and data analytics. In his free time, he enjoys reading,
traveling, and exploring new cuisines.

xvii
Another Random Scribd Document
with Unrelated Content
Two Months In Spain
During The Late Revolution.

Gibraltar.
October 7.

At an early hour yesterday we left Cadiz, which did indeed look like
a "silver cup floating on the water," as the Spaniards say of it. As
the steamer bore us away, the rising sun upon its white towers and
cathedral dome, the belvideres which adorn the roof of every
house, (making each look like a church,) the lovely green alameda,
the distant mountains, the pretty white towns on the shore, the
hundreds of vessels in the sparkling bay, all made an enchanting
scene, from which we were recalled to the miseries of sea-sickness!
From time to time, we crept upon deck to see the fine sea view,
and when we came to Tarifa, near the straits, the scene was
magnificent. On one side, the mountains of Africa, Tangier in the
distance; on the other, the mountains of Spain and the Moorish-
looking town of Tarifa, with an island on which is the lighthouse
and defences standing directly in the mouth of the straits; so that it
seemed as if a long line of vessels with their white sails spread
were encompassing the island. In sight, at one time, were eighty
sail. Every nation under the sun seemed represented, as they
saluted one another with their flags. Among the rest, Sweden and
Norway. We landed at Gibraltar under a glorious sunset. The
farewell beams lighted the mountains with a tint of gilded bronze.
Gibraltar, opposite these, was like a huge gray mountain, and
behind it the sky was of the palest rose color, melting into blue
where it touched the water. The town is on the side and at the foot
of the "Rock," (a place of sixteen or twenty thousand inhabitants,)
and above it are the famous galleries cut through the rock, from
which we could see the noses of the great guns peeping from the
port-holes, range after range, one above another, till the top is
reached, where is the Signal.

The Rock of Gibraltar is 1430 feet high, and about three miles long
—a great gray sphinx jutting into the water. It is joined to the
mainland by a narrow slip of sand, capable of being submerged if
necessary. Upon this neck of land is the "neutral ground," (a
narrow strip,) where, side by side, the fair British sentinel and the
sunburned Spaniard keep their "lonely round." We mount upon
donkeys to ascend the "Rock," passing through the wonderful
"galleries" which, at an immense expense, have been cut into the
solid rock, where, with the guns, are depositories for powder, balls,
etc. Some of these galleries are over a mile and a quarter long,
lighted by the port-holes, which, in passing, gave us glimpses of
the loveliest of landscapes. Leaving the galleries, we ascend by
zigzag paths to the Signal; at every turn feasting our eyes upon the
wonderful panorama spread out below us, which is seen in
perfection from the summit. Here we looked down upon two seas,
the Atlantic and the Mediterranean, and two worlds, Europe and
Africa! Spain on one side, with the snowy heights of the Alpujarras
and Sierra Nevada; at our feet, the town of Gibraltar, with the
lovely alameda, its green trees and bright gardens, the glorious bay
crowded with shipping—men-of-war, school ships, steamers, and
every small craft; and, seemingly, but a stone's throw across lay
Ceuta, at the foot of that other "Pillar of Hercules" which rises 2200
feet, and looks like a mountain of bronze, while Gibraltar is of gray
granite. These two great pillars were considered in the olden time
the end of the world—the Tarshish of the Bible; the Calpe of the
Phoenicians, who erected here Calpe (carved mountain) and Abyla.

Tarik, the one-eyed Berber chief, took Gibraltar in 711, and called it
after his own name, Ghebal Tarik, from whence comes Gibraltar.

While upon the "Signal," we signalize the event by taking a lunch of


delicious English cheese, bread and butter, (the first butter we have
had in Spain,) and such ale! And while thus agreeably engaged, we
hear that an American man-of-war is coming into port, which
proves to be the flagship of Admiral Farragut; so we repair to the
rampart to see the ship saluted by the town, and then by the
British frigate Bristol, to both of which the Yankee replied in gallant
style. It was a fine sight, and, altogether, the scene a most
remarkable one. Down by the neutral ground, some English officers
playing cricket looked like ants in the sunshine; the blue guard-
tents of the English sentinels, and the white ones of the Spaniards,
were little specks, and the Christian and Jewish cemeteries were
like checker work on the greensward.

How longingly we looked toward the purple mountains of Africa,


and that beautiful city of Tangier which we had hoped to visit! but
the quarantine, still in force, obliged us to abandon the idea. It
would have been something to set foot in another continent!
Ceuta, which belongs to Spain, and is but a prison-house, could not
tempt us. Tearing ourselves from this wonderful scene, we
descended by the other side of the mountain and entered the city
by beautiful gardens near the alameda, seeing below us the
government houses, store-houses, magazines, and many fine
residences embowered in gardens of tropical trees and plants;
whole hedges of geraniums and cactus lined the roadside, and
almond trees, dates, and oranges. We passed a convent-school
with beautiful and extensive gardens. In the evening there is music
on the alameda, where are trees and statues, and marble benches,
on which sit the motley population of this strange place; Moors in
turbans, bare-legged Highlanders, officers in scarlet, Andalusians in
the red faja, Irishmen fresh from their native isle, ladies in French
bonnets and English round hats next the Spanish mantilla and ever-
moving fan. Gibraltar is a free port, and every people and kindred
meet here for trade. The garrison is very large, about three
thousand men in time of peace; for the Spaniards see the
occupation of this important point in their country with great
jealousy, and would gladly seek occasion to win it back. And every
now and then the subject is mooted in the English parliament of
giving it up, as it is a most expensive appendage to the English
people, and can bring little benefit save to their pride.

Malaga Hotel Alameda.

October 8.

Leaving Gibraltar at an early hour, and passing the forest of ships in


the bay, we soon see the last of the pillars of Hercules and the
African coast. The sea is calm, and the coast of Spain along which
we come is most beautiful. There is something peculiarly interesting
in the mountains of Spain; they seem to rise hill upon hill till they
grow to be mountains, and instead of the blue of most southern
countries they are of a mulberry hue—seldom with trees, and
reminding one of the purple moors of Scotland. The steamer is
crowded with families returning from Gibraltar, whither they had
fled to get out of the way of the revolution.

We find a busy, crowded city, a lovely bay with mountains in the


background, an old Moorish castle overlooking the city, and a
beautiful alameda, with trees, and statues, and marble seats, upon
which we look from the windows of our delightful hotel.

October 9.

The first thing to-day is to drive to a lovely villa, (that of the


Marquis de Casa Loring,) in whose garden we see every fruit and
flower and tree of the tropics. Bananas and mangoes, the coffee-
tree, the magnolia and India-rubber trees, and among all these we
found, and ate, ripe persimmons!—that homely fruit of old Virginia,
found amidst all these oriental splendors; and sweeter were they
than even the oranges which we gathered from their overladen
trees. Returning, we paused to see another villa, from whence is a
more extensive and beautiful view of the mountains, the city and
the sea, and the fertile plateau upon which Malaga lies, and which
is said to rival even the famous huertas of Valencia and Murcia in
variety and luxuriance of vegetation. The cemetery gives another
favorite point of view, and the old Moorish castle (Gibralfaro) has
even a finer one; but the day is too warm to attempt the ascent.
The castle dates from 1279, and the lower portion, (the Alcazaba,)
which is connected with it, is supposed to be of Phoenician origin;
Malaga having been first a Phoenician colony, and afterwards
Roman. Of the remains of the Roman period, we saw two
interesting bronze slabs in a pavilion of the Villa Loring this
morning, one of them containing the municipal laws of Malaga
under Domitian, and the other those of a city (Salpense) now
unknown.

The interior of the cathedral, which rises upon the site of an


ancient mosque, is not at all remarkable. It was begun in 1528.
The church of "El Cristo del Victoria" is interesting, from the
circumstance of its being built on the spot where stood the tents of
the Catholic kings during the siege of 1487. On the right of the
altar hangs the royal standard of Ferdinand, and on the left the one
taken from the Moors. When the city surrendered, the former was
hoisted on the castle, or alcazaba. Opposite this church is a small
church, San Roque, the first Christian edifice built here by
Ferdinand and Isabella. The crucifix which was formerly here was
the one brought by their majesties, is highly revered, and is now
over the high altar of Santa Victoria.

Malaga is famed for its climate, the best in Spain. It is considered


drier, warmer, and more equable than that of Rome, Pau, Naples, or
Nice, even superior to Madeira. Invalids flock here, and it will soon
be as crowded as Nice. The extreme dryness of the air is its
marked feature, and it is said that there are not ten days in the
whole year when an invalid may not take out-door exercise. The
evaporation is so great, the rain has no influence on the air. During
nine years, it has rained only two hundred and sixty times. The
"oldest inhabitant" does not remember to have seen snow, and the
cold winds from the Sierra Nevada are kept off by the mountains
immediately surrounding the city. To show the longevity of the
inhabitants, in the year 1860, twenty-nine out of five thousand
deaths were of people who had lived to the ages of ninety or a
hundred.

Granada.

October 10

This morning we leave Malaga at an early hour by rail, the road


being cut through extraordinary mountain passes to Antiquera, an
old Roman and Moorish town; from thence by diligence to Loja,
where we again take the railway. The journey is altogether
delightful, the day being cool and bright, and the mountain scenery
on either side grand and beautiful. Loja is in a narrow valley,
through which runs the Genil river, on one side the Periquete Hills
(Sierra Ronda) and the Hacho. The Manzanil unites here with the
Genil, both rapid and clear mountain streams fertilizing a lovely
valley. Soon after leaving Loja, we reach Santa Fé, (Holy Faith,)
built by Queen Isabella to shelter her army in winter during the
siege of Granada in 1492, and called "Santa Fé" because she
looked upon the war as a struggle for the faith, and believed
piously in its happy issue. This little town has been the scene of
many important operations and political acts. It witnessed the
signing of the capitulation of Granada, and it was to this town that
Columbus was recalled by Isabella when he had already reached
the bridge of Piños, behind the mountains, determining to ask aid
elsewhere for his great undertaking.

Darkness now fell upon us, and except one exquisite view which
the setting sun gave of the snow mountains over Granada, we saw
nothing till we reached this last stronghold of the Moors in Spain,
and found lodgings inside the Alhambra grounds in the Hotel
Washington Irving.

October 11.

We go first to the Cathedral, to hear the high mass, and pay our
respects to the remains of Ferdinand and Isabella, which rest there.
Driving through beautiful ornamental grounds out of the Alhambra
gate, down a steep hill in the old Moorish looking city, we find the
cathedral, like that of Malaga, greatly ornamented, (in the Greco-
Roman style,) built in 1529. Within the sanctuary are eleven
pictures by Alonzo Caño, and two of his most celebrated pieces of
sculpture—the heads of Adam and Eve carved in cork. Caño was a
native of Granada, and is buried in the Cathedral Bocanegra.
Another of the celebrated artists of Spain was also a native here,
and the cathedral has several of his pictures. But everything
connected with the church sinks into insignificance when one enters
into the royal chapel, where all that can perish of the great
Ferdinand and Isabella lies (a small space for so much greatness,
as Charles V. said.) In a crypt, below the chapel, in plain leaden
coffins, with but the simple initial of each king and queen upon
them, are the coffins of Ferdinand and Isabella and their daughter
Joanna, with her husband Philip I. (the handsome)—the last—that
very coffin which the poor crazed Joanna carried about with her for
forty-seven years, embraced with such frantic grief, and would
never be parted from. Nothing was so affecting as the sight of this
—not even the remembrance of all Isabella's glories and goodness!
So does an instance of heart devotion touch one more than even
the sight of greatness. Above the vault are the four beautiful
alabaster monuments, made by order of Charles V. to the memory
of his father and mother and his grandparents. Ferdinand and
Isabella, with their statues, lie side by side; and poor Joanne la
Folle looks lovely and placid (all her jealousies over) beside the
husband she adored, as if at last sure that she could not be divided
from him. Isabella died at Medina del Campo, (near Segovia, about
thirty miles from Madrid,) but desired to be buried here in the
bright jewel which she had won as well for her crown as for her
God. Her body was taken to Granada in December, journeying over
trackless moors amidst storms and torrents, of which the faithful
and learned Peter Martyr gives account, who accompanied his
beloved mistress to her last home.

The inscription which runs around the cornice tells: "This chapel
was founded by their most Catholic Majesties, Don Fernando and
Doña Isabel, king and queen of las Españas of Naples, of Sicily—of
Jerusalem—who conquered this kingdom, and brought it back to
our faith; who acquired the Canary Islands and Indies, as well as
the cities of Oran, Tripoli, and Bugia; who crushed heresy, expelled
the Moors and Jews from their realms, and reformed religion. The
queen died Tuesday, November 26, 1504; the king died January 23,
1516. The building was completed in 1517."

The bassi relievi on the altar in this chapel are very interesting,
from the scenes they represent—Ferdinand and Isabella receiving
the keys of Granada from Boabdil, etc. At each end of the altar are
figures of the king and queen in the costume of the day, the
banner of Castile behind the king. In the sacristy is the crown of
Isabella, the sword of Ferdinand, the casket in which she gave the
jewels to Columbus, some vestments embroidered by her own
hand, and the tabernacle used on the altar where they heard mass,
on which is a picture of the adoration of the Magi, by that
wonderful old painter Hemling of Bruges. Lord Bacon has said of
Isabella: "In all her relations of queen or woman, she was an honor
to her sex, and the corner-stone of the greatness of Spain—one of
the most faultless characters in history—the purest sovereign by
whom the female sceptre was ever wielded."

We hear mass in the chapel of the Sagrario, a beautiful church in


itself. It was on one of its three doors that the Spanish knight
Hernan Perez del Pulgar (during the siege of Granada) nailed the
words, "Ave Maria;" to accomplish which feat, he entered the town
at dusk, and left it unharmed—nay, even amidst the plaudits of the
Arabs, who appreciated the deed. He is buried in one of the
chapels called "Del Pulgar."

From the Cathedral we visit the "Cartuja," once a wealthy


Carthusian convent, built upon grounds given to the monks by
Gonzales de Cordova—"El gran Capitan." In the refectory is shown
a cross, painted on the wall by Cotan, which so well imitates wood
that the very birds fly to it, and try to perch there. The church has
a beautiful statue of St. Bruno upon the altar; and a larger one in
the chapel of the Sagrario, by Alonzo Caño, is especially fine. The
sacristy is rich in marbles from the Sierra Nevada, and the doors
and other wood-work of the church and chapel are made of the
most curious and beautiful inlaid work—tortoise-shell, ebony, silver,
and mother of pearl—all done by one monk, who took forty-two
years to accomplish it; and after so adorning this chapel, behold!
the monks are driven from it.

In the church are several lovely pictures—a head of our Lord by


Murillo; a copy, by Alonzo Caño, of the Viergo del Rosario in the
Madrid gallery, and a copy of one of the "Conceptions" of Murillo —
that one with the fair flowing hair, so very lovely.

Returning home, we have our first view of the snow mountains,


(Sierra Nevada.) How strange and how charming to be beneath a
tropical sun, and with all the beautiful vegetation of Africa and the
Indies, with people all eastern in dress and manners, and see
above one snow-capped mountains like the glaciers of Switzerland!
Owing to the proximity of these glaciers, the heat is never
intolerable here, and yet the winters are so mild they seldom need
fire in their sitting-rooms or parlors.

October 12.
To-day is made memorable by our first visit to the Alhambra.
Situated on a high hill, on either side of which flows the Darro and
the Genil, this space, which occupies several hundred acres, was
formerly surrounded by walls and towers, and contained within it
the palaces and villas of the Kalifs of Granada; and so numerous
were these that it was called a city, Medina Alhambra. Of all these,
there now remains but that portion of the Alhambra known as the
summer-palace, (the winter-palace having been torn down by
Charles V. to make room for a palace which he never finished.)
Besides this summer-palace, there is the "Generalife," (a summer-
palace built—later than the Alhambra—in 1319;) the remains of the
Alcazabar, (fortress,) the Torre de la Vega, where the bell strikes
the hours in the same manner as in the Moorish days, to signify
upon whom devolves the duty of irrigating the "vega," the beautiful
and fertile plain below; the tower of the captive; tower of the
princesses; the tower of the "Siete Suetos," (seven stories;) and
the Torres Bermujas, (Red Towers.) The last named are outside the
Alhambra walls, but are on the same hill, and claim to belong to an
older date than even the Moors or the Goths—supposed to be of
Phoenician origin. The walls are entered by several gates, some
Arabic, and others more modern. From these gates, you wander
among stately avenues of trees, with flowers and shrubs and
charming paths, through which now and then is seen a glimpse of
the yellow towers, or some picturesque ruin, altogether a scene of
enchanting beauty. And when upon one of the "miradors" (look-
outs) or terraces which crown these towers and palaces, there lies
the Moorish city at your feet, the grand snow mountains on the
east, the beautiful vega stretching to the mountains on the west,
down which marched the conquering Christians; and on the south
lies that mountain so poetically called "the last sigh of the Moor,"
from which Boabdil looked his last upon the kingdom he was
leaving for ever, and where his mother made him the famous
reproach which has passed into history, that he did well to weep as
a woman over that kingdom he could not defend as a man.
And how venture to describe the Alhambra, which has been written
of by such men as Prescott and Irving! how give to any one an
idea of that which is unique in the world, of the grace and beauty
and wonderful variety of its adornments—the carvings like lace, the
bright colored mosaics and azuelos, (tiles,) the transparent stucco
work and filagree, the inlaid cedar-wood roofs, the pillars, the
domes and fountains, the courts, the beautiful arches! We enter
first the Court of the Myrtles, in which a large square pool, filled by
a fountain at either end, is surrounded by a hedge of fragrant
myrtle, and this in turn by a marble colonnade, over which is a
second gallery, with jalousies, through which we could imagine the
dark eyed beauties to have peeped. The roofs of these galleries are
of cedar-wood inlaid, and the arches and sides of exquisite wreaths
and vines in stucco, with shields of the Moorish kings, mottoes and
verses from the Koran, etc. This court was a place of ablutions for
the kalifs.

From the Court of the Myrtles, one sees the Tower of Comares,
(called from the name of its Persian architect;) and within this
tower, opening from the Court of Myrtles, and preceded by its
"antesala" is the Hall of the Ambassadors, the largest, highest, and
most beautifully adorned of all the Alhambra. Here was the sultan's
throne and reception room. On three sides, arched windows look
down into the deep ravine from which the tower rises; and,
beyond, upon an enchanting prospect, the old Moorish city and the
verdant hills and mountains. The roof of this hall is a sort of
imitation of the vault of heaven, and that of the "antesala" (called
"La Barca," from being shaped like a boat) is also very elegant.

On another side the Court of Myrtles is the famous Court of the


Lions, with its one hundred and thirty-six pillars of white marble, its
twelve lions in the centre, supporting an alabaster basin, (a
fountain.) At each end, a pavilion projects into the court, with
arabesque patterns so light and graceful that the very daylight is
seen through the stucco.
Opening from the Court of the Lions is the Hall of the
Abencerrages, deriving its name from the legend according to
which Boabdil invited the chiefs of the illustrious family of that
name to a feast, and had them taken out one by one and
beheaded. Others assert that they were murdered in this hall, and
show the stains of blood in the marble of the fountain. As they had
been mainly instrumental in placing him upon the throne, this act
of ingratitude helped to his ruin. This story is generally believed,
but Washington Irving has rescued the name of this "unlucky" one
(el chico) from this unjust aspersion. His investigations prove that
the crimes laid to the charge of Boabdil were in reality committed
by his father, Aben Hassin. He it was who murdered the thirty-six
Abencerrages upon suspicion of having conspired against him, and
it was he who confined his queen in the "tower of the captive," etc.

On the east side of the Court of the Lions is the "Sale del Tribunal,"
(the hall of justice,) where the kalifs gave audience on state affairs.
Three arches in the centre and two at either end lead into this hall,
which is ninety feet long by sixteen wide, with a dome thirty-eight
feet high. This is divided by arches into seven rooms, all profusely
ornamented, and in the ceilings of several recesses are paintings of
Moors, with cimeters, castles, etc. In one of these rooms is the
famous Alhambra vase of porcelain, four feet three inches high,
which was found full of gold. In another small room are three
tombstones, one of Mohammed II., and one of Yusef III., found in
the tomb-house of the Moorish kings, near the Court of the Lions,
in 1574. They have long and elaborate inscriptions, one of which
reads thus:

"In the name of God, the most merciful and clement!

"May God's blessing for ever rest with this our king!

"Health and peace!


"Gentle showers from heaven come down on this tomb, and
give it freshness, and the orchard spread its perfume upon it.
What this tomb contains is wine without admixture, and myrtles.
Reward and pardon be granted to him who lies within.

"It was God's pleasure that he should dwell amid the garden of
delights.

"Those that inhabit those happy regions come forth to meet him
with palms in their hands.

"If thou wouldst know the story of him who lies in the tomb,
listen. He was a prince above all in excellence. May God give
him sanctity!

"He was cut down into the dust. Yet the Pleiades themselves
are not his equals.

"Unavoidable fate took up arms, and aimed at the very throne


of the empire.

"Oh! how great was his fame. His excellence, how high! and
unbounded his virtues!

"For Abul Hadjaj was like the moon that points out the road to
take, and when the sun went down its brightness beamed no
less from his eyes.

"Abul Hadjaj showered down tokens of his liberality. But drought


is come; his liberality has ceased; his crops are gathered.

"His generosity is forgotten; his halls are lonesome; his


ministers silent, and his rooms deserted.

"But it was God's pleasure, the merciful one, (may he be


glorified,) to take him into the eternal dwelling when he
deprived him of life.
"Here lies he softly, within this narrow tomb, but his real
dwelling is the heart of every man.

"Why should I not pray God that the rain should moisten his
tomb with its abundant dew? for the rain of his liberality
showered down upon all without ceasing.

"Was he not filled with the fear of God, with gentleness and
wisdom? Amongst his qualities, were not virtue, liberality, and
magnificence one part?

"Was he not the only one that with his science cleared up all
doubts?

"Was not poetry one of his attributes, and did he not deck his
throne with verses like strings of pearl?

"Was he not always stout, and held his ground in the battle-
field?

"How many enemies his sword repelled!

"But Ebn Nasr, his successor, is certainly the greatest among all
monarchs of the earth.

"May God protect him!

"For he is most generous and victorious; besides, he distributes


rewards generously. He has saved the kingdom from ruin, and
restored it to its former greatness."

The Hall of the Two Sisters takes its name from two white slabs of
equal size in the pavement. Here are beautiful arches, windows
with painted jalousies, a fountain, and a wonderful roof, composed
of three thousand pieces in little miniature domes and vaults, all
colored in delicate blue and red with white and gold. From this hall,
indeed quite from the Court of the Lions, one sees through a series
of arched entrances into the "Corredor de Lindaraja," in which room
are thirteen little cupolas, and the Mirador de Lindaraja (a boudoir
of the sultana) looks upon the garden of Lindaraja, with flowers,
and fountains, and orange-trees.

On the opposite of this lovely garden, and looking into it, are the
rooms occupied by Washington Irving, those built by Philip V. for
his beautiful queen, Elizabeth of Parma, whom the Spanish call
"Isabel Farnese." Several corridors here lead to modernized parts of
the building—" the queen's boudoir," a chapel made by Charles V.
out of the mosque, and a lofty tower, used by the Arabs as an
oratory for the evening prayer, and from which the view is superb—
the "Generalife" with its white towers, the woods of the Alhambra,
the Darro far below in the deep gorge, and, beyond and above all,
the snow-capped Sierra Nevada.

The "Patio de la Mosquita" (the court of the mosque) has only the
remains of its beautiful roof.

From this to the baths is a long corridor leading to the Chamber of


Rest, which has just been restored by Sig. Contreras, the able
architect who is repairing the whole building, by order of the
queen. This has a fountain in the centre, marble pillars all round, a
gallery above, where the musicians played and sung while the
bather inclined upon the cushions below; within were the marble
baths of the sultan, the sultana, etc.

"Generalife" means garden of pleasure, and here garden above


garden rises upon the mountain side, through which the Darro
rushes noisily, being brought by a little canal quite through the
mountain. In one of the rooms are some interesting portraits of the
kings and queens of Spain. Ferdinand and Isabella, Philip the
handsome, Jeanne la Folle, Charles V. and Isabella, Don John of
Austria, etc.; and in a second room a series of portraits of the
Dukes of Granada, whose descendant, now married to an Italian
nobleman of Genoa, owns this lovely place. The founder of this
house was a converted Moor, and to his descendants (the houses
of Venegas and Granada) Philip IV. made this a perpetual grant. In
one of the many gardens are some cypress-trees planted by the
Moors, seven hundred years old. Under one of these, a love story is
said to have been enacted, of which the beautiful Sultana Zorayda
is the heroine. Amongst the portraits in the picture gallery is one of
Boabdil, fair and handsome, with yellow hair, and a gentle, amiable
look. He may not have had the qualities fitted to the terrible
emergency in which he was placed, when domestic contention and
misrule had so weakened his empire as to make it difficult to
struggle against the growing greatness of Ferdinand and Isabella;
but he must have possessed qualities which won for him the love
of his people, for many years after his time, the Moors who still
lingered about Granada sung the plaintive song said to have been
composed by Boabdil himself, relating his misfortunes and his
sorrows, spoke of him reverently, and lamented his fate.

It is said he lived to see his children begging their bread at the


door of the mosques in Fez. He was killed in Africa, fighting the
battles of the prince who gave him shelter.

We hasten from the Generalife to see the sunset from the Torre de
la Vega, which is the finest view we have had of the city—the Vega
with the lovely rivers winding through it, and the grand mountains
beyond. As the sun declined, from the many church bells came the
"Ave Maria," soft and musical from the great distance below.

The guide points out the hospital founded by St. John of God, (a
Portuguese saint,) the founder of the brothers of charity now
spread all over Europe. According to the guide, the saint asked the
king for as much land, on which to build this hospital, as he could
enclose in a certain number of hours. Of course he was
miraculously assisted; and by working all night, he took in so great
a space that the king became alarmed. Here he built this hospital
and the church in which he is buried. He lost his life rescuing a
drowning man, and died blessing Granada.
Tuesday.

Spent the whole morning in the Alhambra, wandering amid its


beauties, feasting upon its romantic memories, and reading at
intervals the charming legends connected with every spot so
delightfully told by Washington Irving. In the hall of the tribunal,
we read his account of the entrance of the triumphant Ferdinand
and Isabella, and fancy the scene when Cardinal Mendoza
celebrated the first mass here.

Seated in the Court of the Lions, we meditate upon the cruel death
of the noble Abencerrages, and lean from the window of the Tower
of Comares, down which the good Ayesha let her infant son Boabdil
escape, to save him from the jealous fury of her rival Zorayda.

And then, in the later days of the beautiful Elizabetta of Parma, we


recall the scene where the hypochondriac Philip persists in being
laid out for dead, and can only be brought to life by the voice and
lute of the fair maiden, "the Rose of the Alhambra."

In contrast to the Alhambra are the remains of the palace begun


with such magnificence by Charles V., of which only the walls
remain. Within their vast area and amongst its marble pillars,
muleteers were depositing their billets of wood, and burdens of dirt
and ashes! Sic transit gloria mundi.

We go to look at that which has lasted longer, the church built by


him near by, and called Sta. Maria del Alhambra. Wandering on, we
find ourselves amongst the ruins of the Franciscan convent (still
within the Alhambra walls) which was destroyed by the French in
1809-11, when so much of the Alhambra was injured.

Led by a little boy, and following the wall, we come upon a


plantation of cactus, with its red and yellow fruit, which a man is
gathering with great scissors, to prevent its prickings. A woman
politely cuts and pares some for us to taste. It is sweet and juicy;
is much eaten by the poor, who call it "Tuños." They also make
from it a palatable drink—a sort of beer. Hans Andersen has written
a pretty sonnet to the cactus, which seems especially applicable to
this time and occasion.

"Yes, yellow and red are the colors of Spain;


In banners and flags they are waving on high;
And the cactus flower has adopted them too,
In the warm sunshine to dazzle the eye.
Thou symbol of Spain, thou flower of the sun,
When the Moors of old were driven away,
Thou didst not, like them, abandon thy home.
But stayed with thy fruit and thy flowers so gay.
The thousand daggers that hide in thy leaves
Cannot rescue thee from the love of gain;
Too often it is thy fate to be sold,
Thou sunny fruit with the colors of Spain."

Here we find ourselves at the tower of the "Siete Suelos," through


which Boabdil passed when he left the Alhambra for ever. It is said
that he asked of Isabella that the door might be walled up, so that
no one should ever pass through it after him, and his conquerors
acceded to his request. Returning through one of the many
beautiful paths leading to our hotel, we diverge to look at a view
which presented itself, and find we are near the villa of Señora
Calderon. Here, terrace above terrace rises in view of the
mountains, and on the summit is an artificial lake, with bridges and
boats, and winding walks, and flowers and fruits, and statues and
fountains—everything to make a perfect paradise.

At night, we have a gypsy-dance. The chief of his troop is the


finest guitar player in Spain—there can be no better in the world—a
tall, dark, grave man, who received our plaudits with kingly grace;
he looked as if in sorrow over the degradation of his people, who
are here in great numbers, living in wretched quarters on a hillside,
in holes or caves in the ground.

The dancers were four lovely, graceful girls, modestly dressed, and
several men, all dark, with large, soft eyes and white teeth. A
youth in short jacket, with broad red faja (sash) and the peculiar
Andalusian hat, danced a solo of strange fashion, with many
movements of the body, and the extraordinary gestures which
belong to all. The feet move in short steps—a sort of "heel and
toe"—while the body sways to and fro, and the hands and arms
move gracefully and expressively. The men had tambourines and
the women castanets, and the wild airs to which they danced were
accompanied with their voices. The variety of dances and songs
was curious and interesting, and often descriptive. At the end of
each dance, the girls came round and saluted all, gentlemen and
ladies, by passing one arm over the neck.

Wednesday.

Drive about the city, the public squares, etc., and visit the remains
of the old Moorish bazaar which occupies a square intersected by
narrow lanes, every one of which is beautifully ornamented with
pillars and arabesque work.

The alameda, planted in long avenues of trees which meet


overhead, beyond which one catches a view of the Snow
mountains, and beside which flows the Genil river, can not be
excelled in beauty.

The church and hospital of St. John of God is most interesting.


Over the door are these words of the saint, "Labor, without
intermission, to do all the good works in your power while time is
allowed you." The hospital is built round a large court, with
fountains and gardens, and a double row of corridors in which sat
the sick poor, clean and comfortable. It communicates with the
church, which has several good pictures, and a head of St. John
the Baptist, carved by Caño.

In a richly ornamented chapel behind the great altar is the body of


the saint in a silver casket. The remains of St. Feliciana are also
here, as well as many other relics. In an adjoining room is seen the
identical basket in which the saint carried provisions to the poor.

The church was built by contributions sent by one of the order


from South America. The cedar-wood doors are said to be made
from the logs in which the concealed treasures were brought over.

We climb to the top of the "Torres Bermujas," outside the Alhambra


walls, from whence is another splendid view—a curious old ruin,
dating from the time of the Phoenicians. It is said to have been a
stronghold of the Jews, who made a colony here during their
persecutions by the Romans; and being treated with equal cruelty
by their Gothic conquerors, they invited in the Moors, betrayed the
city to them, made terms for themselves, and thus brought upon
themselves the eternal enmity of the Spaniards, who treated them
with great rigor after the conquest, and finally banished them. In
the story of the three beautiful princesses, this tower plays an
important rôle; here were confined the captive Spanish knights
who eloped with the Infantas, (daughters of Mohammed the left-
handed,) and beyond, rising above the deep, romantic ravine, is the
Tower of the Princesses, beneath which the knights sang their tales
of love.

Madrid, Hotel De Paris.

Friday, October 16.

Yesterday (my feast) and the feast of the great Spanish Saint
Teresa was celebrated by our most sorrowful departure from
Grenada! At three o'clock in the morning, we descend the hill of
the Alhambra, and ruefully mount to the top of a Spanish diligence,
and squeeze into what they call the "coupe"—an exalted place
behind the coach-box, from whence one looks down upon the ten
mules who drag this lumbering vehicle, see all their antics, observe
the rash manner in which they tear down precipitous heights, and
mount steep ascents, having the comfortable certainty that in no
event of danger could we possibly descend from this lofty perch
and save ourselves!

A "special providence," however, guards the Spanish diligence, to


say nothing of the three "conductors"—the postillion who rides in
front, the individual who sits on the box with gold lace and red on
his cap, and who smokes leisurely, let what will happen, only
occasionally speaking to the mules, calling them by name, and
urging them on with a sound like "ayah!" and the boy who runs
alongside shouting, screaming, and plying the whip, now jumping
on the front of the diligence to rest a moment, now hanging on by
one hand to the side doors or behind; active as a cat he springs up
and down while the vehicle is at full speed, keeping one all the
while in terror for his safety.

Such is the Spanish diligence from the "coupé." In the interior, shut
out from the front view, one only hears the united voices of the
"conductors," and it is less exciting. We who are above, however,
have the advantage of a fine view of the mountains, (the Sierra
Morena,) over which we pass by a smooth and beautiful road.

Jaen is the only place of importance which we see, an old Moorish


town with histories and legends, a fine cathedral, and a Moorish
castle on the height above. From this, a few hours brings us to
Menjibar, where we take the railway at six P.M., and reach Madrid
about eight the next morning. At Menjibar, we bid adieu to our
young American friend, who had journeyed with us since leaving
Cordova, and parted with the Scotch and German ladies whom we
had encountered at various points.
Madrid is filled with people. General Prim is in this hotel, is
modestly refusing to be made dictator, and proposing that Spain
shall have, as heretofore, a king. We shall see how long it will be
before (like Caesar) he is overpersuaded, and reluctantly assumes
power.

Topete (the admiral who, at Cadiz, brought over the fleet) is also in
Madrid; and Serrano, the prince of the traitors, is president of the
provisional government. The table d'hôte is crowded with men of
the press, (letter-writers of all nations,) giving their several
impressions of matters to the gullible "public," and interpreting
events to suit the taste of their readers. We ask one of these (a
witty Frenchman) if he writes for Le Monde. "Oui, Madame, pour
tout le monde." Amongst the motley crowd, we distinguish the
letter-writer of the London Times, and him of the New York
Times, with whom we make acquaintance, and who having lived a
long time in France, and being of Irish extraction, is very little of an
American in appearance and manner.

Saturday, October 17.

Madrid is a modern city with fine buildings and shops, many


handsome streets and squares, and a beautiful promenade, called
the Prado, (meadow.) The principal of these squares is the "Puerta
del Sol," upon which this hotel opens, and which is always
thronged with people, and is all life and bustle. This being the head
and front of the revolution, and General Prim being in the house,
the doors are besieged by beggars and revolutionists. As we walk
the streets, in many shop-windows are vulgar caricatures of the
queen and the priests. This is adding insult to injury, and the very
essence of meanness—to take away her throne, and then aim at
her character as a woman. It is refreshing to find that the best
people we see—the best born, the best bred, and the best
educated—defend her from these aspersions, and are loyal to her,
and to the throne.

Sunday, October 18.

We hear high mass in the church of the "Calatrava," (an ancient


order of knighthood,) where are crowds of pious looking men.
Certainly it will be difficult for the revolution to rob these people of
their religion. For a time they may be intoxicated with the
excitement of the change, but the reaction must come, when the
sober second thought will bring them back to their true friends.
Now, the banishment of the Jesuits, the best and most learned
teachers, the confiscation of church property, and the destruction of
churches initiates the new order of things. Yesterday, an English
gentleman (one of the noisiest supporters of the revolution) told us
how the junta had given two places of great trust and importance
into the hands of two of the lowest and most vulgar and ignorant
of the bull fighters; and thus this class of people who have helped
on the revolution must be rewarded. We hear, to-day, that General
Prim has offered to promote, one grade, every officer of the army
lately opposed to him. To their honor be it spoken, every one
refused such promotion.

To Be Continued
Translated From The French.

Sister Aloyse's Bequest.

I.

How delightful it is to sit under the grand old trees of the courtyard
on this charming mid-summer evening! The light breeze is redolent
with the fragrance of the new-mown hay, and the leaves seem to
quiver with joy in an atmosphere heavy with sunshine. The
swallows pursue each other in play with short, wild cries, and in
the foliage of the linden-tree that brown bird, the nightingale, tries
her brilliant cadences, drowned at times by the shouts of the
children at their sports answering her in the silences, whom without
doubt they understood and admired. The children, happy as the
birds, dance and whirl about, just like those motes one frequently
sees rising up in a sunbeam. The nuns, sombre and silent figures,
watch them, contemplating life in its flower and carelessness. This
court-yard where the children play and the birds sing belonged
formerly to a monastery of the order of St. Benoit; but now to a
cloister built out of its ruins, where the virtues of ancient days
flourish under the shelter of modern walls, which are hallowed by
the memories of the past.

Some young girls, no less pleased with the gambols of the children,
were walking in groups to and fro under the vaulted arches which
encircled the court, talking and laughing merrily; but whenever they
approached a nun reclining in an easy chair, by an involuntary
impulse they lowered their voices. She was a poor invalid, who had
been brought out to enjoy the sweet odors and the pleasant
warmth of the evening. She appeared to be nearing the end of life,
though still young. For the paleness of her cheeks, the emaciation
of her body, and the transparent whiteness of her hands, all
proclaimed the ravages of a long and incurable illness. There was
no more sand in the hourglass, no more oil in the lamp, and her
heart—like a timepiece about to stop—was slacking its pulsations.
One could not help but see that Sister Aloyse retained a very
powerful fascination in the beauty which her terrible illness had not
been able to efface. Her dark blue eyes had not lost their almond-
shape or sapphire hue. Her figure was still elegant, seen under the
loose robe which wrapped her like a winding-sheet; and her voice
was as sweet and agreeable as in former days.

At first she felt a little better upon being brought into the garden;
but she still suffered, and neither the pure air nor the mildness of
the beautiful evening had revived her. She sat in silence, absorbed,
perhaps, in those last thoughts, which she did not confide even to
herself, and which, to one who is about departing, seem to give a
glimpse of those unknown shores which are yet so near to her who
waits them.

What is she thinking of? Of her past without remorse; of her future
without terror? Does she regret anything which she has renounced
for her God? Does one last thread hold captive this celestial bird? I
cannot say. She appears sad; yet her companions, always so
affectionately attentive, do not seem to be surprised. For Sister
Aloyse had always been characterized, even in the more beautiful
days of her youth, by a kind of melancholy. She resembled an
angel of peace, but yet an angel who weeps.

One young girl, who was walking under the arches, regarded her
with great interest; and finally, leaving the group by whom she was
surrounded, approached the nun, dropped on her knees in the
grass before her, and, looking in her face, said earnestly:

"Well, my sister, are you better this evening?"


Sister Aloyse blushed slightly, just as porcelain is tinged with a faint
rose-color when a flame is passed behind it, and answered in a
voice sweet and low:

"Thank you, Camille, I am not well, and I shall never be any better
till I come into the presence of our Lord. Look! does it not seem
indeed as if the gates of heaven were opening yonder?"

She pointed to the west, then filled with the glory and splendor of
purple and gold and flame colors.

"Yet one cannot go there," answered Camille in a caressing tone.

"Oh! yes; provided the great God will receive us. And something
warns me that I shall shortly go to him."

Both now became silent, Camille sadly regarding her companion.


Educated in this convent, she had always been accustomed to see
Sister Aloyse there, where she was much beloved. She would like
to have given her some pleasure, but what could she give, or what
could she say, to a person so detached from earthly things, and
whose aspirations were fixed on joys eternal?

The nun was still thinking, praying perhaps; and after a long silence
she said,

"Camille, you must come and see me some time before I go away
from here. But now good-night, dear!"

Two nuns now came forward to help the sister into the house,
while Camille, who had gathered some white roses, carried them to
Aloyse, saying,

"They are from my own little garden, my sister; therefore take


them, I pray you."
"Willingly," said Aloyse, "and I will offer them to the Holy Virgin.
And, Camille, do not forget to remember me in your prayers
tonight."

II.

"Go, my child," said the old abbess to Camille, "go to the infirmary
and see Sister Aloyse; she has something to say to you."

"Is she going to die?" asked Camille with tears in her eyes.

"She will go to her eternal home soon, but not to-day. Have no
fear, child, but go and listen carefully to what she tells you."

Camille with agitated heart (for this poor heart is so quickly stirred
at sixteen years!) ascended the staircase which led to the cells of
the nuns. She passed through a long corridor out of which opened
the little doors, all of which, instead of a number or design, bore
some holy image or pious inscription. At the end of this corridor
she found the infirmary, a large room, quiet and retired, whose
windows opened upon the court and garden below. At this moment
it was almost vacant; she found only one bed occupied, that of
Sister Aloyse, who, as she had no fever, had been left by the
infirmarian while she attended vespers in the chapel. Camille
noiselessly approached the bed, the curtains of which were half
drawn so that Aloyse could see out. She was sitting up supported
by her pillows, and her hands were joined before her on the cross
of her rosary. She smiled on the young girl, who timidly embraced
her; and then Camille very earnestly asked her why she had sent
for her to come to her bedside instead of any other of the girls, or
her friends or companions; for she was afraid, as one naturally
dreads what is unknown. The nun fixed upon her those searching
eyes which seemed to look through and beyond anything present,
and said with much sweetness,
"Sit down, Camille; I have something to say to you." She hesitated,
but finally said, "You have never heard any one of your family
speak of me?"

"Never," answered the child, somewhat surprised. "I have known


something of your family—your father," she said with an effort. "But
it was a long time ago, a very long time—before you were born. I
was related to your grandmother, Madame Reville."

"I never saw her, but I have seen her great portrait," said Camille.

"Yes, it hangs in the red drawing-room, does it not?" asked Sister


Aloyse with a sad smile. "Ah! well. Madame Reville received me into
her family as a lady's companion—a reader—for I was poor, and
needed some home. Your father did not live at home with his
mother, but he came there very frequently."

Here she paused, breathing with difficulty, but continued:

"He wished to marry me; Madame Reville was opposed to it; he


insisted. I saw he would disobey his mother; I was afraid for him; I
was afraid for myself. So I prayed to the good God. He did not
reject my afflicted and desolate heart, but he—the Divine Consoler
—called me into this home, and placed this holy veil as a barrier
between the world and myself. Here I found peace, purchased
sometimes with bitter suffering, but real; for it filled the depths of
my heart; it was the price of my sacrifice. And I was able to see, in
the clear light which streamed from the cross, how all joy is
deceitful, and all pleasure empty and false. After two years had
passed, I came to consecrate myself with irrevocable vows to God's
service, when the friends who now and then came to see me, and
public report, which in our day finds its way even into the cloister,
told me of the only thing which had still power to afflict me. For,
Camille, your father—but what can I say to you who bear his
name! M. Reville, angry at my departure, and grieving for the loss
of the poor creature that I am, sought forgetfulness in dissipation.

You might also like