SQL Antipatterns

SQL Antipatterns pdf epub mobi txt 电子书 下载 2026

出版者:Pragmatic Bookshelf
作者:Bill Karwin
出品人:
页数:328
译者:
出版时间:2010-7-5
价格:USD 34.95
装帧:Paperback
isbn号码:9781934356555
丛书系列:
图书标签:
  • sql
  • database
  • 数据库
  • SQL
  • Antipatterns
  • Programming
  • 计算机
  • 编程
  • SQL
  • 数据库
  • 设计模式
  • 反模式
  • 性能优化
  • 数据建模
  • SQL Server
  • MySQL
  • PostgreSQL
  • 最佳实践
想要找书就要到 图书目录大全
立刻按 ctrl+D收藏本页
你会得到大惊喜!!

具体描述

Each chapter in this book helps you identify, explain, and correct a unique and dangerous antipattern. The four parts of the book group the antipatterns in terms of logical database design, physical database design, queries, and application development.

The chances are good that your application's database layer already contains problems such as Index Shotgun , Keyless Entry , Fear of the Unknown , and Spaghetti Query . This book will help you and your team find them. Even better, it will also show you how to fix them, and how to avoid these and other problems in the future.

SQL Antipatterns gives you a rare glimpse into an SQL expert's playbook. Now you can stamp out these common database errors once and for all.

Whatever platform or programming language you use, whether you're a junior programmer or a Ph.D., SQL Antipatterns will show you how to design and build databases, how to write better database queries, and how to integrate SQL programming with your application like an expert. You'll also learn the best and most current technology for full-text search, how to design code that is resistant to SQL injection attacks, and other techniques for success.

作者简介

Bill Karwin has been a software engineer for over twenty years, developing and supporting applications, libraries, and servers such as Zend Framework for PHP 5, the InterBase relational database, and the Enhydra Java application server. Throughout his career, Bill has shared his knowledge to help other programmers achieve success and productivity. Bill has answered thousands of questions, giving him a unique perspective on SQL mistakes that most commonly cause problems.

目录信息

