John L. Viescas是一位有著超過45年從業(yè)經(jīng)驗的獨立數(shù)據(jù)庫顧問。他從一位系統(tǒng)分析師開始他的職業(yè)生涯,為IBM大型機系統(tǒng)設(shè)計大型數(shù)據(jù)庫應用。他在達拉斯的應用數(shù)據(jù)研究中心工作了六年,在那里他帶領(lǐng)30多名員工負責IBM大型計算機數(shù)據(jù)庫產(chǎn)品的研究、開發(fā)以及客戶支持工作。在應用數(shù)據(jù)研究工作期間,約翰完成了達拉斯德克薩斯大學的商業(yè)金融學位,并以優(yōu)異的成績畢業(yè)。John 1988年加入Tandem 計算機公司,在那里他負責在Tandem公司美國西部銷售區(qū)開發(fā)和實施數(shù)據(jù)庫的營銷方案。他開發(fā)并交付了用于技術(shù)研討會的關(guān)系數(shù)據(jù)庫管理系統(tǒng)―― NonStop SQL。約翰1989年寫了他的**本書,A Quick Reference Guide to SQL(Microsoft Press,1989),該書一本是對比了ANSI-86 SQL 標準、IBM的DB2、微軟的SQL Server、甲骨文公司的Oracle、以及Tandem公司的NonStop SQL之間的語法相似性的研究類書。作者于1992年從Tandem公司公休時寫了Running Microsoft Access**版(Microsoft Press,1992年)。他已經(jīng)寫了四個版本的Running Microsoft Access,以及Running系列的后續(xù)作品――三個版本的Microsoft Office Access Inside Out(Microsoft Press,2003、2007、2010)和Building Microsoft Access Applications(Microsoft Press,2005)。他也是暢銷書籍SQL Queries for Mere Mortals(Addison Wesley,2014)第三版的作者。John目前保持著連續(xù)多年被微軟授予微機數(shù)據(jù)庫管理系統(tǒng)*有價值專家(MVP,Most Valuable Professional)的紀錄(1993年至2015年)。John與他的妻子在法國巴黎定居了三十多年。Douglas J. Steele從事包括大型機和個人機在內(nèi)的計算機相關(guān)的工作超過45年(是的,他一開始是用穿孔卡的?。?。在2012退休前,他在一家大型國際石油公司工作了31年多。盡管他職業(yè)生涯的高光時刻是通過發(fā)展SCCM任務(wù)序列將Windows 7推廣到全球超過10萬臺電腦上,但是數(shù)據(jù)庫和數(shù)據(jù)建模是他的主要工作方向。Douglas超過17年被微軟認證為*有價值專家(MVP),他撰寫了大量關(guān)于Access數(shù)據(jù)庫的文章,Douglas是Microsoft Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs(Wiley,2010)的合著者,也是很多書的技術(shù)編輯。Douglas為滑鐵盧大學系統(tǒng)設(shè)計工程碩士,專注于設(shè)計非傳統(tǒng)電腦用戶的用戶界面研究。(當然,在七十年代末,很少有人是傳統(tǒng)的電腦用戶?。┧膶I(yè)研究源于他的音樂背景(他擁有多倫多英國皇家音樂學院鋼琴演奏準學士學位)。他還癡迷于啤酒并畢業(yè)于尼亞加拉學院釀酒及啤酒廠操作管理專業(yè)(濱湖尼亞加拉,安大略?。ouglas和他的妻子在加拿大安大略省圣凱瑟琳定居超過34年。讀者可以通過郵箱:mvphelp@gmail.com聯(lián)系Douglas。Ben G. Clothier是芝加哥首屈一指的Access和SQL Server開發(fā)企業(yè)IT Impact公司的解決方案架構(gòu)師。他曾在著名J Street Technology和Advisicon公司做過自由顧問,主要從事從小型個人解決方案到公司全業(yè)務(wù)應用程序Access項目的相關(guān)工作。值得注意的項目包括一家水泥公司的工作跟蹤和庫存管理系統(tǒng)、給保險商使用的醫(yī)療保險計劃生成器以及國際航運公司的訂單管理系統(tǒng)。Ben在UtterAccess是系統(tǒng)管理員,并且和Teresa Hennig、George Hepworth、Doug Yudovich合著了Professional Access? 2013 Programming(Wiley,2013);并與Tim Runcie和George Hepworth一起合著了Microsoft? Access in a SharePoint World(Advisicon,2011);Ben還是Microsoft? Access? 2010 Programmer’s Reference(Wiley,2010)一書的特約作者。他擁有微軟SQL Server 2012解決方案認證和MySQL 5認證開發(fā)者等證書。從2009年開始Ben一直是微軟的*有價值專家(MVP)。影印版,無譯者
圖書目錄
Introduction 1 A Brief History of SQL 1 Database Systems We Considered 5 Sample Databases 6 Where to Find the Samples on GitHub 7 Summary of the Chapters 8 Chapter 1: Data Model Design 11 Item 1: Verify That All Tables Have a Primary Key 11 Item 2: Eliminate Redundant Storage of Data Items 15 Item 3: Get Rid of Repeating Groups 19 Item 4: Store Only One Property per Column 21 Item 5: Understand Why Storing Calculated Data Is Usually a Bad Idea 25 Item 6: Define Foreign Keys to Protect Referential Integrity 30 Item 7: Be Sure Your Table Relationships Make Sense 33 Item 8: When 3NF Is Not Enough, Normalize More 37 Item 9: Use Denormalization for Information Warehouses 43 Chapter 2: Programmability and Index Design 47 Item 10: Factor in Nulls When Creating Indexes 47 Item 11: Carefully Consider Creation of Indexes to Minimize Index and Data Scanning 52 Item 12: Use Indexes for More than Just Filtering 56 Item 13: Don’t Go Overboard with Triggers 61 Item 14: Consider Using a Filtered Index to Include or Exclude a Subset of Data 65 Item 15: Use Declarative Constraints Instead of Programming Checks 68 Item 16: Know Which SQL Dialect Your Product Uses and Write Accordingly 70 Item 17: Know When to Use Calculated Results in Indexes 74 Chapter 3: When You Can’t Change the Design 79 Item 18: Use Views to Simplify What Cannot Be Changed 79 Item 19: Use ETL to Turn Nonrelational Data into Information 85 Item 20: Create Summary Tables and Maintain Them 90 Item 21: Use UNION Statements to “Unpivot” Non-normalized Data 94 Chapter 4: Filtering and Finding Data 101 Item 22: Understand Relational Algebra and How It Is Implemented in SQL 101 Item 23: Find Non-matches or Missing Records 108 Item 24: Know When to Use CASE to Solve a Problem 110 Item 25: Know Techniques to Solve Multiple-Criteria Problems 115 Item 26: Divide Your Data If You Need a Perfect Match 120 Item 27: Know How to Correctly Filter a Range of Dates on a Column Containing Both Date and Time 124 Item 28: Write Sargable Queries to Ensure That the Engine Will Use Indexes 127 Item 29: Correctly Filter the “Right” Side of a “Left” Join 132 Chapter 5: Aggregation 135 Item 30: Understand How GROUP BY Works 135 Item 31: Keep the GROUP BY Clause Small 142 Item 32: Leverage GROUP BY/HAVING to Solve Complex Problems 145 Item 33: Find Maximum or Minimum Values Without Using GROUP BY 150 Item 34: Avoid Getting an Erroneous COUNT() When Using OUTER JOIN 156 Item 35: Include Zero-Value Rows When Testing for HAVING COUNT(x) < Some Number 159 Item 36: Use DISTINCT to Get Distinct Counts 163 Item 37: Know How to Use Window Functions 166 Item 38: Create Row Numbers and Rank a Row over Other Rows 169 Item 39: Create a Moving Aggregate 172 Chapter 6: Subqueries 179 Item 40: Know Where You Can Use Subqueries 179 Item 41: Know the Difference between Correlated and Non-correlated Subqueries 184 Item 42: If Possible, Use Common Table Expressions Instead of Subqueries 190 Item 43: Create More Efficient Queries Using Joins Rather than Subqueries 197 Chapter 7: Getting and Analyzing Metadata 201 Item 44: Learn to Use Your System’s Query Analyzer 201 Item 45: Learn to Get Metadata about Your Database 212 Item 46: Understand How the Execution Plan Works 217 Chapter 8: Cartesian Products 227 Item 47: Produce Combinations of Rows between Two Tables and Flag Rows in the Second That Indirectly Relate to the First 227 Item 48: Understand How to Rank Rows by Equal Quantiles 231 Item 49: Know How to Pair Rows in a Table with All Other Rows 235 Item 50: Understand How to List Categories and the Count of First, Second, or Third Preferences 240 Chapter 9: Tally Tables 247 Item 51: Use a Tally Table to Generate Null Rows Based on a Parameter 247 Item 52: Use a Tally Table and Window Functions for Sequencing 252 Item 53: Generate Multiple Rows Based on Range Values in a Tally Table 257 Item 54: Convert a Value in One Table Based on a Range of Values in a Tally Table 261 Item 55: Use a Date Table to Simplify Date Calculation 268 Item 56: Create an Appointment Calendar Table with All Dates Enumerated in a Range 275 Item 57: Pivot Data Using a Tally Table 278 Chapter 10: Modeling Hierarchical Data 285 Item 58: Use an Adjacency List Model as the Starting Point 286 Item 59: Use Nested Sets for Fast Querying Performance with Infrequent Updates 288 Item 60: Use a Materialized Path for Simple Setup and Limited Searching 291 Item 61: Use Ancestry Traversal Closure for Complex Searching 294 Appendix: Date and Time Types, Operations, and Functions 299 IBM DB2 299 Microsoft Access 303 Microsoft SQL Server 305 MySQL 308 Oracle 313 PostgreSQL 315 Index 317