Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorJim Lehmer

If you were handed two different but related sets of data, what tools would you use to find the matches? What if all you had was SQL SELECT access to a database? In this practical book, author Jim Lehmer provides best practices, techniques, and tricks to help you import, clean, match, score, and think about heterogeneous data using SQL. DBAs, programmers, business analysts, and data scientists will learn how to identify and remove duplicates, parse strings, extract data from XML and JSON, generate SQL using SQL, regularize data and prepare datasets, and apply data quality and ETL approaches for finding the similarities and differences between various expressions of the same data. Full of real-world techniques, the examples in the book contain working code. You'll learn how to: Identity and remove duplicates in two different datasets using SQL Regularize data and achieve data quality using SQL Extract data from XML and JSON Generate SQL using SQL to increase your productivity Prepare datasets for import, merging, and better analysis using SQL Report results using SQL Apply data quality and ETL approaches to finding similarities and differences between various expressions of the same data

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical SQL-first guide to reconciling messy, heterogeneous datasets when all you have is SELECT access—ideal for DBAs, analysts, and data engineers who must deduplicate, clean, and match records without leaving the database. 【Book Arc】 - **Opening (~0%–10%)**: Frames the core problem—two related datasets, no shared key, only SQL—and lays out the book's workflow: import, clean, match, score, report. A quick SELECT/join review (Chapter 1) refreshes the patterns used throughout. - **Early (~10%–32%)**: Builds the SQL toolkit (Chapter 2): date, logical, string, and system functions (CHARINDEX, PATINDEX, TRIM, REPLACE, COALESCE, ISDATE, IIF) that later chapters lean on heavily for parsing and normalization. - **Middle (~32%–55%)**: Tackles common dirty-data domains one by one—names (Chapter 3), locations/addresses (Chapter 4), dates (Chapter 5), email (Chapter 6), phone numbers (Chapter 7), and bad characters/encoding (Chapter 8)—showing how to regularize each before matching. - **Late (~55%–80%)**: Moves into matching itself: extracting data from XML/JSON, generating SQL with SQL, preparing datasets for import and merge, and applying data-quality/ETL thinking to find similarities and differences between expressions of the same entity. - **Ending (~80%–100%)**: Focuses on scoring, reporting results, and operationalizing the workflow—turning candidate matches into reviewable output and production-ready views. (Excerpts do not cover the final chapters in detail.) 【Key Takeaways】 - **Fuzzy matching is a pipeline, not a single query** (Opening): import → clean → match → score → report; each stage has its own SQL techniques and failure modes. - **Normalization must precede matching** (Early–Middle): names, addresses, dates, emails, and phones each carry domain-specific traps—suffixes, punctuation, future birthdates, invalid emails, embedded annotations like "Aunt Judy's #". - **String functions are the workhorses** (Early): CHARINDEX, PATINDEX, LEFT/RIGHT/SUBSTRING, TRIM, REPLACE, and TRANSLATE combine to parse and regularize free-text fields. - **COALESCE and outer joins solve "most current value" problems** (Early): when a loan amount lives across four tables in three systems, COALESCE picks the first non-NULL value across joined sources. - **NULL semantics and collation matter** (Early): ANSI_NULLS behavior, EXISTS vs. joins, and case-sensitive collations can silently break matches; choose COLLATE deliberately. - **Bad characters and encoding are real match-killers** (Middle): nonbreaking spaces, invisible characters, and charset mismatches survive TRIM and corrupt comparisons. - **Generate SQL with SQL to scale** (Late): meta-programming queries boosts productivity when matching rules must be applied across many columns or tables. - **Scoring and reporting close the loop** (Late–Ending): match confidence must be surfaced for human review, not just computed. 【Reading Tips】 - **Skim Part I if you know SQL well**—the author says so explicitly; jump to Chapter 2's function reference and return as needed. - **Deep-read Chapters 3–8** (names, locations, dates, email, phone, bad characters); these are the domain-specific heart of the book and where most real-world pain lives. - **Run the code**: examples are working SQL, and the parsing logic (e.g., splitting "Mortimer Snedley, Jr.") is best understood by executing and modifying it. - **Adopt the CTE-to-view pattern** the author uses during EDA—prototype with CTEs, promote to views for production. - **Treat the author's opinions as a starting point**, not gospel; he explicitly invites you to compare approaches and synthesize your own. 【Coverage Limits】 This guide is based on stratified excerpts covering roughly the first half of the book; the later matching, scoring, and reporting chapters are referenced but not detailed in the source material.
Excerpt 1
36 ISDATE 37 Logical Functions: IIF 37 String Functions 38 CHARINDEX and PATINDEX 38 LEN 39 LEFT, RIGHT, and SUBSTRING 39 LTRIM, RTRIM, and TRIM 46 LOWER and...
View in text
Page 15
eferring to a SQL or other programming language keyword, it will look like COUNT(*). Block SQL code in the text appears as follows: SELECT * FROM sys.databas...
View in text
Excerpt 3
ations, these are different tables in dif‐ ferent databases. Then perhaps the loan origination system moves the loan from the application phase to underwriti...
View in text
Excerpt 4
ead of LOWER and UPPER because it forces some other charac‐ ter representation issues into a uniform representation and not just whether all char‐ acters are...
View in text
Excerpt 5
isn’t a precise business. Don’t let that make you a victim! “That list from Marketing” (clears throat) “doesn’t have everything I need, but I can construct m...
View in text
Excerpt 6
o share an email address, and that happens, but it is rare). Along with mobile phone numbers, if you have a match on email, your likelihood of a false positi...
View in text
Excerpt 7
insensitive, accent-sensitive, kanatype-insensitive, width- insensitive for Unicode Data, SQL Server Sort Order 52 on Code Page 1252 for non- Unicode Data.”...
View in text
Excerpt 8
AND CHARINDEX('@', RIGHT(CustomField3, LEN(CustomField3) - CHARINDEX(',', CustomField3))) > CHARINDEX(',', CustomField3) AND CHARINDEX('@', RIGHT(CustomField...
View in text
Tags
AI categories
SQLDataDatabase
Publisher: O'Reilly Media
Publish Year: 2023
Language: English
Pages: 283
File Format: PDF
File Size: 2.2 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…