Data and Databases Concepts in Practice.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Release Team[oR] 2001 [x] Database Joe Celko's Data and Databases: Concepts in Practice ISBN: 1558604324 by Joe Celko Morgan Kaufmann Publishers © 1999, 382 pages A "big picture" look at database design and programming for all levels of developers. Table of Contents Colleague Comments Back Cover Synopsis by Dean Andrews In this book, outspoken database magazine columnist Joe Celko waxes philosophic about fundamental concepts in database design and development. He points out misconceptions and plain ol' mistakes commonly made while creating databases including mathematical calculation errors, inappropriate key field choices, date representation goofs and more. Celko also points out the quirks in SQL itself. A detailed table-of-contents will quickly route you to your area of interest. Table of Contents Joe Celko’s Data and Databases: Concepts in Practice - 4 Preface - 6 Chapter 1 - The Nature of Data - 13 Chapter 2 - Entities, Attributes, Values, and Relationships - 23 Chapter 3 - Data Structures - 31 Chapter 4 - Relational Tables - 49 Chapter 5 - Access Structures - 69 Chapter 6 - Numeric Data - 84 Chapter 7 - Character String Data - 92 Chapter 8 - Logic and Databases - 104 Chapter 9 - Temporal Data - 123 Chapter 10 - Textual Data - 131 Chapter 11 - Exotic Data - 135 Chapter 12 - Scales and Measurements - 146 Chapter 13 - Missing Data - 151 Chapter 14 - Data Encoding Schemes - 163 - 2 - Chapter 15 - Check Digits - 163 Chapter 16 - The Basic Relational Model - 178 Chapter 17 - Keys - 188 Chapter 18 - Different Relational Models - 202 Chapter 19 - Basic Relational Operations - 205 Chapter 20 - Transactions and Concurrency Control - 207 Chapter 21 - Functional Dependencies - 214 Chapter 22 - Normalization - 217 Chapter 23 - Denormalization - 238 Chapter 24 - Metadata - 252 References - 258 Back Cover Do you need an introductory book on data and databases? If the book is by Joe Celko, the answer is yes. Data & Databases: Concepts in Practice is the first introduction to relational database technology written especially for practicing IT professionals. If you work mostly outside the database world, this book will ground you in the concepts and overall framework you must master if your data-intensive projects are to be successful. If you’re already an experienced database programmer, administrator, analyst, or user, it will let you take a step back from your work and examine the founding principles on which you rely every day -- helping you work smarter, faster, and problem- free. Whatever your field or level of expertise, Data & Databases offers you the depth and breadth of vision for which Celko is famous. No one knows the topic as well as he, and no one conveys this knowledge as clearly, as effectively -- or as engagingly. Filled with absorbing war stories and no-holds- barred commentary, this is a book you’ll pick up again and again, both for the information it holds and for the distinctive style that marks it as genuine Celko. Features: • Supports its extensive conceptual information with example code and other practical illustrations. • Explains fundamental issues such as the nature of data and data modeling and moves to more specific technical questions such as scales, measurements, and encoding. • Offers fresh, engaging approaches to basic and not-so-basic issues of database programming, including data entities, relationships and values, data structures, set operations, numeric data, character string data, logical data and operations, and missing data. • Covers the conceptual foundations of modern RDBMS technology, making it an ideal choice for students. About the Author - 3 - Joe Celko is a noted consultant, lecturer, writer, and teacher, whose column in Intelligent Enterprise has won several Reader’s Choice Awards. He is well known for his ten years of service on the ANSI SQL standards committee, his dependable help on the DBMS CompuServe Forum, and, of course, his war stories, which provide real-world insight into SQL programming. Joe Celko’s Data and Databases: Concepts in Practice Joe Celko Senior Editor: Diane D. Cerra Director of Production and Manufacturing: Yonie Overton Production Editor: Cheri Palmer Editorial Coordinator: Belinda Breyer Cover and Text Design: Side by Side Studios Cover and Text Series Design: ThoughtHouse, Inc. Copyeditor: Ken DellaPenta Proofreader: Jennifer McClain Composition: Nancy Logan Illustration: Cherie Plumlee Indexer: Ty Koontz Printer: Courier Corporation Designations used by companies to distinquish their products are often claimed as trademarks or registered trademarks. In all instances where Morgan Kaufmann Publishers is aware of a claim, the product names appear in initial capital or all capital letters. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration. Morgan Kaufmann Publishers Editorial and Sales Office 340 Pine Street, Sixth Floor San Francisco, CA 94104-3205 USA Telephone: 415/392-2665 Facsimile: 415-982-2665 E-mail: [email protected] www: http://www.mkp.com Order toll free: 800/745-7323 © 1999 by Morgan Kaufmann Publishers All rights reserved - 4 - Printed in the United States of America To my father, Joseph Celko Sr., and to my daughters, Takoga Stonerock and Amanda Pattarozzi Preface Overview This book is a collection of ideas about the nature of data and databases. Some of the material has appeared in different forms in my regular columns in the computer trade and academic press, on CompuServe forum groups, on the Internet, and over beers at conferences for several years. Some of it is new to this volume. This book is not a complete, formal text about any particular database theory and will not be too mathematical to read easily. Its purpose is to provide foundations and philosophy to the working programmer so that they can understand what they do for a living in greater depth. The topic of each chapter could be a book in itself and usually has been. This book is supposed to make you think and give you things to think about. Hopefully, it succeeds. Thanks to my magazine columns in DBMS, Database Programming & Design, Intelligent Enterprise, and other publications over the years, I have become the apologist for ANSI/ISO standard SQL. However, this is not an SQL book per se. It is more oriented toward the philosophy and foundations of data and databases than toward programming tips and techniques. However, I try to use the ANSI/ISO SQL-92 standard language for examples whenever possible, occasionally extending it when I have to invent a notation for some purpose. If you need a book on the SQL-92 language, you should get a copy of Understanding the New SQL, by Jim Melton and Alan Simon (Melton and Simon 1993). Jim’s other book, Understanding SQL’s Stored Procedures (Melton 1998), covers the procedural language that was added to the SQL-92 standard in 1996. If you want to get SQL tips and techniques, buy a copy of my other book, SQL for Smarties (Celko 1995), and then see if you learned to use them with a copy of SQL Puzzles & Answers (Celko 1997). Organization of the Book The book is organized into nested, numbered sections arranged by topic. If you have a problem and want to look up a possible solution now, you can go to the index or table of contents and thumb to the right section. Feel free to highlight the parts you need and to write notes in the margins. I hope that the casual conversational style of the book will serve you well. I simply did not have the time or temperament to do a formal text. If you want to explore the more formal side of the issues I raise, I have tried to at least point you toward detailed references. - 5 - Corrections and Future Editions I will be glad to receive corrections, comments, and other suggestions for future editions of this book. Send your ideas to Joe Celko 235 Carter Avenue Atlanta, GA 30317-3303 email: [email protected] website: www.celko.com or contact me through the publisher. You could see your name in print! Acknowledgments I’d like to thank Diane Cerra of Morgan Kaufmann and the many people from CompuServe forum sessions and personal letters and emails. I’d also like to thank all the members of the ANSI X3H2 Database Standards Committee, past and present. Chapter 1: The Nature of Data Where is the wisdom? Lost in the knowledge. Where is the knowledge? Lost in the information. —T. S. Eliot Where is the information? Lost in the data. Where is the data? Lost in the #@%&! database! — Joe Celko Overview So I am not the poet that T. S. Eliot is, but he probably never wrote a computer program in his life. However, I agree with his point about wisdom and information. And if he knew the distinction between data and information, I like to think that he would have agreed with mine. I would like to define “data,” without becoming too formal yet, as facts that can be represented with measurements using scales or with formal symbol systems within the context of a formal model. The model is supposed to represent something called “the real world” in such a way that changes in the facts of “the real world” are reflected by changes in the database. I will start referring to “the real world” as “the reality” for a model from now on. The reason that you have a model is that you simply cannot put the real world into a computer or even into your own head. A model has to reflect the things that you think are important in the real world and the entities and properties that you wish to manipulate and predict. - 6 - I will argue that the first databases were the precursors to written language that were found in the Middle East (see Jean 1992). Shepherds keeping community flocks needed a way to manipulate ownership of the animals, so that everyone knew who owned how many rams, ewes, lambs, and whatever else.