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

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

The document is a promotional overview of the book 'Practical Graph Structures in SQL Server and Azure SQL' by Louis Davidson, which focuses on utilizing graph structures for deeper insights in highly connected data. It includes links to download the book and other related titles, along with information about the author and technical reviewer. The book covers various topics including graph fundamentals, data structures, SQL graph table basics, and performance tuning.

Uploaded by

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

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

The document is a promotional overview of the book 'Practical Graph Structures in SQL Server and Azure SQL' by Louis Davidson, which focuses on utilizing graph structures for deeper insights in highly connected data. It includes links to download the book and other related titles, along with information about the author and technical reviewer. The book covers various topics including graph fundamentals, data structures, SQL graph table basics, and performance tuning.

Uploaded by

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

Practical Graph Structures in SQL Server and

Azure SQL: Enabling Deeper Insights Using Highly


Connected Data 1st Edition Louis Davidson pdf
download
https://ebookmeta.com/product/practical-graph-structures-in-sql-
server-and-azure-sql-enabling-deeper-insights-using-highly-
connected-data-1st-edition-louis-davidson/

Download more ebook from https://ebookmeta.com


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

Practical Graph Structures in SQL Server and Azure SQL:


Enabling Deeper Insights Using Highly Connected Data
1st Edition Louis Davidson

https://ebookmeta.com/product/practical-graph-structures-in-sql-
server-and-azure-sql-enabling-deeper-insights-using-highly-
connected-data-1st-edition-louis-davidson/

Pro SQL Server 2022 Wait Statistics: A Practical Guide


to Analyzing Performance in SQL Server and Azure SQL
Database, 3rd Edition Thomas Larock

https://ebookmeta.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/

Pro SQL Server 2022 Wait Statistics: A Practical Guide


to Analyzing Performance in SQL Server and Azure SQL
Database, 3rd Edition Thomas Larock

https://ebookmeta.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/

A Cultural History of Hair in the Age of Enlightenment


1st Edition Margaret K. Powell & Joseph Roach (Editors)

https://ebookmeta.com/product/a-cultural-history-of-hair-in-the-
age-of-enlightenment-1st-edition-margaret-k-powell-joseph-roach-
editors/
Heidegger in Russia and Eastern Europe Jeff Love

https://ebookmeta.com/product/heidegger-in-russia-and-eastern-
europe-jeff-love/

Diagnostics and Gene Therapy for Human Genetic


Disorders K. V. Chaitanya

https://ebookmeta.com/product/diagnostics-and-gene-therapy-for-
human-genetic-disorders-k-v-chaitanya/

Psychology Themes and Variations Doug Mccann

https://ebookmeta.com/product/psychology-themes-and-variations-
doug-mccann/

Upgrade A Novel 2nd Edition Crouch Blake

https://ebookmeta.com/product/upgrade-a-novel-2nd-edition-crouch-
blake/

River A Curvy Girl Mountain Man Romance Matched with a


Mountain Man 1st Edition Eve London

https://ebookmeta.com/product/river-a-curvy-girl-mountain-man-
romance-matched-with-a-mountain-man-1st-edition-eve-london/
Explaining Cancer Finding Order in Disorder Anya
Plutynski

https://ebookmeta.com/product/explaining-cancer-finding-order-in-
disorder-anya-plutynski/
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
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
Another Random Scribd Document
with Unrelated Content
THE FINESSE OBLIGATORY
This is an arbitrary finesse, which is often forced upon you,
when, unless the cards of a suit are in a certain position, there is no
possibility of winning. Perhaps the best way of defining the finesse
obligatory is to give an example showing the position as it most
frequently occurs:

“Z” is the dealer, and leads a low card to the king in dummy,
which wins the first trick. The suit is returned, the ace being marked
with “A.” If “A” holds both ace and knave, no matter how the dealer
plays, “A” must win two tricks. Unless the knave is in “B’s” hand, and
“A” holds the singleton ace, the adversary must win two tricks. The
dealer should, therefore, play his lowest card, not the queen.

WATCHING THE DISCARDS IN ORDER TO