1 Introduction
1.1 Who This Book Is For
1.2 What’s in This Book
1.3 What’s Not in This Book
1.4 Conventions
1.5 Example Database
1.6 Acknowledgements
Logical Database Design Antipatterns
2 Jaywalking
2.1 Objective: Store Multi-Value Attributes
2.2 Antipattern: Format Comma-Separated Lists
2.3 How to Recognize the Antipattern
2.4 Legitimate Uses of the Antipattern
2.5 Solution: Create an Intersection Table
3 Naive Trees
3.1 Objective: Store and Query Hierarchies
3.2 Antipattern: Always Depend on One’s Parent
3.3 How to Recognize the Antipattern
3.4 Legitimate Uses of the Antipattern
3.5 Solution: Use Alternative Tree Models
4 ID Required
4.1 Objective: Establish Primary Key Conventions
4.2 Antipattern: One Size Fits All
4.3 How to Recognize the Antipattern
4.4 Legitimate Uses of the Antipattern
4.5 Solution:Tailored to Fit
5 Keyless Entry
5.1 Objective: simplify database architecture
5.2 Antipattern: leave out the constraints
5.3 How to Recognize the Antipattern
5.4 Legitimate Uses of the Antipattern
5.5 Solution:declare constraints
6 Entity-Attribute-Value
6.1 Objective: Support Variable Attributes
6.2 Antipattern: Use a Generic Attribute Table
6.3 How to Recognize the Antipattern
6.4 Legitimate Uses of the Antipattern
6.5 Solution:Model the Subtypes
7 Polymorphic Associations
7.1 Objective: Reference Multiple Parents
7.2 Antipattern: Use Dual-Purpose Foreign Key
7.3 How to Recognize the Antipattern
7.4 Legitimate Uses of the Antipattern
7.5 Solution:Simplify the Relationship
8 Multi-Column Attributes
8.1 Objective: Store Multi-Value Attributes
8.2 Antipattern: Create Multiple Columns
8.3 How to Recognize the Antipattern
8.4 Legitimate Uses of the Antipattern
8.5 Solution:Create Dependent Table
9 Metadata Tribbles
9.1 Objective:Support Scalability
9.2 Antipattern:Clone Tables or Columns
9.3 How to Recognize the Antipattern
9.4 Legitimate Uses of the Antipattern
9.5 Solution:Partition and Normalize
II Physical Database Design Antipatterns
10 Rounding Errors
10.1 Objective: Use Fractional Numbers Instead of Integers
10.2 Antipattern:Use FLOAT DataType
10.3 How to Recognize the Antipattern
10.4 Legitimate Uses of the Antipattern
10.5 Solution:Use NUMERIC DataType
11 Flavors
11.1 Objective: Restrict a Column to Specific Values
11.2 Antipattern: Specify Values in the Column Definition
11.3 How to Recognize the Antipattern
11.4 Legitimate Uses of the Antipattern
11.5 Solution:Specify Values in Data
12 Phantom Files
12.1 Objective: Store Images or Other Bulky Media
12.2 Antipattern: Assume You Must Use Files
12.3 How to Recognize the Antipattern
12.4 Legitimate Uses of the Antipattern
12.5 Solution: Use BLOB Data Types As Needed
13 Index Shotgun
13.1 Objective:OptimizePerformance
13.2 Antipattern: Using Indexes Without a Plan
13.3 How to Recognize the Antipattern
13.4 Legitimate Uses of the Antipattern
13.5 Solution:MENTOR Your Indexes
III Query Antipatterns
14 Fear of the Unknown
14.1 Objective: Distinguish Missing Values
14.2 Antipattern: Use Null as Ordinary Value or Vice Versa
14.3 How to Recognize the Antipattern
14.4 Legitimate Uses of the Antipattern
14.5 Solution:Use Null as a Unique Value
15 Ambiguous Groups
15.1 Objective: Get Row with Greatest Value per Group
15.2 Antipattern: Reference Non-Grouped Columns
15.3 How to Recognize the Antipattern
15.4 Legitimate Uses of the Antipattern
15.5 Solution: Use Columns Unambiguously
16 Random Selection
16.1 Objective:FetchASampleRow
16.2 Antipattern:SortDataRandomly
16.3 How to Recognize the Antipattern
16.4 Legitimate Uses of the Antipattern
16.5 Solution:In No Particular Order
17 Poor Man’s Search Engine
17.1 Objective:FullTextSearch
17.2 Antipattern: Pattern Matching Predicates
17.3 How to Recognize the Antipattern
17.4 Legitimate Uses of the Antipattern
17.5 Solution:Use the Right Tool for the Job
18 Spaghetti Query
18.1 Objective:DecreaseSQLQueries
18.2 Antipattern: Solve a Complex Problem in One Step
18.3 How to Recognize the Antipattern
18.4 Legitimate Uses of the Antipattern
18.5 Solution:Divide and Conquer
19 Implicit Columns
19.1 Objective:ReduceTyping
19.2 Antipattern: a Short Cut That Gets You Lost
19.3 How to Recognize the Antipattern
19.4 Legitimate Uses of the Antipattern
19.5 Solution:Name Columns Explicitly
IV Application Development Antipatterns
20 Readable Passwords
20.1 Objective: Recover or Reset Passwords
20.2 Antipattern: Store Password in Plain Text
20.3 How to Recognize the Antipattern
20.4 Legitimate Uses of the Antipattern
20.5 Solution: Store a Salted Hash of the Password
21 SQL Injection
21.1 Objective: Write Dynamic SQL Queries
21.2 Antipattern: Execute Unverified Input As Code
21.3 How to Recognize the Antipattern
21.4 Legitimate Uses of the Antipattern
21.5 Solution:Trust No One
22 Pseudokey Neat-Freak
22.1 Objective:Tidy Up the Data
22.2 Antipattern:Filling in the Corners
22.3 How to Recognize the Antipattern
22.4 Legitimate Uses of the Antipattern
22.5 Solution:Get Over It
23 See No Evil
23.1 Objective:Write Less Code
23.2 Antipattern: Making Bricks Without Straw
23.3 How to Recognize the Antipattern
23.4 Legitimate Uses of the Antipattern
23.5 Solution: Recover from Errors Gracefully
24 Diplomatic Immunity
24.1 Objective:Employ Best Practices
24.2 Antipattern: Make SQL a Second-Class Citizen
24.3 How to Recognize the Antipattern
24.4 Legitimate Uses of the Antipattern
24.5 Solution: Establish a Big-Tent Culture of Quality
25 Magic Beans
25.1 Objective:Simplify Mode ls in MVC
25.2 Antipattern: The Model Is an Active Record
25.3 How to Recognize the Antipattern
25.4 Legitimate Uses of the Antipattern
25.5 Solution: The Model Has an Active Record
V Appendixes
A Rules of Normalization
A.1 What Does Relational Mean?
A.2 Myths About Normalization
A.3 What Is Normalization?
A.4 Common Sense
B Bibliography
Index
· · · · · · (收起)

