Full Getting Started With SQL A Hands On Approach For Beginners 1st Edition Thomas Nield Ebook All Chapters
Full Getting Started With SQL A Hands On Approach For Beginners 1st Edition Thomas Nield Ebook All Chapters
com
https://textbookfull.com/product/getting-started-with-sql-a-
hands-on-approach-for-beginners-1st-edition-thomas-nield/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/getting-started-with-phantomjs-
beltran-aries/
textboxfull.com
https://textbookfull.com/product/getting-started-with-kubernetes-2nd-
edition-baier/
textboxfull.com
https://textbookfull.com/product/getting-started-with-gulp-second-
edition-travis-maynard/
textboxfull.com
https://textbookfull.com/product/getting-started-with-angular-2nd-
edition-stephen-adams/
textboxfull.com
https://textbookfull.com/product/sql-queries-for-mere-mortals-a-hands-
on-guide-to-data-manipulation-in-sql-4th-edition-john-l-viescas/
textboxfull.com
https://textbookfull.com/product/getting-started-with-advanced-c-1st-
edition-vaskaran-sarcar-sarcar/
textboxfull.com
Getting Started with
SQL
A HANDS-ON APPROACH
FOR BEGINNERS
Thomas Nield
Getting Started with SQL
A Hands-on Approach for Beginners
Thomas Nield
Boston
Getting Started with SQL
by Thomas Nield
Copyright © 2016 Thomas Nield. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or [email protected].
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Getting Started with SQL, the cover
image, and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the author disclaim all responsibility
for errors or omissions, including without limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.
978-1-491-93861-4
[LSI]
Table of Contents
Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
2. Databases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
What Is a Database? 3
Exploring Relational Databases 3
Why Separate Tables? 4
Choosing a Database Solution 5
Lightweight Databases 5
Centralized Databases 6
3. SQLite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
What Is SQLite? 9
SQLiteStudio 9
Importing and Navigating Databases 10
4. SELECT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Retrieving Data with SQL 19
Expressions in SELECT Statements 23
Text Concatenation 27
Summary 28
iii
5. WHERE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Filtering Records 29
Using WHERE on Numbers 30
AND, OR, and IN Statements 31
Using WHERE on Text 32
Using WHERE on Booleans 34
Handling NULL 34
Grouping Conditions 36
Summary 37
7. CASE Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
The CASE Statement 47
Grouping CASE Statements 48
The “Zero/Null” CASE Trick 49
Summary 52
8. JOIN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Stitching Tables Together 53
INNER JOIN 55
LEFT JOIN 58
Other JOIN Types 61
Joining Multiple Tables 61
Grouping JOINs 63
Summary 66
9. Database Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Planning a Database 67
The SurgeTech Conference 69
ATTENDEE 69
COMPANY 69
PRESENTATION 70
ROOM 70
PRESENTATION_ATTENDANCE 70
Primary and Foreign Keys 70
iv | Table of Contents
The Schema 71
Creating a New Database 73
CREATE TABLE 76
Setting the Foreign Keys 84
Creating Views 86
Summary 89
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Table of Contents | v
Foreword
Over the past three decades, computers have taken over the world. Twenty-five years
ago, we lived analog. We communicated using an analog POTS telephone, we tuned
in to analog FM radio stations, and we went to the library and browsed the stacks for
information. Buildings were constructed using hand-drawn blueprints; graphic artists
worked with pen, brush, and ink; musicians plucked strings and blew into horns and
recorded on analog tape; and airplanes were controlled by physical cables connecting
the yoke to the control surfaces.
But now everything is computerized and digital. Consequently, every member of
society needs to be familiar with computers. That does not mean having the deep
knowledge of a techie, but just as poets need to study a little math and physics, and
just as mathematicians need to read a little poetry, so too does everybody today need
to know something about computers.
I think that this book really helps to address the knowledge gap between techies and
laypeople, by providing an accessible and easy-to-read discussion of SQL—a core
database technology.
vii
Preface
Nobody needs to learn how a car engine works in order to drive a car. The whole
point of technologies like SQL is to allow you to focus on the business problem, and
not worry about how the technical details are executed. This book will give you a
practical focus on using SQL, and will steer away from unnecessary technical details
that are likely not pertinent to your immediate needs. Much of the content revolves
around hands-on exercises with real databases you can download so you see how
concepts are applied. When you finish this book you will have practical knowledge to
work with databases, as well as use them to overcome your business challenges.
ix
When working with technology, you are never expected to know everything. As a
matter of fact, technology topics are so vast in number it would be impossible. So it is
helpful to develop a degree of tunnel vision and learn only enough to fulfill the task at
hand. Otherwise, you can get overwhelmed or distracted learning irrelevant topics.
Hopefully this book will give you a foundation of knowledge, and afterward you can
continue to learn about topics that are pertinent to you.
You are always welcome to reach out to me at [email protected], and I will answer
any questions to the best of my ability. If you have questions about positioning your
career with technical skillsets or have a SQL question, I might be able to help. I hope
that this material not only augments your skillset and career opportunities, but also
sparks new interests that excite you like it did for me.
x | Preface
the code. For example, writing a program that uses several chunks of code from this
book does not require permission. Selling or distributing a CD-ROM of examples
from O’Reilly books does require permission. Answering a question by citing this
book and quoting example code does not require permission. Incorporating a signifi‐
cant amount of example code from this book into your product’s documentation does
require permission.
We appreciate, but do not require, attribution. An attribution usually includes the
title, author, publisher, and ISBN. For example: “Getting Started with SQL by Thomas
Nield (O’Reilly). Copyright 2016 Thomas Nield, 978-1-4919-3861-4.”
If you feel your use of code examples falls outside fair use or the permission given
above, feel free to contact us at [email protected].
Technology professionals, software developers, web designers, and business and crea‐
tive professionals use Safari Books Online as their primary resource for research,
problem solving, learning, and certification training.
Safari Books Online offers a range of plans and pricing for enterprise, government,
education, and individuals.
Members have access to thousands of books, training videos, and prepublication
manuscripts in one fully searchable database from publishers like O’Reilly Media,
Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que,
Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kauf‐
mann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders,
McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more
information about Safari Books Online, please visit us online.
Preface | xi
How to Contact Us
Please address comments and questions concerning this book to the publisher:
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://bit.ly/getting-started-with-sql.
To comment or ask technical questions about this book, send email to bookques‐
[email protected].
For more information about our books, courses, conferences, and news, see our web‐
site at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Acknowledgments
I am blessed to have amazing people surrounding me, and I realize how central they
have been in my life and everything I do. If it was not for them, this book would
probably not have happened.
First and foremost, I would like to thank my mom and dad. They have given every‐
thing to secure my future. I know for a fact that I would not have the opportunities I
have today if it was not for them. My dad worked hard to provide a better education
for my brothers and me, and my mother always pushed me forward, even when I
resisted. She taught me to never settle and always struggle through my limits.
I cannot express enough gratitude toward my leaders, managers, and colleagues at
Southwest Airlines Revenue Management. Justin Jones and Timothy Keeney have a
warrior spirit and zeal for innovation that few possess. They truly define the leader‐
ship and spirit of Southwest Airlines, but more importantly they are good guys. They
will always be my friends and they’ve made it hard to imagine a life without South‐
west Airlines.
xii | Preface
Robert Haun, Brice Taylor, and Allison Russell continuously work to make our team
the forefront of innovation and continuously pursue new ideas, and I am blessed to
work in the environment they have helped create. I also have to thank Matt Louis for
bringing me on board at Revenue Management, and Steven Barsalou who made me
realize how little I really knew about SQL. Steven is the first person who came to
mind when I needed a reviewer for this book, and I am grateful he came on board
this project.
Then there is the project team I work with every day: Brian Denholm, Paul Zigler,
Bridget Green, Todd Randolph, and Chris Solomon. As a team, the feats we pull off
never cease to amaze me. Brian is the kind of project manager that can effectively
bridge technology and business jargon together, and he will not hesitate to get his
hands dirty with SQL and the occasional code review. I want to give a special thanks
to Chris Solomon for helping me with everything I do every day. He not only has a
rare talent to absorb high volumes of technical knowledge and maintain it in a busi‐
ness perspective, but he is also a nice guy that I am privileged to be friends with.
Chris is always a key player in any project, and I was thrilled when he agreed to
review this book.
I cannot forget the great people who worked at Southwest Airlines Ground Ops
Safety Regulatory Compliance, including Marc Stank, Reuben Miller, Mary Noel
Hennes, and everybody else I had the privilege of working with. I interned and con‐
tracted with that department a few years back and some of my fondest memories are
there. It was there I discovered my passion for technology, and they provided many
opportunities for me to pursue that, whether it was throwing together databases or
prototyping an iPad app.
When I announced I was publishing this book I did not expect Richard Hipp, the
founder and creator of SQLite, to reach out to me. Richard graciously stepped up to
be the technical reviewer for this book and it has been a tremendous honor to have
him on board. The technology community continues to amaze me, and the fact
Richard Hipp joined this project shows how unique and close-knit the community
really is.
Shannon Cutt has been my editor at O’Reilly for this book. This is my first book and I
was uncertain what the publishing experience would be like. But Shannon made pub‐
lishing such a pleasant experience that I am eager to write again. Thanks Shannon,
you have been awesome!
Last but not least, I want to thank Watermark Church and the volunteers at Careers
in Motion for creating the vehicle that made this book happen. I initially wrote this
“book” as a public service to help unemployed professionals in the Dallas area. It was
at their encouragement that I decided to publish it, and I want to give a special thanks
to Martha Garza for her insistence. I have learned remarkable things can happen
when you give your time to help others.
Preface | xiii
CHAPTER 1
Why Learn SQL?
1
Who Is SQL For?
One misperception about SQL is that it is an IT skill and therefore only applicable to
technology (not business) professionals. In the world as it exists today, this is hardly
the truth. Businesspeople, managers, IT professionals, and engineers can all reap ben‐
efits from learning SQL to better position their careers. SQL can open many career
paths because it enables individuals to know their businesses better through the data
that is driving them. On the business side, interest in SQL can lead to roles that are
analytical, managerial, strategic, and research- or project-based. On the IT front, it
can lead to roles in database design, database administration, systems engineering, IT
project management, and even software development.
What Is a Database?
In the broadest definition, a database is anything that collects and organizes data. A
spreadsheet holding customer bookings is a database, and so is a plain-text file con‐
taining flight schedule data. Plain-text data itself can be stored in a variety of formats,
including XML and CSV.
Professionally, however, when one refers to a “database” they likely are referring to a
relational database management system (RDBMS). This term may sound technical
and intimidating, but an RDBMS is simply a type of database that holds one or more
tables that may have relationships to each other.
3
We can reasonably expect there to be another table, maybe called CUSTOMER
(Figure 2-2), which holds the customer information for each CUSTOMER_ID.
When we go through the ORDER table, we can use the CUSTOMER_ID to look up the cus‐
tomer information in the CUSTOMER table. This is the fundamental idea behind a “rela‐
tional database,” where tables may have fields that point to information in other
tables. This concept may sound familiar if you’ve used VLOOKUP in Excel to retrieve
information in one sheet from another sheet in a workbook.
Notice that for the Re-Barre Construction orders someone had to populate the cus‐
tomer information three times for all three orders (the name, region, street address,
city, state, and zip). This is very redundant, takes up unnecessary storage space, and is
difficult to maintain. Imagine if a customer had an address change and you had to
update all the orders to reflect that. This is why it is better to separate CUSTOMERS and
ORDERS into two separate tables. If you need to change a customer’s address, you only
need to change one record in the CUSTOMER table (Figure 2-4).
4 | Chapter 2: Databases
Figure 2-4. A normalized table
We will explore table relationships again in Chapter 8, and learn how to use the JOIN
operator to merge tables in a query so the customer information can be viewed along‐
side the order.
Lightweight Databases
If you are seeking a simple solution for one user or a small number of users (e.g., your
coworkers), a lightweight database is a good place to start. Lightweight databases have
little to no overhead, meaning they have no servers and are very nimble. Databases
are typically stored in a file you can share with others, although it starts to break
down when multiple people make edits to the file simultaneously. When you run into
this problem, you may want to consider migrating to a centralized database.
The two most common lightweight databases are SQLite and Microsoft Access.
SQLite is what we will use in this book. It is free, lightweight, and intuitive to use. It is
used in most of the devices we touch and can be found in smartphones, satellites, air‐
craft, and car systems. It has virtually no size limitation and is ideal for environments
where it is not used by more than one person (or at most a few people). Among many
other uses, SQLite is ideal to learn SQL due to its ease of installation and simplicity.
Microsoft Access has been around for a while and is inferior to SQLite in terms of
scalability and performance. But it is heavily used in business environments and
Centralized Databases
If you expect tens, hundreds, or thousands of users and applications to use a database
simultaneously, lightweight databases are not going to cut it. You need a centralized
database that runs on a server and handles a high volume of traffic efficiently. There
is a wide array of centralized database solutions to choose from, including the follow‐
ing:
• MySQL
• Microsoft SQL Server
• Oracle
• PostgreSQL
• Teradata
• IBM DB2
• MariaDB
You can install some of these solutions on any computer and turn that computer into
a server. You can then connect users’ computers (also known as clients) to the server
so they can access the data. The client can send a SQL statement requesting specific
data, and the server processes the request and returns the answer. This is a classic
client–server setup. The client requests something, and the server gives it.
While you can turn any MacBook or cheap PC into a MySQL server, larger traffic vol‐
umes require more specialized computers (called server computers) optimized for
server tasks. These are typically maintained by an IT department whose members
administrate and control databases formally deemed critical to the business.
As you enter a workplace, chances are an existing centralized database might exist
with information you need, and you will need to request access to it. While we will
not be covering centralized databases in this book, the experience between different
database solutions should largely be the same. Across all database solutions, you use
6 | Chapter 2: Databases
SQL to interact with tables in a pretty uniform way, and even the SQL editor tools are
somewhat similar. Each solution may have nuances to its implementation of SQL,
such as date functionalities, but everything in this book should be universally applica‐
ble.
If you ever do need to create a centralized database solution, I would highly recom‐
mend MySQL. It is open source, free to use, and straightforward to install and set up.
It is used by Facebook, Google, eBay, Twitter, and hundreds of other Silicon Valley
companies.
With a conceptual understanding of databases, we can now start working with them.
Although we will use SQLite in this book, keep in mind it uses SQL, so the knowledge
you gain is applicable to all database platforms.
What Is SQLite?
As discussed in the previous chapter, there are many places to put data. But often‐
times we want a quick, easy place to put data without all the hassle of a client–server
setup. We want to store data in a simple file and edit it just as easily as a Word docu‐
ment. This is an optimal situation to use SQLite.
SQLite is the most widely distributed database in the world. It is put on iPhones,
iPads, Android devices, Windows phones, thermostats, car consoles, satellites, and
many other modern devices that need to store and retrieve data easily. It is used heav‐
ily in the Windows 10 operating system as well as the Airbus A350 XWB aircraft. It
excels where simplicity and low overhead is needed. It is also great for prototyping
business databases.
But every technology has a trade-off. Because it has no server managing access to it, it
fails in multiuser environments where multiple people can simultaneously edit the
SQLite file. Still, for our training purposes, SQLite is perfect.
SQLiteStudio
There are many SQL editors you can use to work with a SQLite database. I strongly
recommend using SQLiteStudio, as it is intuitive and makes it easy to explore and
manage a database. We are going to use that application in this book. You can down‐
load it at http://sqlitestudio.pl/?act=download. Be sure to choose Windows, Mac, or
Linux for your respective OS. Then open the downloaded folder and copy it to a loca‐
tion of your choice. No installation is needed. To start SQLiteStudio, double-click
SQLiteStudio.exe (Figure 3-1). You can also create a shortcut on your desktop so you
can easily launch the application in the future.
9
Figure 3-1. The SQLiteStudio folder
10 | Chapter 3: SQLite
Figure 3-2. The SQLiteStudio dashboard
Let’s get some databases into SQLiteStudio. Some SQLite database samples used in
this book are provided at http://bit.ly/1TLw1Gr.
Download the databases by clicking the Download ZIP button and copy the contents
to a folder of your choice. You will probably want to dedicate this folder to all the
databases you will work with in this book.
After downloading the databases, navigate in the top menu to Database → Add a
Database (Figure 3-3).
You will come to a dialog box prompting for a database file. Click the yellow folder
icon to select a database file and import it (Figure 3-4).
12 | Chapter 3: SQLite
Figure 3-4. Opening a database
Browse for the folder with the saved databases, and double-click the rexon_metals.db
database file to load it into SQLiteStudio (Figure 3-5).
Este es nuestro último día; menester es, por tanto, preparar los
lazos que han de ahorcarnos, o aguzar el acero.
ELECTRA
Mátame tú, pues, ¡oh hermano!, para que ningún argivo llene de
ignominia a los hijos de Agamenón.
ORESTES
Sería para mí lo más grato; pero ya ves cómo nos abandonan los
amigos, para juntarnos después en la tumba. Nada ha dicho en tu
favor, nada ha hecho para que no mueras ese villano Menelao, traido
a mi padre; ni siquiera lo hemos visto; atento solo a no perder su
cetro, tuvo miedo de salvar a sus amigos. ¿Qué hemos de hacer? Que
sea gloriosa nuestra muerte y digna de los hijos de Agamenón. Y yo
probaré mi nobleza a los ciudadanos atravesando mis entrañas con la
espada; tú debes hacer lo mismo. Pílades, preside a nuestro suicidio
tributa a nuestros cadáveres los últimos deberes y entiérranos juntos
llevándonos al sepulcro de mi padre. Y adiós; como ves, ahora mismo
voy a cumplir mi sentencia.
PÍLADES
Espera. Tengo que reconvenirte porque has creído que yo querría
vivir sin ti.
ORESTES
Ven al fin, ¡oh padre!, si debajo de la tierra oyes a tus hijos, que te
llaman y que mueren por tu causa.
PÍLADES
Oye también, ¡oh Agamenón!, pariente de mi padre,[297] mis
súplicas, y salva a tus hijos.
ORESTES
Maté a mi madre...
PÍLADES
Y yo esgrimí la espada.
ELECTRA
Y yo no te hice traición.
PÍLADES
Ensalza, pues, estas súplicas, y salva a tus hijos.
ORESTES
Que parte de vosotras guarde este camino, y otras esta senda que
viene hacia el palacio.
EL CORO
¿Por qué me ordenas esto, dime, ¡oh amada!?
ELECTRA
Ya te obedecemos.
ELECTRA
¿Cómo, pues? ¿No hay temor por esta parte? Dadme una respuesta
favorable, y decidme si nada se ve delante del palacio.
PRIMER SEMICORO
Por aquí todo va bien; pero observa por ahí, para que ninguno de
los hijos de Dánao se acerque por esta parte.
SEGUNDO SEMICORO
¿Cómo así? Las nuevas desdichas que nos atormentan bien merecen
tales lamentos.
HERMÍONE
No pronuncies palabras de mal agüero. ¿Hablas de nuevas
desdichas?
ELECTRA
¿No me matarás?
ORESTES
Nada temas.
EL FRIGIO
Pero la retractaré.
EL FRIGIO
Mira cómo se eleva el humo por los aires delante del palacio, y
anuncia algún nuevo suceso.
SEGUNDO SEMICORO
Encienden las antorchas como para abrasar la morada de Tántalo, y
no desisten de su sanguinario proyecto.
EL CORO
Los dioses acaban con los hombres, sí, acaban con ellos cuando
quieren. Su fuerza es incontrastable; un numen vengador ha derruido
ha derruido este palacio con sangrientos horrores, por habe
precipitado a Mírtilo de su carro. Pero veo a Menelao, que se acerca a
paso rápido, sabedor acaso de la desgracia que aquí ha ocurrido
Atridas, que dentro estáis, que las barras cierren pronto las puertas
Cruel es que el hombre, mimado por la fortuna, haga la guerra a
quienes, como a ti ahora, ¡oh Orestes!, se muestra adversa.
MENELAO
Traénme las execrables maldades cometidas por dos leones osados
pues no los debo llamar hombres. Me han dicho que no ha muerto m
esposa, sino que ha desaparecido del palacio, según cuenta un vano
rumor, hijo acaso del miedo del que me lo refirió; pero estas son
maquinaciones matricidas y un horrible sarcasmo. Que abra alguno e
palacio; mandaré a los esclavos que penetren en él a la fuerza para
arrancar al menos a mi hija del poder de estos hombres manchados de
sangre, y recobraré el cuerpo de mi desventurada esposa; si no, sus
osados asesinos morirán como ella a mis manos.
(Orestes, Pílades y Electra aparecen en lo alto del palacio. Orestes
amenaza con su espada el cuello de Hermíone. Pílades y Electra agitan
antorchas encendidas).
ORESTES
¿En cuál?
ORESTES
En la pelásgica Argos.
MENELAO
¿Quién te hablará?
ORESTES
Todo el que ame a su padre.
MENELAO
No tú.
ORESTES
No me agradan las malvadas.
MENELAO
¿Pero la matarás?
ORESTES
No lo dudarás mucho tiempo.
MENELAO
¿Qué?
ORESTES
¿O mataréis a mi hija?
ORESTES
Justamente.
MENELAO
¡Oh desventurada Helena![313]
ORESTES
Obedezcamos.
ORESTES
Y yo también. Propicia como la tuya es ya mi fortuna, ¡oh Menelao!
y propicios son también tus oráculos, ¡oh Apolo!
APOLO
ARGUMENTO
Desterrado Apolo del cielo por la muerte de los cíclopes, forjadores
de los rayos con que Zeus mató a su hijo Esculapio, se refugió en e
palacio de Admeto, rey de la Tesalia, cuyos ganados guardó, siendo
recompensado por él generosamente. Agradecido a sus beneficios le
salvó una vez la vida engañando a las Parcas, y obtuvo después e
consentimiento de Zeus para librarlo de la muerte, si encontraba algún
otro que quisiese morir por él. La empresa no era nada fácil, y hasta
los padres de Admeto, ya ancianos, rehusaron hacer por su hijo este
sacrificio. Sin embargo, Alcestis, su esposa, no vaciló en dar por él su
vida, aunque joven, bella y reina, y dejando dos hijos huérfanos.
La acción de la tragedia comienza poco antes de morir Alcestis, y
Apolo y la Muerte discuten sobre este suceso inminente. Ambos
esposos se despiden uno de otro con la mayor ternura, y ella muere
después muy llorada de todos sus servidores, que la adoraban por su
bondad. Admeto se dispone a celebrar sus funerales con gran pompa y
aparato, cuando primero se presenta su padre, que trae dones
mortuorios para la difunta, dando origen a un altercado nada edificante
entre ambos, y después Heracles pidiendo hospitalidad, puesto que
ignoraba la desdicha de su amigo el rey de los tesalios. El hijo de
Alcmena, que ve impresas las señales del más acerbo dolor en el rostro
de su huésped, le pregunta la causa con interés, y a pesar de su
insistencia, nada averigua de positivo, porque Admeto desea
hospedarlo, y si le descubre la verdad, se expone a que se ausente en
busca de otro albergue. Sus réplicas anfibológicas inducen a Heracles a
aceptar el hospedaje que se le ofrece, y en su consecuencia penetra en
la hospedería aislada del palacio, y a fuer de buen gastrónomo se
abandona por completo a los placeres de la mesa, y come y bebe de lo
lindo, coronado de mirto y entonando escandalosos y báquicos
cantares. El esclavo que le sirve, no pudiendo disimular su pena, excita
las sospechas del héroe, que llega al fin a saberlo lodo. Apodérase
entonces de sus armas, y escondiéndose junto al túmulo de Alcestis
sorprende a Hades cuando venía a gustar las fúnebres ofrendas, y le
obliga a soltar su presa, devolviendo la vida a la difunta, y llevándola
cubierta con un velo al palacio de su esposo. Empéñase en persuadir a
este que la guarde hasta su vuelta, pretextando que la ha ganado
legítimamente en unos juegos, en que se ofrecía por premio a
vencedor, y tanto le importuna, que Admeto consiente en hacer este
nuevo sacrificio por su amigo, quien le descubre al cabo que aquella
mujer confiada a su custodia es su propia esposa.
Fácil es de ver que esta tragedia, así por la sencillez de su plan
como por la moralidad que resulta de la acción, es una de las mejores
de Eurípides, acercándose a las de Sófocles. Apolo, agradecido a los
beneficios de Admeto, premia su virtud sin proponerse la satisfacción
de ninguna pasión mezquina e indigna de los dioses; Admeto obtiene
merecida recompensa por la generosa hospitalidad que dispensa a
Apolo y a su amigo Heracles; Alcestis resucita en justo galardón de
sacrificio que hace por su esposo; y Heracles, correspondiendo a la
amistad de Admeto, paga con usura la hospitalidad que de él recibe. La
diferente condición social de la mujer entre nosotros, comparada con la
que tenía en Grecia, y el resto de sentimientos caballerescos que
todavía conservamos, nos hacen mirar con desagrado la aquiescencia
del rey de los tesalios al sacrificio de su esposa, y vituperar el egoísmo
de un soberano que, por amor a la vida, consiente en perder la mejo
de las mujeres; pero debemos advertir que las costumbres griegas eran
muy diversas de las nuestras, y que, suponiendo su existencia, no
aparece su acción tan baja como antes. Faltando Admeto, sus hijos
quedan entregados a Alcestis en edad temprana, y expuestos a todas
las violencias e iniquidades consiguientes al elevado rango que en su
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com