LOCATE FINESSES
The amount of information to be gained from the adversary’s
discards is apt to be underestimated. Careful notice of the discards,
particularly in a “no-trump” hand, will often help you to locate
honours and to determine where a finesse should be taken;
moreover, it will simplify the end play, show you chances to throw
the lead, and give you opportunities to force the opponents to lead
up to your hand.
If the king of your long suit is against you and on the wrong side,
it will probably make, but this is not true of the queen. If you hold in
the two hands ace king, jack or ace king jack, ten of a suit, unless
you can place the queen, you are compelled to guess where to take
the finesse. If, however, you can advantageously lead another suit
try to force the adversaries to discard, one will undoubtedly protect
the queen of your suit, and the other, not knowing perhaps that you
are trying to gain information, will probably discard from his weak
suit; the discard thus enabling you to finesse successfully.
This information can often be similarly obtained in a trump hand
by leading an extra round of trumps. If, however, you are forced to
lead the suit without any knowledge of the situation, lead a card
which will tempt your adversary to cover; for instance, holding ace x
x in dummy with king jack ten in your own hand, lead the jack. If
the jack is not covered, it is often good play to take the first trick
with the ace, and, on returning the lead, to play the ten. As the jack
was not covered you infer that the queen is held by the other
adversary.
If you have no finesse in your suit, it often pays to give the
adversaries a chance to make a finesse possible for you. For
instance, with A x x in dummy and K 10 9 in your own hand, unless
both queen and jack are unguarded, or unless you can tempt them
to play badly, the adversaries must make one trick in the suit. The
play is to lead the ten, for if it is covered, either with jack or queen,
you have the advantage of a finesse on your return of the suit.

SECOND HAND PLAYS


Showing the play of the different combinations between dealer
and dummy. In each case a small card is led and the second hand is
the hand that is led through:
2d Hand. 4th Hand. Play.
AKx Jxx K, or Low
AKx 10 x x K (T) Low (NT)
AQx Jxx Low
AQx 10 x x Low
AQx xxx Queen (T) Low (NT)
AJx Qxx Low
A 10 x Jxx Low
Axx Qxx Low
KQx xxx Queen
KJx xxx Low
KJ xxx Jack (T) King (NT)
KJ Axx Jack
KJx 10 x x Low
K 10 x Jxx Low
Kxx Qx Low
Kx xx Low (T) King (NT)
Kx Jxx Low
Kx Qxx Low (T) King (NT)
Kx Q 10 x Low
Kx A 10 x Low
Kx AJx Low
QJx xxx Jack
QJx Axx Jack
Q 10 x Axx Low
Qxx Kxx Low
Qxx xxx Low
Qx Axx Queen
Qx A 10 x Low
Qx AJx Low
Qx Kxx Low (T) Queen (NT)
(T) with a declared trump.
(NT) at no trump.
AKx Jxx K, or Low
Qx Jxx Low
Qx xxx Queen
J 10 x AKx Ten
J 10 x Axx Ten
Jx AKx Jack
Jx AQx Low
10 x AKx Ten
10 x AQx Ten
10 x AJx Low
(T) with a declared trump.
(NT) at no trump.
MANAGEMENT OF TRUMPS BY THE
DEALER
The surest test of a player’s skill is the ability he displays in
handling trumps. Habits that are wrong in theory are frequently
formed, and errors in judgment are common in the trump
management. The difficulties are as numerous as the combinations
are varied. Only general rules can be given, and the constantly
changing situations must be met by the skill and originality of the
player.

WHEN TO LEAD TRUMPS


One of the first points for the dealer’s consideration is the
advisability of the trump lead. As he usually holds the balance of
trump strength in the combined hands, generally speaking the
dealer should lead trumps.
A common excuse for avoiding the trump lead is that the hands
contain no long suit; if this is true, why not try to establish your
trump suit? If you hold five trumps in one hand, the chances are
that three rounds will leave you with two long trumps and the
adversaries powerless to “ruff” any high card you may hold; by
refusing to lead trumps you may enable the opponents to “overruff”
your strong hand and make their trumps separately. It may be to
your advantage to have the other suits led by the adversaries and
your trump lead will often force them to do this.
At times you will have the choice of two ways of playing the
hand. One, to trump losing cards in your weak hand; the other to
exhaust trumps and discard your losing cards on the commanding
cards of a long suit. If your trumps are strong and your long suit
established, the trump lead is preferable. With an established suit
and high trumps against you, postpone the trump lead until you
have allowed your weak hand to “ruff” the losing cards.
However, with five trumps in the strong and four in the weak
hand, as you will probably exhaust trumps in two rounds, it is safer
to lead the trumps first. You can then “ruff” in your weak hand
without danger of being “overruffed.”
If you hold seven or more trumps in the combined hands, do not
make the fact that your strong hand has been forced an excuse for
not leading trumps. If you are protected in the adversaries’ suit and
can lead the trumps advantageously from the weak to the strong
hand, always lead them.
To lead trumps with this number is the rule, not the exception,
but occasionally when they cannot be led from the weak hand it is
better to make as many trumps as possible by “ruffing.”

