Celko - Thinking in Sets - Auxiliary, Temporal and Virtual Tables in SQL (Elsevier, 2008).pdf

(7345 KB) Pobierz
434707951 UNPDF
JOE CELKO’S
THINKING IN SETS
Auxiliary, Temporal, and
Virtual Tables in SQL
Joe Celko
AMSTERDAM BOSTON HEIDELBERG LONDON
NEW YORK OXFORD PARIS SAN DIEGO
SAN FRANCISCO SINGAPORE SYDNEY TOKYO
Morgan Kaufmann is an imprint of Elsevier
434707951.005.png 434707951.006.png 434707951.007.png
Publisher Denise E. M. Penrose
Publishing Services Manager George Morrison
Project Manager
Marilyn E. Rash
Assistant Editor
Mary E. James
Production Management
Multiscience Press, Inc.
Design Direction
Joanne Blank
Cover Design
Dick Hannus
Typesetting/Illustrations
diacriTech
Interior Printer
Sheridan Books
Cover Printer
Phoenix Color Corp.
Morgan Kaufmann Publishers is an imprint of Elsevier.
30 Corporate Drive, Burlington, MA 01803-4255
This book is printed on acid-free paper.
Copyright © 2008 by Elsevier Inc. All rights reserved.
Designations used by companies to distinguish their products are often claimed as
trademarks or registered trademarks. In all instances in which 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.
No part of this publication may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means—electronic, mechanical, photocopying,
scanning, or otherwise—without prior written permission of the publisher.
Permissions may be sought directly from Elsevier’s Science & Technology Rights
Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail:
permissions@elsevier.com. You may also complete your request on-line via the Elsevier
homepage ( http://elsevier.com ), by selecting “Support & Contact” then “Copyright and
Permission” and then “Obtaining Permissions.”
Library of Congress Cataloging-in-Publication Data
Celko, Joe.
[Thinking in sets]
Joe Celko’s thinking in sets : auxiliary, temporal, and virtual tables in SQL
/ Joe Celko.
p. cm.
Includes index.
ISBN 978-0-12-374137-0 (alk. paper)
1. SQL (Computer program language) 2. Declarative programming. I. Title.
II. Title: Thinking in sets.
QA76.73.S67C463 2008
005.13—dc22 2007043898
For information on all Morgan Kaufmann publications, visit our Web site at
www.mkp.com or www.books.elsevier.com.
Printed in the United States
08 09 10 11 12 10 9 8 7 6 5 4 3 2 1
Working together to grow
libraries in developing countries
www.elsevier.com | www.bookaid.org | www.sabre.org
434707951.008.png 434707951.001.png 434707951.002.png 434707951.003.png
To my god-niece, Olivia. When
we are nished with her board
books, we can start on SQL
manuals before bedtime!
This page intentionally left blank
CONTENTS
Preface
xvii
1 SQL Is Declarative, Not Procedural
1
1.1
Different Programming Models
2
1.2
Different Data Models
4
1.2.1
Columns Are Not Fields
5
1.2.2
Rows Are Not Records
7
1.2.3
Tables Are Not Files
11
1.2.4
Relational Keys Are Not Record Locators
13
1.2.5
Kinds of Keys
15
1.2.6
Desirable Properties of Relational Keys
17
1.2.7
Unique But Not Invariant
18
1.3
Tables as Entities
19
1.4
Tables as Relationships
20
1.5
Statements Are Not Procedures
20
1.6
Molecular, Atomic, and Subatomic Data Elements
21
1.6.1
Table Splitting
21
1.6.2
Column Splitting
22
1.6.3
Temporal Splitting
24
1.6.4
Faking Non-1NF Data
24
1.6.5
Molecular Data Elements
25
1.6.6
Isomer Data Elements
26
1.6.7
Validating a Molecule
27
2 Hardware, Data Volume, and Maintaining Databases
29
2.1
Parallelism
30
2.2
Cheap Main Storage
31
2.3
Solid-State Disk
32
2.4
Cheaper Secondary and Tertiary Storage
32
2.5
The Data Changed
33
2.6
The Mindset Has Not Changed
33
434707951.004.png
Zgłoś jeśli naruszono regulamin