100% found this document useful (3 votes)
27 views

Get Practical Graph Structures in SQL Server and Azure SQL: Enabling Deeper Insights Using Highly Connected Data 1st Edition Louis Davidson free all chapters

Enabling

Uploaded by

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

Get Practical Graph Structures in SQL Server and Azure SQL: Enabling Deeper Insights Using Highly Connected Data 1st Edition Louis Davidson free all chapters

Enabling

Uploaded by

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

Download the full version of the ebook at

https://ebookmass.com

Practical Graph Structures in SQL Server and


Azure SQL: Enabling Deeper Insights Using
Highly Connected Data 1st Edition Louis
Davidson
https://ebookmass.com/product/practical-graph-
structures-in-sql-server-and-azure-sql-enabling-
deeper-insights-using-highly-connected-data-1st-
edition-louis-davidson/

Explore and download more ebook at https://ebookmass.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Practical Graph Structures in SQL Server and Azure SQL:


Enabling Deeper Insights Using Highly Connected Data 1st
Edition Louis Davidson
https://ebookmass.com/product/practical-graph-structures-in-sql-
server-and-azure-sql-enabling-deeper-insights-using-highly-connected-
data-1st-edition-louis-davidson/
testbankdeal.com

Pro SQL Server 2022 Wait Statistics: A Practical Guide to


Analyzing Performance in SQL Server and Azure SQL
Database, 3rd Edition Thomas Larock
https://ebookmass.com/product/pro-sql-server-2022-wait-statistics-a-
practical-guide-to-analyzing-performance-in-sql-server-and-azure-sql-
database-3rd-edition-thomas-larock/
testbankdeal.com

Pro SQL Server 2022 Wait Statistics: A Practical Guide to


Analyzing Performance in SQL Server and Azure SQL
Database, 3rd Edition Thomas Larock
https://ebookmass.com/product/pro-sql-server-2022-wait-statistics-a-
practical-guide-to-analyzing-performance-in-sql-server-and-azure-sql-
database-3rd-edition-thomas-larock-2/
testbankdeal.com

SQL Server Analytical Toolkit: Using Windowing,


Analytical, Ranking, and Aggregate Functions for Data and
Statistical Analysis 1st Edition Angelo Bobak
https://ebookmass.com/product/sql-server-analytical-toolkit-using-
windowing-analytical-ranking-and-aggregate-functions-for-data-and-
statistical-analysis-1st-edition-angelo-bobak/
testbankdeal.com
Expert Performance Indexing in Azure SQL and SQL Server
2022, Fourth Edition: Toward Faster Results and Lower
Maintenance Both on Premises and in the Cloud Edward
Pollack
https://ebookmass.com/product/expert-performance-indexing-in-azure-
sql-and-sql-server-2022-fourth-edition-toward-faster-results-and-
lower-maintenance-both-on-premises-and-in-the-cloud-edward-pollack/
testbankdeal.com

Getting Started with SQL and Databases: Managing and


Manipulating Data with SQL 1st Edition Mark Simon

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

testbankdeal.com

SQL Server 2022 Administration Inside Out 1st Edition


Randolph West

https://ebookmass.com/product/sql-server-2022-administration-inside-
out-1st-edition-randolph-west/

testbankdeal.com

Azure SQL Hyperscale Revealed: High-performance Scalable


Solutions for Critical Data Workloads 1st Edition Zoran
Bara■
https://ebookmass.com/product/azure-sql-hyperscale-revealed-high-
performance-scalable-solutions-for-critical-data-workloads-1st-
edition-zoran-barac-2/
testbankdeal.com

Azure SQL Hyperscale Revealed: High-performance Scalable


Solutions for Critical Data Workloads 1st Edition Zoran
Bara■
https://ebookmass.com/product/azure-sql-hyperscale-revealed-high-
performance-scalable-solutions-for-critical-data-workloads-1st-
edition-zoran-barac/
testbankdeal.com
Practical Graph
Structures in
SQL Server and
Azure SQL
Enabling Deeper Insights Using
Highly Connected Data

Louis Davidson
Practical Graph
Structures in SQL Server
and Azure SQL
Enabling Deeper Insights Using
Highly Connected Data

Louis Davidson
Practical Graph Structures in SQL Server and Azure SQL: Enabling Deeper Insights
Using Highly Connected Data

Louis Davidson
Cleveland, TN, USA

ISBN-13 (pbk): 978-1-4842-9458-1 ISBN-13 (electronic): 978-1-4842-9459-8


https://doi.org/10.1007/978-1-4842-9459-8