WHEN NOT TO LEAD TRUMPS


Perhaps the simplest rule that can be given is, do not lead
trumps when there is a short side suit in the weak trump hand. You
will obviously gain by trumping losing cards in the weak hand.
As it often requires two rounds to exhaust the short suit in the
weak hand, try not to show your intention too clearly, or the
adversaries will circumvent your scheme of “ruffing” by a trump
lead. Remember, also, that you cannot obtain the “ruff” unless you
hold, or can make, an entry card in your strong hand.
When your combined hands contain fewer than seven trumps,
the balance of strength is with the adversaries, and, in this case,
unless your trumps or side suits are exceptionally strong, avoid the
trump lead.
With but six trumps and an established suit against you, it would
be dangerous to lead trumps. One adversary must hold at least four
trumps, and it may be that all the remaining trumps are in one hand.
The trump lead would only help the adversaries to make their suit.
When the commanding trump is against you, endeavour to
discard your losing suit cards from one hand on winning ones in the
other before you give up the lead.

UNBLOCKING THE TRUMP SUIT


As dealer, be careful to lead your trumps in such a manner that
you will not find it impossible to continue the lead. The simplest
method of unblocking the trump suit is to lead or play the high
trumps from the shorter hand.
Occasionally to avoid blocking the suit, it will be necessary to
“ruff” with a high instead of a lower trump. For instance, with ace
and ten of trumps in dummy and king, queen, jack, nine and eight in
your own hand, if you “ruff” with dummy’s ten, you will block the
trump suit; even a temporary discontinuance of the trump lead may
result in loss.
When you lead the queen toward the ace, holding the ace, jack,
ten, nine, seven in one hand and queen, eight, four in the other, you
must provide for the possible necessity for leading three times
through the king by playing the nine of trumps on the queen lead. A
careless play of the seven may make it impossible to capture the
adversary’s king.

NOT FORCING YOUR STRONG TRUMP HAND


The greatest weakness and the most expensive fault in the
beginner’s game is his predilection for trumping in the strong trump
hand. When trumps are hopelessly against you, it may be necessary
to make what you can by ruffing, but with the advantage of the
make, you are seldom compelled to play a defensive game. When
you needlessly force your strong hand to trump, you reduce your
power to exhaust the adversaries’ trumps, to establish your suit, and
to be left with the last trump—which is, par excellence, the dealer’s
game.
To trump in the weak hand is always advisable, nor can any
objection be raised to a “cross-ruff,” but force your strong hand only
as a last resource.
If you hold the losing one of two remaining trumps, try to force
the winning trump from the adversary’s hand; to force your own
hand instead will materially prejudice your chance of making a suit.

LEADING TRUMPS TO PREVENT A RUFF


When it is apparent that one adversary can “ruff” a suit, or when
a “cross-ruff” is imminent, it is important that you guard against
such a contingency by at least two rounds of trumps. Of course, if
you hold the commanding trump, this presents no difficulties; but,
when the winning trump is with the adversary, you should try to
tempt him to hold it up second in hand by refraining from a high
card lead. For instance, with queen and seven of trumps in one hand
and king jack ten nine eight in the other, lead the seven instead of
the queen.
If your trumps are in sequence you can often obtain two rounds
by leading the lowest of your sequence rather than the highest card.

WHEN TO DRAW THE REMAINING TRUMPS


When you are left with but one remaining trump, and that the
commanding one, usually lead it to draw the losing trumps.
When there are but two other remaining trumps, trust that your
trump lead will find them divided. If you have reason to know that
both are in one hand, one must of course make; but lead the
commanding trump, so that but one can make.
With the best trump in your hand and one against you, it is only
in critical situations that you should refrain from drawing the losing
trump. For instance, when the adversaries hold an established suit
and the commanding card of your suit, it is a better play to clear
your suit and then refuse a force until the adversary who holds the
remaining trump cannot lead his partner’s suit. Take care, however,
to accept the force at the right time, for a delay in trumping may
allow the adversary to discard a losing card of your suit.

DISCONTINUING THE LEAD OF TRUMPS