读后感

评分

这本书讲的东西,只有维护过一堆烂代码和槽糕的数据库设计的人才能体会。 至少没有外键,也不设主键的系统我是见过的 本书讨论的主题是非常实用的,而且是开发中的一些重要问题 比如树形结构,随机行选取,外键的使用,密码的存储,文件的存储等等 作者总体来说是把数据一致性...

评分

《SQL反模式》,英文版2010年7月出版,中文版2011年9月出版。还算比较新。英文名:“SQL Antipatterns: Avoiding the Pitfalls of Database Programming”(SQL反模式:避免数据库开发中的陷阱)。 所谓反模式,就是做的不好的模式。也就是前人的经验教训。 感觉作者功力比较高...  

评分

《SQL反模式》,英文版2010年7月出版,中文版2011年9月出版。还算比较新。英文名:“SQL Antipatterns: Avoiding the Pitfalls of Database Programming”(SQL反模式:避免数据库开发中的陷阱)。 所谓反模式,就是做的不好的模式。也就是前人的经验教训。 感觉作者功力比较高...  

评分

《SQL反模式》,英文版2010年7月出版,中文版2011年9月出版。还算比较新。英文名:“SQL Antipatterns: Avoiding the Pitfalls of Database Programming”(SQL反模式:避免数据库开发中的陷阱)。 所谓反模式,就是做的不好的模式。也就是前人的经验教训。 感觉作者功力比较高...  

评分

《SQL反模式》,英文版2010年7月出版,中文版2011年9月出版。还算比较新。英文名:“SQL Antipatterns: Avoiding the Pitfalls of Database Programming”(SQL反模式:避免数据库开发中的陷阱)。 所谓反模式,就是做的不好的模式。也就是前人的经验教训。 感觉作者功力比较高...  

用户评价

评分

我最欣赏这本书的一点是它对“人”的因素的考虑。很多技术书籍只关注代码和数据,但这本书深入探讨了团队协作、代码审查和知识传递过程中如何固化这些“反模式”。它不仅仅是技术规范,更像是工程文化建设的参考。其中有一段关于命名规范的论述非常深刻,它指出模糊不清的字段名或存储过程名,是导致后来接手维护的工程师误解业务逻辑、从而引入新Bug的温床。这种从文化层面去审视技术问题的角度,非常开阔视野。在阅读过程中,我经常停下来,思考我们团队内部的Code Review流程是否能够有效地捕获这些陷阱。这本书的语言虽然严谨,但字里行间透露着一种“过来人”的无奈和深切的期望,希望后来者能够少走弯路。它没有提供一步到位的“银弹”,而是提供了一套**鉴别和修正**的思维工具。如果你已经厌倦了那些浮于表面的性能调优技巧,渴望深入理解为什么某些设计在长期运行中会崩溃,那么这本书绝对是不可多得的珍品,它教会你如何像一位经验丰富的老架构师一样思考问题,而不是被动的“代码搬运工”。

评分

这本书的封面设计非常有冲击力,黑白分明的色调,配上那略显粗犷的字体,一看就让人觉得这不是一本温和的入门指南。我之前花了不少时间在网上搜寻关于数据库设计和优化方面的资料,结果总是陷入各种“最佳实践”的迷雾中,感觉每个人都在推荐一套完美的、一成不变的流程,但实际操作起来却处处碰壁。这本书的切入点非常独特,它没有直接告诉你“应该怎么做”,而是反其道而行之,列举了那些在实际项目中屡见不鲜、但后患无穷的“陷阱”。这就像一个经验丰富的老兵在战场上给你做战前动员,告诉你哪些地方是地雷区,你必须绕着走。我印象最深的是关于事务处理的那一章,里面剖析了过度依赖隐式锁定的后果,那种场景描述得极其生动,让我立刻联想到了我们系统上次差点崩溃的午夜抢修。它并非批判技术本身,而是揭示了在特定业务场景下,如果我们带着对技术的不够深刻理解盲目套用教科书上的模式,会产生多么可怕的负面效应。这本书的价值在于,它迫使你停下来,审视自己的代码库,看看哪些看似合理的结构,其实已经是技术债的定时炸弹。阅读体验上,它更像是在破解一系列复杂的谜题,而不是被动地接受知识灌输,非常适合那些已经有一定基础,但总感觉程序性能上不去、或者数据一致性难以保障的资深开发者。

评分

