Tài liệu SQL Antipatterns: Avoiding the Pitfalls of Database Programming pdf

334 3.7K 12
Tài liệu SQL Antipatterns: Avoiding the Pitfalls of Database Programming pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... Limitations Since each entry is in a separate row in the intersection table, the list is limited only by the number of rows that can physically exist in one table If it’s appropriate to limit the number of entries, you should enforce the policy in your application using the count of entries rather than the collective length of the list Other Advantages of the Intersection Table An index on Contacts.account_id... widespread programmer misconceptions Other topics may be new to you I hope you can improve your SQL programming habits by reading them If you are a trained database administrator, you may already know the best ways to avoid the SQL pitfalls described in this book This book can help you by introducing you to the perspective of software developers It’s not uncommon for the relationship between developers... patterns and antipatterns names that serve as a metaphor or mnemonic The appendix provides practical descriptions of some relational database theory Many of the antipatterns this book covers are the result of misunderstanding database theory Anatomy of an Antipattern Each antipattern chapter contains the following subheadings: Objective This is the task that you may be trying to solve Antipatterns are used... yourself or others saying, can tip you off to the presence of an antipattern Legitimate Uses of the Antipattern Rules usually have exceptions There may be circumstances in which an approach normally considered an antipattern is nevertheless appropriate, or at least the lesser of all evils Solution This section describes the preferred solutions, which solve the original objective without running into the problems... about performance issues related to database programming I recommend SQL Performance Tuning [GP03] and High Performance MySQL, Second Edition [SZT+ 08] Some of the topics in SQL Antipatterns are relevant to performance, but it’s not the main focus of the book I try to present issues that apply to all database brands and also solutions that should work with all brands The SQL language is specified as an ANSI... examples, see Figure 1.1, on the following page 1.5 Example Database I illustrate most of the topics in SQL Antipatterns using a database for a hypothetical bug-tracking application The entity-relationship diagram for this database is shown in Figure 1.2, on page 21 Notice the three connections between the Bugs table and the Accounts table, representing three separate foreign keys The following data definition... experience with SQL seems to be a common one for software developers, even those who have a college degree in computer science Most people are self-taught in SQL, learning it out of self-defense when they find themselves working on a project that requires it, instead of studying it explicitly as they would most programming languages Regardless of whether the person is a hobbyist or a professional programmer... have a number of children and one parent The top node, which has no parent, is called the root The nodes at the bottom, which have no children, are called leaves The nodes in the middle are simply nonleaf nodes In the previous hierarchical data, you may need to query individual items, related subsets of the collection, or the whole collection Examples of tree-oriented data structures include the following:... true, but they certainly belie the complexity and depth of their subjects To support execution of that single SQL statement, I realized I would W HO T HIS B OOK I S F OR have to develop all the code for a fully functional relational database management system and query engine I declined this opportunity to code an SQL parser and RDBMS engine in shell script The manager underrepresented the scope of his... language shows how I define the tables In some cases, choices are made for the sake of examples later in the book, so they might not always be the choices one would make in a real-world application I try to use only standard SQL so the example is applicable to any brand of database, but some MySQL data types also appear, such as SERIAL and BIGINT Download Introduction/setup .sql CREATE TABLE Accounts . Thorpe Microsoft Principal Engineer; Author of Delphi Component Design SQL Antipatterns Avoiding the Pitfalls of Database Programming Bill Karwin The Pragmatic. like “an SQL query,” not “a SQL query.” In the context of database- related usage, the word index refers to an ordered collection of information. The preferred

Ngày đăng: 17/02/2014, 11:20

Từ khóa liên quan

Mục lục

  • Contents

  • Introduction

    • Who This Book Is For

    • What's in This Book

    • What's Not in This Book

    • Conventions

    • Example Database

    • Acknowledgments

    • Logical Database Design Antipatterns

      • Jaywalking

        • Objective: Store Multivalue Attributes

        • Antipattern: Format Comma-Separated Lists

        • How to Recognize the Antipattern

        • Legitimate Uses of the Antipattern

        • Solution: Create an Intersection Table

        • Naive Trees

          • Objective: Store and Query Hierarchies

          • Antipattern: Always Depend on One's Parent

          • How to Recognize the Antipattern

          • Legitimate Uses of the Antipattern

          • Solution: Use Alternative Tree Models

          • ID Required

            • Objective: Establish Primary Key Conventions

            • Antipattern: One Size Fits All

            • How to Recognize the Antipattern

Tài liệu cùng người dùng

Tài liệu liên quan