There are many positions difficult to define when it is advisable
to discontinue the trump lead. An obvious case is when the
commanding trump is against you and the lead would entail your
loss of two trumps for one card, which the adversary must make in
any case. The best play is to force the adversary to “ruff” with the
high trump, for then your trumps may make separately.
When you hold but two trumps with two against you, be careful
about taking the third round of trumps when your adversaries hold
an established suit; if the trumps are divided no doubt the lead will
save a trick; but you risk finding both trumps in one hand, in which
case the adversary will draw or force your remaining trump and
make his suit. The trump lead cannot win more than one trick and it
may lose several.
With three remaining trumps, if your suit is established, the third
round should always be taken. Should you find after one or two
rounds that the trumps are banked in one hand against you, it is, as
a rule, better to force the opponent’s hand than to continue the
trump lead. This gives you the long trump, which is no
inconsiderable advantage.
The adversaries’ high trumps are sometimes placed after one
round, so that it may be advisable to discontinue the trump lead
temporarily until you can lead to better advantage from the weaker
hand.
When you hold the commanding card of each side suit and do
not wish the lead of your long suit to be interrupted, it is good play
to lead the losing trump. If, however, you are not in a position to win
any card the adversary may lead, it is better play to force the
commanding trump.

WHEN TO TRUMP
If the adversary attempts to force your strong hand, it is usually
advisable to accept the force. Only in rare cases does it pay to allow
the opponent to continue the lead of his established suit.
At times you can afford to give the adversary one trick, knowing
that, on the next lead, your weak hand can take the “ruff.”
With two trumps against you it is often good play to discard
rather than to “ruff” with the commanding trump. But to gain by
your play, you should hold a certain entry card in the suit that the
adversary must lead.
With one trump against you, do not use your one remaining
trump until the leader’s partner is exhausted in the leader’s suit.
If the adversary leads a suit which you can trump in either hand,
the “ruff” should invariably be taken in the weak hand, and a discard
made in the strong one.
You are sometimes in a position to know that if you trump, your
adversary will overtrump. When the best card is led, it is usually
good play to trump immediately and if possible with a card which
will not unguard an honour in your own hand, but will force a high
card from the opponent. If a suit is led, of which you hold the
commanding card in the opposite hand, your best defence is to take
a discard, which will prevent the adversary from making a high card
later in the hand. If you can make no advantageous discard, your
best play is to trump, especially if the trumps in your combined
hands are in sequence, for, if the adversary wins the trick, his high
trump will probably make in any case.
OVERTRUMPING
It is only the experienced player who can resist the temptation to
overtrump. The beginner jumps at every trick without realising that
he can often gain by waiting. Overtrump when your hand is weak
and your trumps low; but, if overtrumping takes out your only high
card in the trump suit, especially if it is the commanding trump, it is
nearly always better to discard. Your winning trump is bound to
make, and it is better play to throw away a suit that you can ruff
later with one of your small trumps.
Frequently by overtrumping you make it easy for the adversary
to draw your remaining trumps, which, had you not weakened your
hand, he would be powerless to do. For instance, where you hold
the best and the fourth best trump, with the second and third best in
your adversary’s hand, should you overtrump, your adversary will, of
course, be in a position to catch your smaller trump, while by
refusing the trick you retain the extra trump and are enabled to
draw the adversary’s last trump.

RE-ENTRY CARDS
It is of little use to establish a suit unless it is possible to get the
lead in the hand that contains it; therefore, the reservation of a re-
entry card in the hand that has the long suit is of great importance.
A preferable re-entry is, of course, the last trump or trumps.
Arranging the trump lead so that the last round will be taken in
the desired hand is often a necessary precaution.
After the adversaries’ trumps are exhausted, you may be
compelled to place the lead in the opposite hand by an extra round
of trumps, and often it is necessary to trump with a high card,
saving the low trump to lead to the opposite hand.
It not infrequently happens that in order to get the lead in the
opposite hand, you are forced to trump your own commanding card.
FORCING DISCARDS
Should you find as dealer that you have a losing card and a
number of winning trumps, always lead the trumps to give the
adversaries a chance to make an error in discarding.
If the adversary holds the ace, dummy the king, and you a
singleton of a suit, your hand otherwise consisting of long trumps
and established cards, by first leading the singleton you may tempt
the second hand adversary to hold up the ace; while if you lead the
established cards, the adversaries can count your hand and will
make no such mistake.
Whenever you hold but six or seven cards of a suit in the
combined hands, endeavour to make your adversaries discard before
you indicate any strength. You will find that many times the discards
will necessarily benefit your hand.
With two or three remaining trumps in your hand, you should
lead at least two rounds of trumps before opening the suit of which
you have but six cards. An example of the situation is given below:
In this case hearts are trumps. The dealer is left with the two
remaining trumps, and holds in his combined hands but six clubs.
Should the clubs be led before the trump suit, the adversaries would
be left with the commanding club. The dealer should play his two
trumps to force discards from his opponents’ hands before he opens
the club suit.
With four or five long trumps, when but one other suit has been
opened, you will almost invariably gain tricks by forcing the
adversaries to discard. Any error they may make in selecting the suit
to protect may enable you to take tricks with cards that would
otherwise be valueless.