Copyright © 2023 by Louis Davidson


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: Jonathan Gennick
Development Editor: Laura Berendson
Editorial Project Manager: Shaul Elson
Copy Editor: Mary Behr
Cover image by Garry Killian from Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media LLC, 1 New York Plaza, Suite
4600, New York, NY 10004. 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 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 (https://github.com/Apress). For more detailed information, please visit www.apress.
com/source-code.
Printed on acid-free paper
To Val, what a life we have had so far… here’s to more of it.
Table of Contents
About the Author����������������������������������������������������������������������������������������������������� ix

About the Technical Reviewer��������������������������������������������������������������������������������� xi


Acknowledgments������������������������������������������������������������������������������������������������� xiii

Preface��������������������������������������������������������������������������������������������������������������������xv

Chapter 1: Introduction to Graphs���������������������������������������������������������������������������� 1


Graph Fundamentals��������������������������������������������������������������������������������������������������������������������� 3
Definition��������������������������������������������������������������������������������������������������������������������������������� 4
Summary������������������������������������������������������������������������������������������������������������������������������������ 15

Chapter 2: Data Structures and Algorithms����������������������������������������������������������� 17


Basic Implementation����������������������������������������������������������������������������������������������������������������� 17
Acyclic Graphs���������������������������������������������������������������������������������������������������������������������������� 19
Trees�������������������������������������������������������������������������������������������������������������������������������������� 22
Other Acyclic Graphs������������������������������������������������������������������������������������������������������������� 27
Cyclic Graphs������������������������������������������������������������������������������������������������������������������������������ 30
Non-Directed Graphs������������������������������������������������������������������������������������������������������������� 35
Summary������������������������������������������������������������������������������������������������������������������������������������ 36

Chapter 3: SQL Graph Table Basics������������������������������������������������������������������������ 39


Object Creation��������������������������������������������������������������������������������������������������������������������������� 40
Creating Data������������������������������������������������������������������������������������������������������������������������������ 43
Querying Data����������������������������������������������������������������������������������������������������������������������������� 48
Node-to-Node Querying��������������������������������������������������������������������������������������������������������� 48
Traversing Variable Level Paths��������������������������������������������������������������������������������������������� 59
Summary������������������������������������������������������������������������������������������������������������������������������������ 75

v
Table of Contents

Chapter 4: SQL Graph Tables: Extended Topics������������������������������������������������������� 77


Advanced Data Creation Techniques������������������������������������������������������������������������������������������� 77
Building an Interface Layer��������������������������������������������������������������������������������������������������� 78
Loading Data Using Composable JSON Tags������������������������������������������������������������������������� 87
Heterogenous Queries���������������������������������������������������������������������������������������������������������������� 93
Integrity Constraints and Indexes��������������������������������������������������������������������������������������������� 101
Edge Constraint������������������������������������������������������������������������������������������������������������������� 101
Uniqueness Constraints (and Indexes)�������������������������������������������������������������������������������� 107
Additional Constraints��������������������������������������������������������������������������������������������������������� 111
Metadata Roundup�������������������������������������������������������������������������������������������������������������������� 115
List Graph Objects in the Database������������������������������������������������������������������������������������� 115
Types of Graph Columns������������������������������������������������������������������������������������������������������ 116
Tools for Fetching Graph Information���������������������������������������������������������������������������������� 117
Summary���������������������������������������������������������������������������������������������������������������������������������� 118

Chapter 5: Tree Data Structures��������������������������������������������������������������������������� 121


Creating the Data Structures���������������������������������������������������������������������������������������������������� 122
Base Table Structures���������������������������������������������������������������������������������������������������������� 122
Demo Sales Structure���������������������������������������������������������������������������������������������������������� 125
Essential Tree Maintenance Code��������������������������������������������������������������������������������������������� 127
Code To Create New Nodes������������������������������������������������������������������������������������������������� 128
Reparenting Nodes�������������������������������������������������������������������������������������������������������������� 138
Deleting a Node������������������������������������������������������������������������������������������������������������������� 141
Tree Output Code���������������������������������������������������������������������������������������������������������������������� 148
Returning Part of the Tree���������������������������������������������������������������������������������������������������� 149
Determining If a Child Node Exists�������������������������������������������������������������������������������������� 151
Aggregating Child Activity at Every Level���������������������������������������������������������������������������� 154
Summary���������������������������������������������������������������������������������������������������������������������������������� 162

vi
Table of Contents

Chapter 6: Tree Structures, Algorithms, and Performance����������������������������������� 163


Alternative Tree Implementation����������������������������������������������������������������������������������������������� 164
Path Technique�������������������������������������������������������������������������������������������������������������������� 166
Helper Table������������������������������������������������������������������������������������������������������������������������� 175
Performance Comparison��������������������������������������������������������������������������������������������������������� 186
Summary���������������������������������������������������������������������������������������������������������������������������������� 189

Chapter 7: Other Directed Acyclic Graphs������������������������������������������������������������ 191


The Problem Set������������������������������������������������������������������������������������������������������������������������ 191
The Example����������������������������������������������������������������������������������������������������������������������������� 193
Determining If a Part Is Used in a Build������������������������������������������������������������������������������������ 197
Picking Items for a Build����������������������������������������������������������������������������������������������������������� 200
Printing Out the Parts List for a Build���������������������������������������������������������������������������������������� 201
Summary���������������������������������������������������������������������������������������������������������������������������������� 206

Chapter 8: A Graph For Testing����������������������������������������������������������������������������� 209


The Example����������������������������������������������������������������������������������������������������������������������������� 209
Creating the Tables�������������������������������������������������������������������������������������������������������������� 210
Loading the Data����������������������������������������������������������������������������������������������������������������� 212
The Queries������������������������������������������������������������������������������������������������������������������������� 215
Performance Tuning Results����������������������������������������������������������������������������������������������������� 228
Performance Tuning Roundup��������������������������������������������������������������������������������������������������� 231
Test�������������������������������������������������������������������������������������������������������������������������������������� 231
Index the Internal Columns�������������������������������������������������������������������������������������������������� 231
Employ a Maximum Degree of Parallelism of One�������������������������������������������������������������� 232
Consider Breaking Up Some Queries����������������������������������������������������������������������������������� 232
The End (or Is It the Beginning?)����������������������������������������������������������������������������������������������� 233

Index��������������������������������������������������������������������������������������������������������������������� 235

vii
About the Author
Louis Davidson has been working with databases for
more than 25 years as a corporate database developer
and architect. He is now the editor for the Redgate Simple
Talk website. He has been a Microsoft MVP for 18 years. In
addition to this book on graphs in SQL Server, he has written
six editions of his general-purpose SQL Server database
design book (Apress) and has worked on multiple other
book projects over the years.
Louis has been active in speaking about database design and implementation at many
conferences over the past 25 years, including SQL PASS, SQL Rally, SQL Saturday events,
CA World, Music City Data, and the devLink Technical Conference. He has a bachelor’s
degree in computer science from the University of Tennessee at Chattanooga. For more
information, please visit his website at drsql.org.

ix
About the Technical Reviewer
Kathi Kellenberger is a Customer Success Engineer at
Redgate and a Data Platform MVP. She has worked with
SQL Server since 1998 and has authored, co-authored, or
tech reviewed over 20 technical books. Kathi is a longtime
volunteer at LaunchCode in St. Louis where she has taught
T-SQL in the LaunchCode Women + program. When Kathi
isn’t working, she enjoys spending time with family and
friends, cycling, singing, and climbing the stairs of tall
buildings.

xi
Visit https://ebookmass.com
now to explore a rich
collection of eBooks and enjoy
exciting offers!
Acknowledgments
My wife, for suffering through yet another long and painful book writing process.
The Microsoft MVP Program for all the connections it has provided me to meet
wonderful, bizarrely smart people for 18 years. And my lead, Rie Merritt, for all she has
done for me through the years; amazing how we met so many years ago. Just meeting
Bob Ward and Conor Cunningham is thrill enough, and there have been hundreds
besides them.
Shreya Verma and Arvind Shyamsundar for their help over the past few years as I
attempted to do crazy things with the graph objects on my local personal computer.
Dr. David Rosenstein, who first got me interested in graphs in relational structures so
many years ago. Paul Nielsen for the talks we had on graph structures.
Kathi Kellenberger for tech editing this book. I appreciate the hard work!
All the doctors/medical professionals who kept me alive and kicking these past few
years. (If you want to know more, just ask, if you have a while to talk. There is a reason
this book took me over two years to write.)
My coworkers at CBN whom I left during the writing of this book. I hope the graph
objects I left you with are serving you nicely.
My new coworkers at Redgate. I have been a friend of Redgate (as well as a member
of Friends of Redgate) for many years, writing for them. My new manager and teammates
have been nothing but awesome.
Amber Davis, for giving me the chance to be a Dollywood Insider. Obviously being
a Dollywood insider has little to do with this book, but I just wanted to say it again
(which she may never see!) as I am writing the acknowledgements in the Dollywood
Dreammore lobby. I learned a lot from her that has been useful writing some of this book
and in my new job at Redgate as Simple-Talk editor.

xiii
Preface
I started working on my first book 23 years ago. It was on relational database design.
I had learned a little about graphs at that point from a class I took by Dr. David
Rozenshtein (his 1997 book The Essence of SQL : A Guide to Learning Most of SQL in the
Least Amount of Time was essential). His class was very influential and taught me a lot
about how to think about SQL problems. This was a really long time ago (clearly), but
in that same class, one of the sections was on trees in SQL Server. I was hooked on the
subject.
In my 2012 edition of my database design book, I started to include hierarchies
as one of the topics. In my latest book, that came out after SQL Server 2019 arrived, I
promised a book of SQL Graph. This book in your hands is the answer to that challenge.
This is my first programming-based book in many years. Usually I am more
interested in helping you shape a design, but in this case, I want to show you the
mechanics of building a graph database solution using SQL Server and leave it more
to you to decide what to do with it from there. Part of this is due to the newness and
relative complexity of the topic, but also because graphs are meant to be very flexible
structures…way more flexible than the standard relational databases.
The chapters of the book are as follows:

• Chapter 1: What a graph is and ways graphs can be used. I touch on


some of the underpinnings of what makes a graph a graph and a taste
of the theory that mathematicians use to describe and work with
graph data structures.

• Chapter 2: How graphs are implemented and the algorithms that are
used to process them. While the basic structure of the graph is really
simple, there is some value to understanding how graph structures
are built in coding and having some idea of what you will see in the
rest of the book.

xv
Preface

• Chapter 3: The syntax that Microsoft has implemented for use with
graph data stored in SQL Server tables is similar to what you probably
already know from working with relational tables, but it is so much
more. In this chapter, I teach you how to use the syntax provided by
Microsoft to query graph tables in interesting ways.

• Chapter 4: Whereas in Chapter 3 I showed basic query techniques, in


this chapter I show methods that can help you load and protect the
integrity of the data in your SQL Graph tables.

• Chapter 5: A tree structure built using SQL Graph objects, including


code to load and manipulate those nodes in ways that you will need
when building production systems. In this chapter, you explore
the code to create and manage a tree in SQL Server, along with an
example of how it all works.

• Chapter 6: In this chapter, I dig into performance. You’ll examine


a new method of implementing a tree for comparison to the SQL
Graph objects and build some objects you can use to write queries
to report on data in your trees that operate faster. You will then build
some large, random data sets and compare how these methods
perform with certain larger sized data sets.

• Chapter 7: The goal of this chapter is to build a data structure that


can show some of the concerns with working with directed graphs
that are not trees. You will build a fairly simple bill of materials data
structure to demonstrate the techniques you will need when you are
working with these structures, which are similar to trees but still quite
different.

• Chapter 8: In this chapter, you will do some querying of larger data


sets in SQL Server’s graph objects. To do this, you will implement
a graph structure and data generation tools to try on large sets of
data to match your expected needs. Finally, you will explore a set of
performance tips for handling graph objects.

xvi
Preface

SQL Server’s relational engine may never be acceptable as a complete replacement


for a specific graph database system like CosmosDB, but even in its relative infancy with
just a few iterations complete in the SQL Server lifecycle, it has become a nice way to
extend your data structures inside existing relational data structures quickly and easily.
You can find the downloads in the book in two locations. First, on Apress’s website
you will find the original code for this book and any errata that is reported: ­https://
github.com/Apress/practical-graph-structures. Second, at https://github.com/
drsqlgithub/GraphBook1 you will find that code plus any new code and projects I create
that pertain to learning graphs until I start working on a second edition of this book
someday.
If you have any direct questions about the content, send email to [email protected]
and I will do what I can.

xvii
CHAPTER 1

Introduction to Graphs
With great power comes great responsibility.
--Voltaire (and Spider-Man’s Uncle Ben)

At its core, a graph data structure is simply a model representing the connection of one
thing to one other thing and then those things to even more other things. Essentially a
graph database formalizes a database based on many-to-many relationships as the core
relationship.
Everyone who has ever modeled a relational database will either have modeled
a graph purposefully or inadvertently because many-to-many relationships begin to
appear as you add more concepts to your data model. The vast difference you will see is
that relational implementations, ideally, are rigidly modeled.
The term frequently used to decide whether to model a many-to-many relationship
in a relational database or a graph structure is whether the data is highly connected.
With a graph database structure, you can connect many tables to many other tables
and query that structure in a different (yet quite similar) manner to how you query a
relational database.
There are many examples of graphs, but some of the most common examples you
probably hear about are

• Social networks, where you record the relationship from one person
to another

• Suggestion processing systems like online retailers use to record the


relationship between a person and the products they have looked at
and ordered and how that matches up with other people who have
similar interests

• Manager-employee relationships where the employee has a manager


who also has a manager who is likely managed by someone else

1
© Louis Davidson 2023
L. Davidson, Practical Graph Structures in SQL Server and Azure SQL,
https://doi.org/10.1007/978-1-4842-9459-8_1
Chapter 1 Introduction to Graphs

With this information, you can discover interesting things about an object based on
its relationships and similarity to relationships other entities have.
Possibly the most famous graph that most people will have heard of is the basis of the
parlor game “Six Degrees of Kevin Bacon.” This game suggests that everyone is no more
than six connections away from anyone else, including Kevin Bacon (and not just that
your favorite breakfast meat is bacon.)
The fact that graphs are very natural data structures does not make them easy
to work with. Because they are less rigid data structures than relational tables, the
flexibility makes them quite complex to work with (certainly in the database engine).
Graph objects can represent a very messy reality, and the more complex the data you
are modeling, the more complicated it is to work with. Of course, the reward for that
complexity is the solutions you create are often quite tremendous.
Like many computer science topics, graphs are also a fundamental mathematical
concept. Some of the insights you can get from the math of graphs will help once we
start analyzing data. So, to begin this book on graphs, I will provide a very cursory look
at some mathematical concepts as I define what a graph is and how it can be used in
software.
Note that the concepts in this chapter were gleaned from many resources and are
generally common knowledge. However, when I was searching for resources to read
for an introduction to the concepts of graphs, including mathematical proofs (none of
which will come up in this book, so no worries!) of such concepts, one was Introduction
to Graph Theory by Richard J. Trudeau from Dover Publications in 1993. It is far deeper
than this chapter and definitely more than you need to learn to code with SQL Server’s
graph database extensions, and mathematical proofs have always been my Kryptonite!
However, I highly recommend this as a place to ascend to the next level beyond what I
will show you.
This chapter will be a quick, high-level overview of the many topics you will find
in this book and many other sources, plus ideas you may wish to use in the graph table
objects I will cover once you start building objects. The book itself will be mostly focused
on very practical applications and how to write certain types of code, but I found that
knowing some of the graph fundamentals really helped me to envision what I was
attempting to accomplish.

2
Chapter 1 Introduction to Graphs

Graph Fundamentals
While most readers will have the explicit goal of applying a graph to a specific problem
they are trying to solve, it is best to start at the beginning and discuss what a graph is
in the pure sense. (If you don’t care, you can skip to Chapter 3 where the T-SQL code
starts!) Going through the fundamentals will help you free your mind from preconceived
notions. Perhaps, more importantly, you can ignore the limitations of the tools and
specific problem sets you may wish to solve and just think about the whole problem set.
In math, there are the concepts of “pure” math and “applied” math. Pure math is
math for math’s sake. It is there to ask, “what can be done with a construct?” without
asking the limiting questions of, “is this helpful code to solve my problem or, even more
importantly, any problem?” Applied math is more or less the sort of thing we typical
computer architects/programmers are typically interested in since we have a problem
and want to find something to help us with that problem (and immediately so). Most
of the time, solutions are only interesting if they can solve the specific problems we
currently know about and have a manager riding on our back.
However, I always prefer to start just trying to see what I can accomplish with a new
tool before getting my hands dirty (metaphorically, of course; as a programmer, my
hands never get dirty at work unless the day’s snack includes chocolate).
Some of the things I will discuss will then be familiar in understanding what
we might do when looking for patterns in the data and eventually translating into
algorithms. Some designs may not be realistically possible due to current computing
limitations in SQL Server (or any graph database platform) or reasonable hardware
limitations at the time of writing in 2023. Having written my first book in 2000, it
astounds me how different this statement feels to me 23 years later sitting here with a
computer on my desk that has more power that medium to large corporations were
running on when I first wrote T-SQL.
In one of my sample databases you can download, I have millions of rows in just one
table, and I can process reasonable queries on my desktop computer in mere minutes.
Limitations always exist, but there are fewer and fewer limitations for every generation of
computer architecture that passes.
My goal here in this first chapter (and to a large extent, the second chapter) is to
simply introduce some of the terms and concepts around graphs to help you understand
how graphs are shaped and, eventually, processed.

3
Chapter 1 Introduction to Graphs

Definition
Graphs are based on two primary data structures: nodes (or in math terms, vertices),
and edges. Nodes represent a thing that one might care about, much like a table in a
relational database. Edges establish a connection between exactly one or two nodes
(when the node count is one, it means the node is related to itself.) A graph is defined as
being a set of nodes and a set of edges.
In a graph database, a node is like most any table with attributes describing what
the node represents. The edge is analogous to a many-to-many relationship table with
at least attributes to represent the node that the relationship is from and which it is
to. You will see that two major things set these new concepts apart from a relational
implementation.
First, the from and the to in an edge generally can be from any node object. Whereas
a relational table column used to reference another table value communicates that it is
a foreign key from Table X and nothing else, the from and to attributes of an edge can be
from multiple different node types if you so desire.

Tip I am fully aware that you can put any value into a column, so every foreign
key value in a column needn’t come from the same table. But that is not how it
should be done because data where a column can mean multiple things is very
confusing in a relational table. Graph structures work very similar to how relational
tables work. Still, they have special properties that allow two rows to contain data
from multiple sources without confusing the user/engine.

Second, to make use of these flexible structures, a special set of operations is enabled in
a graph engine, allowing easier access to the meaning of the relationships than we can get
using SQL. More detail on these operations and the basic algorithms are in Chapters 2 and 3.
For the first example, consider the simple graph represented in Figure 1-1—two
nodes connected by a single edge. If the type of node is important, it will be indicated
using different shapes.

4
Chapter 1 Introduction to Graphs

Figure 1-1. Simple graph

When diagraming a graph, edges may also have a property of direction. The direction
indicates that the relationship is not reciprocal. For example, consider Figure 1-2.

Figure 1-2. Simple directed graph

In this graph, N1 connects to N2, but N2 is not connected to N1. This is analogous to
a social media relationship such as when I follow Paul McCartney, but Paul McCartney
doesn’t follow me! It will often be very important to understand the value of the direction
because of the unbalanced nature of some relationships. Mr. McCartney doesn’t all of
the sudden wish to get any communication about where I am speaking at a conference,
but I wish to be informed of his concerts and new music being released.
In SQL Graph, and other graph products, edges are almost always directed. This will
become important later but will only complicate our discussion of graphs concepts in
general, so to start with, let’s ignore the directedness of the edges.
In my first example graph in Figure 1-1, I have two nodes and a single edge. This is a
very simple graph, but it is not the simplest graph. The simplest graph is a graph with 0
edges and 0 nodes, otherwise referred to as the NULL graph. You can also have a graph
with a single node and no edges, and a single node with a single edge, and so on. (You
can’t have an edge without a node.)
Just like modeling a relational database, there is an inherent danger in thinking of a
graph as a drawing and not a complex data structure. Consider a graph with the nodes
and edges seen in Figure 1-3.

5
Visit https://ebookmass.com
now to explore a rich
collection of eBooks and enjoy
exciting offers!
Chapter 1 Introduction to Graphs

Figure 1-3. Graph with four edges and four nodes

This graph could be expressed as sets of nodes and edges in the following manner:
Nodes: {N1,N2,N3,N4}; Edges: {E1:{N1,N2}; E2:{N2,N4}; E3:{N3,N4}; E4:{N1,N3}}
By definition, all nodes and edges must be distinct, much like a table requires
distinct rows. And just like a table, the order of the items in the sets has no importance.
The following graph is the same as diagrammed and as defined prior to this paragraph:
Nodes: {N2,N3,N1,N4}; Edges: {E2:{N2,N4}; E1:{N1,N2}; E4:{N1,N3}; E3:{N3,N4}}
When drawing a graph as an image, there is a very similar consideration. Every
programmer with any skill has frequented a white board to draw a diagram of a
structure. If you were to draw a shape of a circle, a triangle, and a square on the white
board, instinctively you would believe them to be different things. Even if you drew a
rectangle, square, and a rhombus (all shapes with four sides) you would not think they
were the same.
But, in graph terms (just like when diagramming tables), the two graphs in Figure 1-4
are the same as each other and the graph in Figure 1-3, in which they are considered
“equal.”

6
Chapter 1 Introduction to Graphs

Figure 1-4. Two identical graph structures

The two graph diagrams in Figure 1-4 are copies of the same graph. The next concept
is related, in that we will look at graphs with the same shape but different nodes. When
a graph has the same node and edge shape (meaning the same nodes and edges, not
diagram shape,) the graphs are referred to as being isomorphic graphs. For example,
the two graphs in Figure 1-5 are not equal but they are isomorphic because they have the
same shape in their set of data (regardless of whether you draw them as a square or not).

Figure 1-5. Two isomorphic graph structures

This concept of isomorphism will be, if not actually referred to using the exact term,
interesting in your usage of graphs on occasion. Consider the set of nodes in Figure 1-6.

7
Random documents with unrelated
content Scribd suggests to you:
[38] Defrauding errand boys, or porters, of their load, by false
pretences of various kinds.
[39] Obtaining money from charitable persons, by some
fictitious statement of distress.
[40] Obtaining goods from a tradesman by false pretences, or
by a forged order in writing.
[41] Throwing snuff in the eyes of a shopkeeper, and then
running off with such money or valuable property as may lay
within reach.
[42] See the evidence of William Alderman.
[43] A short confinement is here meant.
[44] The settlement or camp at Hawkesbury, now called, the
town of Windsor.
[45] Governor King was a post-captain in the navy, and
principal commander of the Buffalo, having a second (acting)
captain under him. The Buffalo had been stationed in N.S.W. ever
since the year 1802, and was now relieved by the Porpoise, in
which ship Governor Bligh arrived.
[46] Now Surveyor-General of New South Wales.

MEMOIRS OF JAMES HARDY


VAUX.
IN TWO VOLUMES. VOLUME II.

MEMOIRS
OF
JAMES HARDY VAUX.
WRITTEN BY HIMSELF.

IN TWO VOLUMES.

VOL. II.

LONDON:
PRINTED BY W. CLOWES, NORTHUMBERLAND-COURT, STRAND.
AND SOLD BY
ALL RESPECTABLE BOOKSELLERS.
1819.
CONTENTS
OF

THE SECOND VOLUME.

CHAPTER I.
I arrive in London—A sudden alarm—Visit my mother and sisters—
Set out for S⸺shire—Interview with my grandfather—Return
to town—A lucky hit on the road—Obtain a situation in the
Crown-Office, page 1.
CHAP. II.
Quit the Crown-Office, and engage as reader in a printing-office—
Determine to live a strictly honest life—Meet with an old
acquaintance who laughs me out of my resolution—Give up all
thoughts of servitude, and become a professed thief, page 13.

CHAP. III.
Various modes of obtaining money—My regular course of life, when
disengaged from my vicious companions—Meet with an
amiable girl, like myself the child of misfortune—We cohabit
together—Our mutual happiness, page 20.

CHAP. IV.
Adventures in the course of my profligate career—Motives which
induce me to marry my companion—Her exemplary behaviour
—A family misfortune, page 29.
CHAP. V.
Adventure of the silver snuff-box—Its consequences.—My narrow
escape from transportation, which I have since had reason to
regret, page 35.
CHAP. VI.
Visit Mr. Bilger, an eminent jeweller—His politeness, and the return
I made for it—Perfidy of a pawnbroker—Obliged to decamp
with precipitation, page 52.

CHAP. VII.
Take a house in St. George’s Fields—Stay at home for several
weeks—At length I venture out in quest of money—My
imprudent obstinacy in entering a house of ill repute, against
the advice and entreaties of my wife—I am taken in custody
and carried to the watch-house.—Distress of my wife on the
occasion, page 71.

CHAP. VIII.
Discover that I have been betrayed—Examined at Bow-street, and
committed for trial—Sent to Newgate—Prepare for my defence
—My trial and conviction, page 83.

CHAP. IX.
Account of my companion and fellow-sufferer in the condemned
cells—His unhappy fate—I receive sentence of death—Am
reprieved, and soon afterwards sent on board the hulks—Some
account of those receptacles of human misery, page 97.

CHAP. X.
I embark a second time for New South Wales—Indulgently treated
by the Captain—My employment during the voyage—Arrive at
Port Jackson, after an absence of four years—My reception
from Governor Macquarrie—Assigned by lot to a settler—His
brutal treatment of me—I find means to quit his service, and
return to Sydney, page 113.

CHAP. XI.
Appointed an overseer—Determine to reform my life, and become a
new man—All my good intentions rendered unavailing by an
unforeseen and unavoidable misfortune—I become a victim to
prejudice, and the depravity of a youth in years, but a veteran
in iniquity—I am banished to the coal-river, page 122.

CHAP. XII.
Return to head-quarters, after an exile of two years—Renew my
vows of rectitude, to which I strictly adhere—Proposal made
me to obtain my liberty—I make the attempt—Its failure, and
the consequent punishment inflicted on me—Conclusion, page
137.
MEMOIRS
OF
JAMES HARDY VAUX.
CHAPTER I.
I arrive in London.—A sudden Alarm.—Visit my Mother and Sisters. Set out for S
⸺shire.—Interview with my Grandfather.—Return to Town.—A lucky Hit on
the Road.—Obtain a Situation in the Crown-Office.

About four miles from Gosport, is a place called Fareham, where is


a gate, through which on the coach passing, I had always
understood that the passengers were subject to an overhaul, as the
sailors term it. I was, therefore, somewhat alarmed during this part
of my journey. I felt confident, however, that I could give a good
account of myself, had I been questioned; but to my great joy, on
our approach, the gate was thrown open, and the coach passed
without stopping. I now felt extremely cold, and my dress being thin,
I suffered much during the night. In order to counteract the effects
of the frost, I fortified myself with a good dram of brandy at every
stage, and the ensuing morning proving delightfully fine, I at length
found both my animal and mental spirits revive, and my heart beat
high with expectation of the happiness I anticipated. About eight
o’clock I was gratified with a sight of Hyde Park Corner; and I leave
the reader to imagine what transports I felt at the difference
between my then situation and that from which I had so recently
and happily emerged. On my ascending the coach at Gosport, I had
placed myself on the roof between two men who had the
appearance of country farmers, and I maintained that situation
throughout the night, by which indeed I was something benefited,
for they had both good great-coats, and we sitting rather crowded, I
was warmer than I should otherwise have been. On the coach
stopping at the Gloucester Coffee-house, Piccadilly, I expressed my
intention to alight and walk; the two farmers had the same
inclination, and I observed, that if they were going my way, I should
be glad of their company. They answered they were strangers in
town, and their only object was to find out the inn from which the
Yorkshire coach set out, as they were about proceeding to that
county immediately. I replied, I was myself almost a stranger to
those matters, but I fancied the inn lay in the way I was going, and
that I would with pleasure conduct them to it. We accordingly set
forwards, and walked through Piccadilly, the Haymarket, Strand, &c.,
until we came to Fetter-lane; and arriving at the White Horse, I was,
I found, right in my conjecture, for the York coach was among the
number of those advertised in large characters on each side the
gateway of the inn. I introduced them to the coach-office, where
they took places for the ensuing evening; and, as my night’s ride
had brought me to an appetite, I proposed (before going to my
mother’s, whose lodgings were close at hand,) that we should
breakfast together; to which they assenting, I conducted them to
the coffee-room, and calling the waiter, ordered tea, coffee, and
plenty of muffins with all possible speed. We had nearly concluded
our meal, and I had just bespoke a morning paper from the waiter,
when the room beginning to fill, several gentlemen entered, and
passed the table at which we sat, proceeding to the upper end of
the room. At that moment a voice struck my ear, which almost
petrified me with fear and astonishment, for I felt persuaded at the
time that it was that of Mr. Oxley himself, exclaiming, “Waiter, see
that portmanteau of mine brought in.” On hearing these words, I
almost dropped the tea-cup from my hand, and on the impulse of
the moment, quitted my seat, and hastily left the room; nor did I
stop for a moment’s reflection until I had crossed Holborn, and
found myself at the corner of Gray’s-Inn-Lane. Then, however,
conceiving I was out of danger, I endeavoured to rally my spirits,
and to persuade myself that I must have been mistaken, as it was
highly improbable that Mr. Oxley, whom I had left on board the
Buffalo, should so suddenly have arrived in town, and particularly at
the White Horse, no Portsmouth or Gosport coach setting up there.
However, Mr. Oxley’s voice and manner of speaking being a little
remarkable, I was so far in doubt that I determined not to return.
What opinion the countrymen must form of me, I know not; it is
likely they would impute my unmannerly departure to a design of
avoiding payment of the reckoning. I have since ascertained that I
was mistaken in my conjecture, for Mr. Oxley did not quit the ship
until several days afterwards.
I now repaired to Middle-Row, and inquiring for my mother, was
ushered up stairs, where I found her and my two sisters pretty
comfortably situated in a genteel first floor, which they hired ready
furnished. They all expressed great joy at seeing me. My mother
appeared to be in a declining state, but my sisters were much
improved, and really very fine girls. I understood that the whole
family were supported by the industry of the latter, who worked
incessantly at their needle, being excellent proficients in fancy-work,
which they obtained from various shops. Having explained to my
mother the particulars of my situation, and the risk I had incurred by
my desertion; and recollecting that I had inconsiderately suffered
her letter, in which was her address, to be seen by several persons
on board the Buffalo, it occurred to me that Captain Houston might
possibly come to the knowledge of that particular, the consequence
of which might be fatal to me. It was the opinion of my mother, that
I should on that account, absent myself from town for a few weeks,
until the affair was blown over, and my mother advised that I should
go down to my relations in S⸺shire. I accordingly the next day set
out by the coach, an aunt of mine who was in good circumstances,
supplying me with the needful. On arriving at S⸺ I went to a
public-house, which was still kept by a woman who had known me
from my infancy; as I feared to break abruptly on my aged
grandfather, who might be too much affected to sustain the surprise,
I, therefore, got the landlady to send word that a stranger had
arrived, who brought news from his grandson: having thus prepared
the way, I followed in person, and was received with transport by my
dear and venerable benefactor. On inquiring into his circumstances, I
was grieved to learn that he had been for several years obliged to
subsist upon the charity of his friends, and particularly the worthy
family of the Moultries, of whom I have made honourable mention in
the second chapter of these Memoirs. I was also concerned to find
that the dear old man’s faculties were much impaired, and my grief
was heightened by the reflection that my misconduct and
consequent misfortunes had been the primary cause of his mental as
well as pecuniary distress. My other relatives in S⸺ treated me
with every mark of attention, and I was hospitably entertained by
them all during my stay in that town. It is to be observed, that only
two or three of my nearest relations were acquainted with the
events of my life for the last seven years. It was given out that I had
been abroad, but it was understood in a respectable capacity. About
a fortnight after my arrival in S⸺shire, I received a letter from my
mother, informing me that no inquiry whatever had been made
respecting me, and concluding from thence that I might with safety
return when I thought proper. As no prospect of employment
presented itself in the country, it was the opinion of my friends that I
should again try my fortune in London; for which purpose they
jointly supplied me with money to defray my present expenses, and
contributed among them a few necessaries I was most in need of. I
was persuaded that my dear grandfather would not experience the
want of any reasonable comforts during the short remaining term of
his life, which could not in all probability be long protracted. I was,
therefore, less solicitous about continuing on the spot, as my
presence in fact only tended to recall to his half-distracted mind the
remembrance of former and better days. My grandfather gave me
letters of recommendation to several of his old law acquaintances,
particularly one to a Mr. Belt, who held a superior situation in the
crown-office, and who had formerly been articled to himself when
resident in London.
All things being arranged, I once more took leave of my friends,
and set off by the coach for London, on the 1st of January, 1808.
Having occasion to take a fresh coach at Birmingham, and wishing to
take a little recreation, which the restraint I was under at S⸺, and
the nature of the place had hitherto precluded me from, and having
the pecuniary means of so doing in my power, I determined on
devoting a few days to that object, before I resumed my journey to
London. After three days’ amusement I again took coach, and
having travelled all night, we stopped about seven in the morning at
Henley-upon-Thames to breakfast. I had been so free in my
expenses at Birmingham, that I had at this time but four shillings left
in my purse. I therefore declined alighting, in order to save the cost
of a breakfast, as I had had a snack at the last stage, and felt no
inclination to eat. The other passengers having entered the house, I
remained alone in the coach, the horses being taken out, and the
coachman and guard having also quitted it. After sitting a few
minutes, it occurred to me that I had seen a number of small parcels
put into the seats of the coach, previous to our departure from
Birmingham; and, having frequently heard of large sums in bank-
notes being transmitted by this mode of conveyance to London, I
was tempted to purloin one of them, which it appeared I should run
no risk in doing, as the coast was clear, and I had a large bundle of
linen, &c., deposited in one of the seats. I solemnly declare that until
this moment, no idea of depredation had entered my head since my
arrival in England; the act was, therefore, perfectly unpremeditated.
Without hesitation then, I opened the seat, and taking out my
bundle, untied it, in case of a surprise. As I had not time to examine
the contents of the various parcels, I determined to trust to fortune,
and therefore took out the first which came to hand. It was enclosed
in brown paper, tied with packthread, about twelve inches by eight in
size, and from its weight and hardness, I supposed it to contain
some kind of cutlery or other hardware; but as such goods were
commonly packed up with bank-notes, to prevent a suspicion of
money being enclosed, the apparent contents were a matter of
indifference to me. The parcel was directed to “Mr. ⸺, Goodge-
street, Tottenham-court-road.” This circumstance convinced me
there could be no discovery of the robbery until after I was far
enough from the coach, which I intended to quit on arriving at the
Gloucester Coffee-house, as, in case I had gone on to the George
and Blue-boar in Holborn, the parcel might possibly have been
searched for, on our passing the end of Tottenham-court-road.
Having concealed my prize in my own bundle, which I replaced in
the seat, I judged it best to alight and partake of breakfast with the
other passengers. I was also in better spirits on account of the
confidence I felt, that I should find something in the parcel to recruit
my slender finances; as, let the contents be what they might, it was
probable they would produce me at least a guinea or two, which
would supply my immediate exigencies. I accordingly entered the
parlour, and took a cup of coffee with the company. The bill being
called, amounted to two shillings and three pence per head; I put
down half-a-crown, which left me in possession of eighteen pence.
We then re-ascended the coach, and resumed our journey. At three
in the afternoon we entered London, and stopping as usual at the
Gloucester Coffee-house, I told the coachman I should then leave
him, as I resided in the neighbourhood. He inquired if I had any
luggage, and on my saying I had a bundle in the seat, he opened
the door and handed it to me. I gratified him with a shilling out of
my small stock, and made the best of my way. Having suffered the
coach to pass on, I followed slowly until I arrived in Holborn; but
previous to visiting my mother, I entered a public-house, being
anxious to examine my newly-acquired prize. Retiring to a private
room, I cut the string with a trembling hand, and opening the
outside paper, found three several parcels (also in brown paper,)
lying one upon another. Developing the first of these, I found it to
contain, to my no small surprise and chagrin, a quantity of fine, new
⸺ twelvepenny nails! about a hundred in number. My hopes now
fell to the ground. I was determined, however, to see the whole; and
lo! the second paper contained ⸺ the same quantity of tenpenny
nails!! The third and last, which I carelessly unfolded, expecting
nothing better, presented a number of small plated articles,
apparently designed for fixing on harness, being hooks, rings, &c., of
various shapes, and every one separately wrapped in fine silver
paper. As these latter articles were of no more real value to me than
the nails, I was much mortified at my ill luck, and was on the point
of tying up the whole parcel in order to throw it away as soon as I
gained the street, when it fortunately struck me that there must be
somewhere, a letter or note accompanying these goods. I, therefore,
once more overhauled the packages, and lifting up the bottom one,
found under it a letter, which on taking up, I perceived to contain an
enclosure, and I plainly felt several pieces of loose money. Now
again my spirits rose—all that I had read and heard of large sums in
bank-notes being artfully transmitted in this manner, recurred to my
mind, and I eagerly drew the candle towards me, half afraid, and yet
impatient to see the event. The letter was superscribed in the same
manner as the parcel; and opening it, I could scarce believe my
eyes, when I discovered some bank-paper carefully folded, and
through which the black marks of the sum were plainly discernible!
Before I ascertained the amount, however, I proceeded to peruse
the letter, and found it to the following effect:—“Sir, I have sent you
herewith specimens of the nails and other articles; the order shall be
completed as speedily as possible. I have also enclosed you £47 9s.
which you will find to be the present balance between us. I am,
&c.”—Here was an unexpected windfall! The reader will conceive my
joy, and with what satisfaction I replaced the parcel in my bundle, in
order to quit the public-house. The notes proved to be two of twenty
pounds each on a Birmingham bank, but payable also at Forster,
Lubbock, and Co’s, in London, a bank of England five pound note,
and another of two pounds, also a bank dollar, and four shillings. I
now repaired with a light heart to my mother’s lodgings, where I
met with a cordial welcome. Having spent the evening with my
mother, I walked into the city and procured a bed at an inn. The
next morning I sent one of my twenty pound notes by a porter to
the banking-house, where he procured small notes of the Bank of
England in exchange; I soon afterwards called myself with the
second, and did the like. Being now possessed of near fifty pounds
by this lucky hit, I determined to furnish myself with a stock of
genteel clothes, a watch, and other appendages, prior to my
obtaining some employment, as I always considered an outward
appearance essential to success in every pursuit; but I was firmly
resolved never again to hazard my liberty by a second act or attempt
of a similar nature.
In a few days I had purchased such articles as were most
requisite, at the expense of about forty pounds, and I then turned
my attention to procuring a genteel situation. I accordingly waited
on Mr. Belt, the gentleman I mentioned of the Crown-office; who, on
perusal of the letter I presented, testified his respect for my
grandfather’s recommendation, and very obligingly offered to take
me as an assistant clerk under his own direction in the above office,
if I thought fit to accept of a guinea a week, which was all he could
promise to allow me at first, but might be afterwards increased. I
thought this too favourable an offer to be rejected. I, therefore,
thankfully closed with it, and prepared immediately to attend
assiduously to the duties of my office.
CHAPTER II.
Quit the Crown Office, and engage as Reader in a Printing Office.—Determine to
live a strictly honest life.—Meet with an old Acquaintance who laughs me out
of my Resolution.—Give up all thoughts of Servitude and become a professed
Thief.

I had, on my second arrival in London, engaged a small apartment


in a creditable house, and regulated my expenses upon principles of
the strictest economy; but notwithstanding every possible effort, I
soon found it impossible to subsist within my income; consequently,
in a few weeks I had sensibly decreased my little capital. I,
therefore, began to consider how I might obtain a more productive
situation, as I saw no prospect of my present salary being
augmented. At this juncture I met with an advertisement for a
person of good education, to act as Reader in a Printing Office.
Though this was an employment of which I had not the least idea, I
determined to offer myself, conceiving there could be nothing very
difficult in its duties. Having, therefore, first inquired into the nature
of the latter I boldly applied to the advertiser Mr. Barnard, on Snow-
hill; and in answer to his queries, replied that I had lately left the
service of a country printer, whom I named, and was well acquainted
with the business of a printing office in general; adding, that if he
pleased to make trial of me, I doubted not of proving well qualified
for the situation in question. Mr. Barnard consented to do so; and
informing me that the salary he had given my predecessor was two
guineas a week, expressed his willingness to allow me the same. I
was so much pleased with this increase of wages, as well as with the
nature of the employment when explained to me, that I immediately
quitted Mr. Belt, and began my attendance at the office of Mr.
Barnard. My business here was to read over or examine the proofs
(sheet by sheet, as they were struck off by the pressmen) of every
new work printed by my employer. These proofs or first impressions,
having been first compared with the copy or manuscript, the errors
so discovered being noted by me, were corrected by the compositor,
and a second impression produced, which was then carefully
examined, and the few errors yet remaining were rectified as before.
A third sheet was then revised by me, which in most cases proved
perfectly correct; and this being ascertained, the required number of
copies were struck off, whilst a succeeding sheet was in the hands of
the compositors, in a state of progress for the like operation. In a
few days I had a perfect knowledge of the business confided to me;
and here I found the advantages of a good education, and of my
extensive reading, which enabled me at first sight to detect many
errors that an experienced “Reader,” with a common education,
would have passed over, particularly where Latin or French phrases,
quotations, &c., were introduced. This soon became obvious to my
employer, who expressed his satisfaction, and paid me more than
common respect. On my part I was equally pleased with my new
situation. The business of Mr. Barnard’s office was very extensive. It
employed from forty to fifty workmen in various capacities, and he
had generally ten or more different works (periodical as well as
others) in the press. Among these were some of an entertaining
kind; so that while I was performing my duty, I gratified my passion
for reading, and anticipated the public in the perusal of many
curious and interesting new publications.
I still adhered closely to my system of economy and took care to
expend something less than my income. It was my fixed
determination to abstain from every kind of dishonesty; and for
about three weeks I met with no temptation to an opposite conduct:
but one day as I entered the eating-house at which I commonly
dined, I was accosted by a young man who had come home with me
from New South Wales, in the Buffalo, having been for several years
in the service of Governor King. This was, in fact, the very person to
whom I had confided my intention of deserting, and bequeathed my
effects previous to my going ashore. Our joy at meeting was
reciprocal, and before we parted an appointment to sup together the
same evening was the consequence. My old friend informed me that
the Buffalo was paid in about five days after I quitted her, and that
the crew were immediately drafted into various ships: he himself
was put on board the Diomede of 50, and having at last, with much
difficulty, obtained a liberty-ticket for eight days, he had been about
a week in town. It is needless to add, that nothing was further from
his thoughts than returning. From him I also learnt that a diligent
search was instituted for me in Portsmouth the day after my
absconding, and that Captain King, as well as his subordinate
Captain Houston, were much exasperated on the occasion. On
meeting my shipmate at the appointed place (which by-the-by,
proved to be a house of ill repute) he introduced me to several other
old acquaintances, who had also come home with us, and to a few
of the same stamp, who had been a longer time returned, from New
South Wales. I soon discovered that they had all resumed the same
depredatory course of life which had caused their former sufferings,
and must inevitably entail upon them future misery and disgrace.
However, as I knew how fruitless it would be to advise or
remonstrate, I contented myself with letting them know that I had
met with a tolerable situation which enabled me to live upon the
square, and that I had “tied up prigging,” as I was determined never
to be “lagged” again[47]. By this communication I only incurred at
the moment, a few dry jokes on my pretended honesty, and a hint
or two that I should soon become tired of servitude, and be easily
brought over to get an easy guinea. Upon the whole, I spent a very
agreeable evening, but to prevent a relapse, I determined to avoid
the company of these misguided persons in future, notwithstanding
they extracted a promise at parting, that I would meet them again
next day. This promise I scrupled not to break, and how long I might
have refrained from their society I know not; but a day or two
afterwards, as I was descending Holborn-hill in my way to the office,
I unexpectedly met my old partner and fellow-sufferer, Alexander
Bromley, whom I had left in Newgate in 1801. Having in vain made
inquiry as to his fate, since my return to England, I was truly glad to
see him, for he looked well and was genteelly dressed. I was so
much altered, that when I first accosted him, he had no immediate
recollection of me, but on making myself known, nothing could
exceed the joy he evinced at our meeting. Before we parted it was
indispensable that we should drink together, and he hastily informed
me that he had served his seven years on board the Hulks, at
Portsmouth, from whence he returned to London the 17th of
September 1807, and that he was now once more under the
protection of his father, who had received him with great kindness,
and was inclined, if he continued honest, to take care of his future
fortune; but added, with a shrewd shake of the head, that he could
never reconcile himself to confinement on a shop-board, and feared
he should very speedily make a push at some higher enjoyments.
Having agreed to dine together, and by mere accident named the
house at which I had lately supped as the place of meeting, we
parted with some little regret.
Bromley was punctual to his time, and during the two hours I
allowed for dinner, we became more fully informed of each other’s
circumstances. When I was on the point of leaving him to return to
my duty, two or three of my Botany-bay acquaintances dropping in,
forcibly detained me; urging that I might for once stretch a point,
and spend the afternoon with them, ridiculing with too much effect,
the idea of a man like myself being confined to certain hours like a
school-boy, &c. As I was somewhat elevated with the liquor I had
drank, and had really no business at the office which could not be
easily deferred, I consented in an evil moment, to join the party
which was forming, consisting of nearly a dozen persons, most of
them recently returned either from the Hulks, or New South Wales.
It is needless to describe the nature of our conversation, or the
various characters of which the party was composed; let it suffice to
state (with sorrow and shame I confess it) that I was effectually
laughed out of my late good intentions; and before we parted, had
joined with the loudest of them in decrying and contemning every
species of servitude or confinement; and cordially agreed in a
resolution to live independent while I could, and to make up by
every means in my power for the privations and sufferings I had
endured for the last seven years.
From this moment I returned no more to the printing-office, but
joined myself with Bromley, and a few others, who regularly walked
out every evening in quest of money, without confining our pursuits
to any particular branch, but embracing every opportunity which
offered. These were indeed but few, and far from productive, so that
I soon grew heartily tired of the set I was associated with, and
determined to withdraw myself from them the first opportunity, and
to live by the exercise of my own ingenuity. Indeed my appearance
was so much above, and of so different a stamp from their’s, that
this circumstance alone was enough to excite suspicion, and on
many accounts rendered them unsuitable companions for me. I
determined, however, not to discard poor Bromley, for whom I felt a
real friendship, on account of our former intimacy and joint
misfortunes.
CHAPTER III.
Various modes of obtaining Money.—My regular course of Life when disengaged
from my vicious Companions.—Meet with an amiable girl, like myself, the
Child of Misfortune.—We cohabit together.—Our mutual Happiness.

Having withdrawn myself from my late companions, I now became


very circumspect in my proceedings; and as Bromley had neither the
appearance nor the manners of a gentleman, I only made use of
him occasionally in the course of my practice, keeping him in the
back ground to receive and carry any articles which I purloined, and
never suffering him to converse with, or approach me except in
private. I generally spent the mornings, that is, from about one
o’clock to five P. M. (which are the fashionable hours for shopping) in
visiting the shops of Jewellers, Watchmakers, Pawnbrokers, &c.
Having conceived hopes that this species of robbery would turn to a
good account, and depending upon my own address and
appearance, I determined to make a circuit of the town, and not to
omit a single shop in either of those branches: and this scheme I
actually executed so fully, that I believe I did not leave ten untried in
all London, for I made a point of commencing every day in a certain
street and went regularly through it on both sides the way. My
practice was to enter a shop and request to look at gold seals,
chains, broaches, rings, or any other small articles of value; and
while examining them, and looking the shopkeeper in the face, I
contrived by slight of hand to conceal two or three (sometimes
more) in the sleeve of my coat, which was purposely made wide. On
some occasions I purchased a trifling article to save appearances; at
other times I took a card of the shop, promising to call again; and as
I generally saw the remaining goods returned to the window, or
place from whence they were taken, before I left the shop, there
was hardly a probability of my being suspected, or of the property
being missed. In the course of my career I was never once detected
in the fact, though on two or three occasions, so much suspicion
arose, that I was obliged to exert all my effrontery, and to use very
high language, in order, as the cant phrase is, to bounce the
tradesman out of it; and my fashionable appearance, and affected
anger at his insinuations, had always the effect of convincing him
that he was mistaken, and inducing him to apologize for the affront
put upon me. I have even sometimes carried away the spoil
notwithstanding what had passed, and I have often gone a second
and third time to the same shop, with as good success as at the
first. To prevent accidents however, I made it a rule never to enter a
second shop with any stolen property about me; for as soon as I
quitted the first, I privately conveyed my booty to Bromley, who was
attending my motions in the street, and herein I found him
eminently useful. By this course of depredation I acquired on the
average about ten pounds a week, though I sometimes neglected
shopping for several days together. This was not, indeed, the only
pursuit I followed, but was my principal morning’s occupation;
though if a favourable opportunity offered of getting a guinea by any
other means, I never let it slip. In the evenings I generally attended
one of the theatres, where I mixed with the best company in the
boxes, and at the same time that I enjoyed the amusements of the
place, I frequently conveyed pocket-books, snuff-boxes, and other
portable articles, from the pockets of their proprietors into my own.
Here I found the inconvenience of wanting a suitable companion,
who might have received the articles I made prize of, in the same
manner as Bromley did in the streets; but though I knew many of
the light-fingered gentry, whose appearance fitted them for any
company, yet, their faces being well known to the police-officers,
who attend the Theatres, they would not have been suffered to
enter the house: and herein I possessed an advantage which many
of these gentry envied me; for being just arrived in England, and a
new face upon the town, I carried on my depredations under the
very noses of the officers, without suspicion. Having, therefore, at
first no associate, I was obliged to quit the Theatre and conceal my
first booty in some private spot, before I could make (with
prudence) a second attempt. Upon the whole I was very successful
in this pursuit also, at least as to the number of articles I filched,
and had their value been reasonably proportionate to what I
expected, I need not long have followed so hazardous an
employment. I have very frequently obtained nine or ten pocket-
books, besides other articles, in an evening; and these being taken
from gentlemen evidently of fortune and fashion, I had reason to
expect I should sometime meet with a handsome sum in Bank-
notes; but fortune did not favour me therein, for during near twelve
months almost nightly attendance at one or other of the public
places, I never found more than twenty pounds in a book, and that
only on one occasion. I several times got five, ten, or eleven pounds,
but commonly one, two, or three pounds, and most generally four
books out of five contained nothing but letters, memorandums, and
other papers useless to me. At the same time I knew frequent
instances of the common street pickpockets getting a booty of fifty,
one hundred and sometimes three or four hundred pounds.
However, I never failed to pay the expenses of the night, and if I
gained nothing, I enjoyed at least a fund of amusement, which was
to me the highest gratification. It sometimes happened that the
articles I got (particularly pocket-books) were advertised by the
losers, within a few days, as “Lost,” and a reward offered for their
restoration: where this reward was worth notice, I frequently
restored the property by means of a third person whom I could
confide in, and whom I previously tutored for the purpose.
In the mean time, the manner in which I spent my life, abstracted
from the disgraceful means by which I supported myself, was (as I
have formerly hinted,) perfectly regular and inoffensive. Though I
lived by depredation, yet I did not like the abandoned class of
common thieves, waste my money, and leisure time in profligate
debauchery, but applied myself to the perusal of instructive and
amusing books, my stock of which I daily increased. I occupied
genteel apartments in a creditable house, the landlord of which
understood me to hold a situation under Government, and every
part of my conduct at home tended to confirm his opinion of my
respectability. I was scrupulously exact in paying my rent, as well as
the different tradesmen in the neighbourhood, with whom I had
occasion to deal; nor did I ever suffer any person of loose character
to visit me, but studiously concealed from those of my acquaintance
my place of residence. I was sometimes, indeed, so imprudent as to
resort, for company’s sake, to some of those public-houses
frequented by thieves and other dissolute characters, the landlord of
which is himself commonly an experienced thief, or returned
transport. When I had a mind to relax a little, or grew tired of
domestication, I disguised my appearance as much as I could, and
repaired to a house of this description, sometimes taking my
Dulcinea with me, whom I shall shortly introduce to the reader, and
whose person and dress I was not a little proud of exhibiting in
public. This fondness for flash-houses, as they are termed, is the
rock on which most persons who live by depredation unhappily split,
and will be found in the sequel to have brought me to my present
deplorable condition; for the police officers, or traps, are in the daily
habit of visiting these houses, where they drink with the thieves,
&c., in the most familiar manner; and, I believe, often obtain secret
information by various means from some parties respecting the
names, characters, pursuits, &c., of others. By this imprudent
conduct I also became personally known to many of the officers,
which was productive of great danger to me in the exercise of my
vocation; whereas, had I avoided such houses, I might have
remained unknown and unsuspected by them for a series of years. I
ought not to omit what may perhaps gratify the reader, as much as
the act did myself, namely, that as soon as I became possessed of a
moderate sum, I remembered the kindness shewn me by the good
woman at Gosport, and wrote her a letter of thanks, enclosing a
five-pound bank-note, which, no doubt, proved highly acceptable. I
also from time to time assisted my aged mother, whose
circumstances were extremely narrow, and her support derived
solely from the earnings of my two sisters, whose success depending
on the caprice of fashion and of milliners, both alike inconstant, was
but precarious. They, as well as my other relations in S⸺shire,
were indeed totally ignorant of my unhappy relapse into a life of
infamy, but believed my assertion, that I had a liberal salary from Mr.
Belt, and was still employed under that gentleman in the Crown-
office.
About three months after my return to London, and whilst in the
zenith of my success, I was introduced by one of my former
dissolute companions to the acquaintance of a young woman, who,
like myself, had been well and tenderly brought up, but having been
seduced by a young man equally inexperienced with herself, to quit
her friends and cohabit with him as his wife, she had thereby
forfeited the countenance of her family, and her paramour having
died after a year’s cohabitation, she had been driven to the usual
refuge in such cases, a life of prostitution. At the period of my
introduction, however, she had been only a few months upon the
town, and I clearly perceived that her mind was yet but very slightly
contaminated. As there were many reasons which rendered a female
companion in whom I could place confidence, desirable, and in fact
necessary to me; and as this young woman’s misfortunes had placed
her in such circumstances, that I had no obstacles to surmount on
the score of delicacy, I proposed to her, after a few days’
acquaintance, that we should live together; to which, as she was
heartily tired of her present course of life, she willingly consented.
She knew enough of the world from her late experience, to surmise
in what manner I obtained my living, of which, however, to avoid all
duplicity, I fully possessed her. Having informed my landlord, that my
wife, whom I had not before mentioned to him, was arrived in town
from a visit she had been paying in the country, I accordingly took
her home; and in a very few days we had arranged a pretty snug
system of domestic economy, and provided every requisite for the
family life I meant in future to live. My companion was the daughter
of an industrious mechanic, who, having a numerous offspring, had
only been enabled to give her a common education; but her mother
had instructed her in the duties of house-keeping, and she was
perfectly conversant in all the qualities requisite to form a good wife.
She was about nineteen years of age, agreeable in her person, and
of the sweetest disposition imaginable; and what was most
gratifying, the company she had latterly mixed with, and the
disgusting examples before her eyes, had not been able to eradicate
an innate modesty which she naturally possessed; so that her
manners and conversation were such as fitted her for any company
to which I might be inclined to introduce her. I informed my mother
and sisters that I was on the point of contracting a union with this
young woman, and having made them personally acquainted, the
three young ladies soon became very intimate. As my mother and
sisters but rarely called at my lodgings, and then merely en passant,
I had no difficulty in concealing the connexion from them until I
could with propriety declare my marriage to have taken place. We
had the happiness of finding ourselves mutually pleased with each
other, and I considered my meeting with so amiable a friend as one
of the greatest blessings of my life. In a few weeks after our
junction, my partner discovered evident symptoms of pregnancy,
which with her affectionate behaviour, and real attachment to my
interest, endeared her still more to me. In a word, I now felt myself
as happy as any man daily risking his liberty and life, and exposed to
the reproaches of his own conscience, could possibly be.
CHAPTER IV.
Adventures in the course of my profligate Career.—Motives which induce me to
marry my Companion.—Her exemplary Behaviour.—A family Misfortune.

Having now settled myself in a manner much to my satisfaction,


and happily met with a faithful friend, to whom I might confide my
most secret thoughts, who would sincerely participate my joy, when
success crowned my pursuits; and who, in the hour of adversity,
would condole with, and cherish me, I applied myself with redoubled
assiduity to the acquirement of money, with a full resolution in the
event of my meeting with one good booty, or realizing by degrees a
sufficient sum to quit the hazardous course of life I had embarked
in, to establish myself in some honest line of business. To this
prudent measure I was also strongly prompted by my companion,
who could not hide her fears and anxiety on my account, and was
never easy during my absence from home on a depredatory
excursion. I continued to visit the shops as usual in the morning,
and the theatres in the evening with tolerable success; and my
partner having expressed a desire to accompany me, in the hope of
rendering me service, I was induced to gratify her. As her figure and
address were both extremely prepossessing, and her air perfectly
genteel, I soon found her eminently useful; for she not only received
from me the property I purloined, but with much ingenuity would
contrive to engross the attention of the shopkeeper while I robbed
his counter, or by artful gallanting with a gentleman at a public
place, facilitate my design upon his pockets. At all times, when
disengaged from these hazardous practices, we lived a life of perfect
domestic happiness, our chiefest pleasure being centred in each
other’s company.
As our mutual affection increased, my companion, whom I had
informed of the outlines of my past life, and who was aware of the
dangers to which I was daily exposed, being filled with tender fears
of losing me for ever, and prompted by sincere affection, suggested
the idea of uniting ourselves indissolubly by marriage; in the hope
that should I unhappily experience a reverse of fortune, and be
again banished from my native country, she might obtain permission
to share my misery, and contribute, by her society, to lessen my
sufferings. This proposal so fully convinced me of her undisguised
attachment, and had so much reason on its side, that I gave into it
with ardent pleasure; and the necessary preliminaries being
adjusted, we were accordingly married at St. Paul’s, Covent-Garden,
on the 21st of July, 1808, her mother, to whom she had become
reconciled, and who (judging by appearances,) had a favourable
opinion of the match, assisting at the ceremony.
Soon afterwards, I communicated the event to my mother,
informing her that weighty reasons had rendered it necessary to
observe privacy on the occasion; and hinting to the unsuspecting old
woman, that I had acquired by this marriage, a considerable
pecuniary advantage. This intimation gave my mother great
pleasure, and I took care by increased liberality towards her and my
sisters, to confirm them in the opinion of my veracity. The behaviour
of my wife became every day more exemplary; and had I been free
from that remorse which must ever accompany a guilty life, and
enabled to procure those necessary comforts which I knew so well
how to enjoy, by upright means, I should have considered myself
supremely happy. In the beginning of the month of October, my
wife, who was far advanced in her pregnancy, accompanied me one
evening to Drury-lane theatre; and the performance being over, we
were descending the stair-case from the box-lobby, when I
attempted to possess myself of a gentleman’s pocket-book; but by
some accident he suspected my design, and publicly accused me
therewith. Unfortunately several other gentlemen, who had been
robbed in the course of the evening, being on the spot, and
beginning to compare notes, agreed unanimously that they
recollected my person as being near them about the time they were
robbed, and did not scruple to insinuate that I ought to be detained
and searched. This conversation naturally attracted the attention of
the company immediately round us; but while it took place, all the
parties were obliged by the pressure of the throng behind to
continue descending, and we in fact quitted the theatre all together.
Being arrived in Little Russell-street, the gentlemen surrounded me
to the number of about a score, and our altercation became loud
and vehement. Fortunately for me no police-officers happened to be
near the spot; for although I had nothing to fear from a search, yet
the circumstance would have made me personally known to the
latter, and would of course operate to my disadvantage on my future
appearance at the theatre. I exerted every art of expostulation, and
finally had recourse, on my part, to threats, affecting to feel highly
insulted by their insolent insinuations; declared myself a gentleman
of character, which I would prove to their cost; offered to give my
card of address, or to retire to a coffee-house, and send for
respectable persons who knew me, but all my rhetoric proved
ineffectual; some were for giving me in charge to an officer; others
still more violent were for having me pumped. At this moment a
person named G—ge W—k—n, now in this colony, who had been
himself exercising his vocation in the pit of the theatre, happened
fortunately to come up, and seeing a crowd collected, stopped to
ascertain the cause. He immediately perceived the critical situation
in which I stood, and having the appearance of a man of fashion, he
stepped forward, and hearing the various motions of my
persecutors, strongly advised them to forbearance, and caution how
they treated a gentleman, as I evidently appeared to be; urging that
they must certainly be mistaken in their conjectures, that my
proposal of giving my address, or a reference, ought to be sufficient,
and particularly dwelt on the impropriety of taking the law into their
own hands. These arguments of my friend W—k—n carried so much
weight, that the gentlemen began to waver and grow less
clamorous; till at length they dropped off one by one; and W—k—n,
assuming a haughty tone, said, taking me by the arm, “Come, Sir,
you have been sufficiently exposed, and long enough detained on a
charge which I am confident there is no foundation for; allow me to
conduct you from this spot; if you are going towards St. James’s, I
shall be glad of your company, and let me see (raising his voice and
cane together,) who will dare to insult you further.” So saying, he led
me away in triumph, tipping the wink to my poor wife, who had
stood all the while at a small distance, much terrified and agitated
by various emotions, which so much affected her, that though we
lived within two hundred yards of the theatre, she had scarcely
power to walk home; and we had no sooner quitted our kind
conductor, who attended us to the door, than she fainted away, and
was for sometime insensible. The consequences of this untoward
event were still more seriously afflicting, for her tender constitution
was not proof against the shock, and she was the next day
prematurely delivered of a male child, which, however, only lived
eight hours, and was a subject of infinite regret to us both.
CHAPTER V.
Adventure of the Silver Snuff-box.—Its Consequences.—My narrow Escape from
Transportation, which I have since had reason to regret.

Happening soon after the adventure at Drury-lane, to read an


advertisement, stating that a meeting of the freeholders of the
county of Middlesex would be convened on the 11th of November, at
the Mermaid Tavern, Hackney, to consider of the expediency of
petitioning the Throne on the subject of parliamentary reform, it
struck me that I might find it worth while to attend this meeting, as
it would probably attract a large concourse of people, and, as at
such assemblies riots and much confusion frequently occurred,
which afforded a favourable opportunity for plundering the pockets
of the company. On the day appointed, I accordingly left town in one
of the Hackney stages, and arriving at the Mermaid about one
o’clock, found the sheriffs had just opened the business of the
meeting, which was held in a large room commonly used as an
assembly-room for dancing, and detached from the tavern itself. To
my disappointment, however, there were not above three hundred
persons collected, and the building being very spacious, there was
not the least prospect of any violent pressure taking place. Before I
commenced my operations, I entered a small house called “The
Tap,” immediately contiguous to, but distinct from, the Mermaid; and
going into a parlour, called to the landlady, a decent looking elderly
woman, for a glass of brandy and water, and a pipe. Having taken
and paid for this refreshment, I proceeded to the meeting; and
found, so far from any tumult or uproar, that the whole company
were collected at one end of the room, and listening in profound
silence to the speech of some popular and patriotic orator, who was
warmly censuring the conduct of ministers, and advocating the
cause of liberty. I now entered the thickest part of the crowd, and
having tried the pockets of a great many persons without feeling a

You might also like