这本书的结构安排非常巧妙,它没有完全按照数据类型或操作的类别来划分,而是围绕着几种最常见、最容易让人产生误解的“习惯性错误”来组织内容。例如,关于错误处理和回滚机制的讨论,它详细分析了在分布式事务和高并发环境下,缺乏细粒度错误捕获和幂等性设计所带来的数据不一致隐患。我过去总觉得只要保证主流程成功就行了,这本书让我看到了那种“边缘情况”才是真正摧毁系统可靠性的元凶。它的论述方式有一种强烈的“反直觉”魅力,你常常会发现,你多年来深信不疑的某种“优化技巧”,在特定情境下恰恰是效率的杀手。作者对于性能瓶颈的分析,总是能精准地定位到那个最不起眼的角落,比如不恰当的连接类型选择,或者是在循环中重复执行的复杂查询。这本书更像是一面镜子,照出我们在追求快速交付过程中,那些被忽略的、潜藏的瑕疵。读完后,你会对SQL这门语言产生一种新的敬畏感,明白它远比我们想象的要复杂和微妙。

评分

说实话,我刚翻开这本书的时候,一度有些失望,因为开篇并没有那种令人振奋的、宏大的技术愿景。它非常务实,甚至有些枯燥地从最基础的索引结构讲起,但深入进去才发现,这种“不炫技”恰恰是其最大的优点。它没有谈论时髦的新技术栈,而是聚焦于SQL语言本身那永恒的、绕不开的底层逻辑。作者似乎对数据库引擎的内部运作了如指掌,每一个反面教材的分析,都像是在进行一次精密的解剖手术,从查询计划的生成到磁盘I/O的效率,无不扣击要害。我特别喜欢它在探讨“过度规范化”时的论述,用了很多实际的性能对比数据来支撑观点。我以前总是被教导要遵守第三范式,但这本书让我明白了,在读写比例严重失衡的OLTP场景中,适度的冗余和反范式设计是如何成为性能的救星的。这是一种非常成熟的、权衡利弊的思维方式,它超越了学院派的教条,直指工程实践的核心——没有银弹,只有最适合当前约束条件的妥协。这本书的文字风格相当克制,用词精准,没有一句废话,让你感觉每一页的信息密度都高得惊人,需要反复咀嚼才能消化。

评分

对于那些刚接触数据库,或者主要负责应用层开发的同事来说,这本书的阅读门槛可能会稍微高一些。它不是那种教你写出第一个`SELECT * FROM table`的教材,它假设你已经知道SQL的基本语法,并且正在面对更深层次的架构难题。我记得有一部分内容是关于存储过程和函数使用的陷阱,作者用了一个非常形象的比喻,把臃肿的存储过程比作一个“黑箱工厂”,一旦出错,调试的难度呈指数级增长。这个比喻让我醍醐灌顶,因为我们团队内部就有好几个这种被人诟病已久、但没人敢动的“遗留巨兽”。这本书的强大之处在于,它不只是指出了问题,还提供了一套系统性的思维框架来识别和规避这些问题,而不是简单的“这里错了,那里对了”。它引导读者从“功能实现者”转变为“系统守护者”,培养一种对潜在风险的敏锐嗅觉。每次读完其中的一个“反模式”案例,我都会忍不住去检查我们自己的代码库,这种自我审视的过程非常痛苦,但收获是巨大的。这更像是一本“避雷手册”和“高级修炼指南”的结合体,适合希望从“能用”跨越到“健壮”的进阶学习者。

评分

“You can't learn from these mistakes.“ 我觉得里面的反模式真的都好好笑。

评分

所谓的反模式就是开发过程中经常会走进的误区或者说不好的实践,书中指出这些用法会带来哪些问题,在什么情况下使用才算合理,最后给出最佳实践,并解释清楚。尤其最后一章深入挖掘MVC模式中Model的真正含义,非常受用,我算是彻底明白为什么Laravel默认的目录结构里没有Models目录,是因为很多程序员对Model的作用有争议,所以框架把决定权交给程序员。强烈建议每个程序员都读读此书,尤其是PHP程序员,书中的应用程序层的代码示例就是PHP的

评分

讲数据库层的设计模式,讲应用层与数据库层之间的结合开发。 把很多在面向对象设计中的思想融入到关系型数据库的应用开发上。

评分

很不错的小书,快速浏览最合适了。

评分

第一部分8章最重要,很实用,其它的选看。

本站所有内容均为互联网搜索引擎提供的公开搜索信息,本站不存储任何数据与内容,任何内容与数据均与本站无关,如有需要请联系相关搜索引擎包括但不限于百度google,bing,sogou

© 2026 book.wenda123.org All Rights Reserved. 图书目录大全 版权所有