THROWING THE LEAD


The disadvantage of the lead is at times most apparent, and you
can often gain by forcing your adversary to lead a suit which you
cannot well afford to open.
When there are tricks that the adversaries must win, try to make
this necessity a benefit to your hand.
Occasions for throwing the lead arise most frequently in the end
play; there are the nice situations where you gain the advantage of
position by leading a losing trump or suit card.
However, situations where it is advisable to throw the lead are so
frequent and varied in occurrence throughout the entire play that
the subject can only be treated in a general way. Perhaps covered by
one suggestion; when you cannot lead a suit advantageously, try to
force the adversary to lead it to you.
THE DEALER’S PLAY OF A “NO-
TRUMP” DECLARATION
As soon as the hand has been opened, make a comprehensive
examination to determine the possibilities of your combined hands.
Are you strong enough to win the game? Can you win the odd trick?
Shall you be able to save the game?
With no other possibility in the hand, make a determined effort
to save the game. If you are weak in one suit and hold the
command of the suit that is opened, your danger may lie in allowing
the adversaries to retain the lead.
When you hold an established suit, you cannot but gain by
forcing the opponents to discard; they may unguard honours in their
weaker suits or give you information that will locate high cards.
Do not forget that your strength is in your long suit, and that you
are often dependent on your other high cards to establish this suit.
To the mind of the novice, the loss of the lead is a calamity, and he
will often lead all his high cards, leaving the command of his own
suit, as well as of the others, with the adversaries.
Remember that it requires no skill to make aces and kings, and
that your goal in a “no-trump” hand must be the establishment of
the small cards of your long suit.
With fair possibilities in the hand, ascertain before you play a
card from dummy, first: which is your longest suit; second, how can
it be most advantageously led; and, third, in which hand there is the
greater need of an entry card.

CHOICE OF SUITS
There is no rule so necessary to good play as that of retaining
the control of the shorter suits and playing to establish the longest
suit in the combined hands. Do not let the fact that your long suit
contains but a few high cards discourage you—the lead can entail
but small loss as the commanding cards would probably make in any
case.
When, as frequently happens, your combined hands contain two
suits of equal length, make a careful selection of the suit to be
played for.
When the ace of one suit and the king or the queen of the other
are against you, play for the suit of which the adversary holds the
ace. The ace must win, while the fuller information that comes later
in the hand may enable you to catch the king or queen by a finesse.
Then you can better afford to discard from a suit headed by the ace
than from a suit in which an honour must be protected. Moreover,
you deprive the adversary of a sure re-entry card.
With two suits of equal length, be careful not to play for one in a
hand that contains no re-entry card.
When you hold two suits of equal length, it is usually wise to play
for the suit that is exposed on the table and conceal the strength in
your own hand. In other words, don’t give the adversaries
unnecessary information.
In choosing between two suits select the one that will gain you
the greater number of tricks. For instance, when you hold two eight-
card suits, one divided five and three and the other four and four,
there are clearly more tricks to be made in the former.
Be cautious about playing for a suit of no more than seven cards,
for you will often find the remaining cards most unequally divided.
When you hold but six cards in the combined hands the balance of
strength is with the adversaries, one of whom must hold at least
four cards. Try to force your opponents to discard before you
indicate strength in six- or seven-card suits.
With two entire suits against you, you cannot afford to lose the
lead. Make what tricks you need to save the game and pin your
hope on successful finesses.
With but one suit against you, do not fear to establish your long
suit. It is not so dangerous to give up the lead when you hold a
protection in the suit led originally. The adversary, not knowing your
weakness, will probably return the original lead.

KEEPING THE COMMANDING CARD


OF THE ADVERSARIES’ SUIT
As a general rule, do not part with the command of the
adversaries’ suit until one adversary is exhausted in the suit, and
therefore unable to return his partner’s lead; unless the original
leader has a sure card of entry you may be able to prevent this
player from getting into the lead. Usually do not refuse to take a
trick with a king or queen when the higher card or cards have not
been played. The adversaries may lead through and capture a single
guarded honour.
If you find that there is another entire suit against you, it pays to
take the first lead and make what tricks you can in the two
remaining suits. Even in some rare cases, the play of a well-guarded
king in dummy is the one chance to make or save the game.
Sometimes the cards of your long suit will be so unfortunately
placed that the continued lead would establish it for the adversaries.
In this situation, keep the command of that suit, and make a bid for
better luck in establishing another.
Unless there is no possibility of losing the game, do not hesitate
to take the first lead whenever you are assured of a sufficient
number of tricks to win the game.
Often by taking the first trick you promote the value of another
card in your own hand or in dummy. In other words, you temporarily
give up the control, with the knowledge that you will eventually hold
the master card of the opponents’ suit.
In these cases, by taking an honour led or played, the dealer can
eventually stop the adversaries’ suit.
At times, if you take the first trick, the suit will be protected,
provided it is not led by your right-hand adversary.

In these two cases, if an honour is led, the first trick should be


passed. If a low card is led and an honour played, the first trick
should be taken. Otherwise the opponent may immediately lead
through your hand.
Holding the king, queen, and a small card of the adversaries’ suit,
you are assured of at least one trick, with the possibility of two, but
remember, if you take the first trick, your hand may be led through;
it is often safer to win the third round than the first.
Should you win the first trick in any one of these cases,
endeavour to prevent your right-hand adversary from obtaining the
lead.
When the adversaries can take two tricks in your long suit, it is
better to win the first and third than the first and second tricks in
their suit.
In this case a low card is led, and you can win the first trick with
the queen. By doing this you are forced to take the first and second
rounds. If you take the first trick with the ace, your queen will be
sacrificed to the king, but your jack controls the third round.
Unless there is another suit against you, it is safer to win the
second and third tricks of the adversaries’ suit than the first and
third.

Should you wait to win the second trick with the ace, there is a
chance that your right-hand adversary will be exhausted in the suit,
and unless the original leader has two cards of re-entry his suit
cannot be made.

RE-ENTRY CARDS
Clear your long suit before you take out your card of re-entry is a
simple rule that is often violated. When you have made the “no-
trump” declaration, any possible re-entry in the dummy hand should
be used to bring in a suit or to lead a suit advantageously from the
weak hand. In fact, much of the success of a “no-trump” hand
depends on the dealers’ skill in saving and making re-entries in the
weaker hand.
A re-entry may be an ace or a three. It may be the master card
of your long suit or a guarded honour in the adversaries’ suit.
When you can win the original lead in either hand, consider well
the question of re-entries before you touch one of dummy’s cards.
Save all possible re-entry cards, remembering that often in order
to gain any material advantage from a finesse you must be in a
position to lead twice from the weak hand.
For instance, holding any one of the following combinations:
In order to make an entry card in the suit led originally, it may
occasionally be necessary to overtake a card played by the dummy.
When your long suit is blocked, try to establish an entry card
before you make the situation clear to the opponents. Otherwise
they will not allow you to enter and make your suit.
If you hold four cards of a suit in each hand, it may be possible
to obtain the lead twice in one hand. For instance, holding
If you lead the deuce and play the king, you have deprived
dummy of the only entry card in the suit. If, however, you lead the
eight, dummy’s seven will probably be the master card on the fourth
round. Such a re-entry is often of great assistance in opening the
next suit.
When you hold a nine-card suit divided five and four, it may be
necessary to use both the third and fourth rounds of the suits as re-
entries to lead another suit advantageously. This is a chance for
good play that is often overlooked in the pleasure of making a long
suit.
When dummy’s re-entry is a guarded king or queen, and you
have no means of knowing the position of the ace, try to establish
this re-entry by sacrificing a high card from your own hand.
In both of the examples given above, the dealer to make a re-
entry card for the dummy should sacrifice a high card from his hand.

UNBLOCKING
There is frequent necessity in the dealer’s play for ridding one
hand of high cards in order not to interrupt the lead of smaller cards
from the other hand. It is well to look ahead and prepare for this
contingency, for often in the middle of a hand you will quite
unexpectedly find that unblocking will enable you to make small
cards that the adversaries have made good by reckless discarding.
When you hold more cards of a suit in one hand than in the
other, you can invariably prevent blocking, if you lead or play the
high cards from the shorter hand. At times a suit may be unblocked
by discarding the winning card or cards from one hand, but the first
rule covers the majority of cases where there is necessity for
unblocking.

You might also like