Tải bản đầy đủ

1161 beginning database design

www.it-ebooks.info


Beginning Database Design
Gavin Powell

www.it-ebooks.info


Beginning Database Design

www.it-ebooks.info


www.it-ebooks.info


Beginning Database Design
Gavin Powell

www.it-ebooks.info



Beginning Database Design
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com

Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN-13: 978-0-7645-7490-0
ISBN-10: 0-7645-7490-6
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1B/RV/RR/QV/IN

Library of Congress Control Number is available from the publisher.
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, recording, scanning or otherwise, except as permitted
under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright
Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests
to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc.,
10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://
www.wiley.com/go/permissions.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE
NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS
OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING
WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY
MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND
STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS
SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING
LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS
REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT.
NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A
CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT
THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR
WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE
AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.


For general information on our other products and services or to obtain technical support, please contact our
Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317)
572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not
be available in electronic books.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress
are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and
other countries, and may not be used without written permission. All other trademarks are the property of their
respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.

www.it-ebooks.info


This book is dedicated to Jacqueline — my fondest pride and joy.

www.it-ebooks.info


About the Author
Gavin Powell has a Bachelor of Science degree in Computer Science, with numerous professional
accreditations and skills (including Microsoft Word, PowerPoint, Excel, Windows 2000, ERWin, and
Paintshop, as well as Microsoft Access, Ingres, and Oracle relational databases, plus a multitude of
application development languages). He has almost 20 years of contracting, consulting, and hands-on
educating experience in both software development and database administration roles. He has worked
with all sorts of tools and languages, on various platforms over the years. He has lived, studied, and
worked on three different continents, and is now scratching out a living as a writer, musician, and family
man. He can be contacted at oracledbaexpert@earthlink.net or info@oracledbaexpert.com. His Web site
at http://www.oracledbaexpert.com offers information on database modeling, database software, and
many development languages. Other titles by this author include Oracle Data Warehouse Tuning for 10g
(Burlington, MA: Digital Press, 2005), Oracle 9i: SQL Exam Cram 2 (1Z0-007) (Indianapolis: Que, 2004),
Oracle SQL: Jumpstart with Examples (Burlington, MA: Digital Press, 2004), Oracle Performance Tuning
for 9i and 10g (Burlington, MA: Digital Press, 2003), ASP Scripting (Stephens City, VA: Virtual Training
Company, 2005), Oracle Performance Tuning (Stephens City, VA: Virtual Training Company, 2004), Oracle
Database Administration Fundamentals II (Stephens City, VA: Virtual Training Company, 2004), Oracle
Database Administration Fundamentals I (Stephens City, VA: Virtual Training Company, 2003), and
Introduction to Oracle 9i and Beyond: SQL & PL/SQL (Stephens City, VA: Virtual Training Company, 2003).

www.it-ebooks.info


Credits
Senior Acquisitions Editor

Vice President and Publisher

Jim Minatel

Joseph B. Wikert

Development Editor

Project Coordinator

Kevin Shafer

Michael Kruzil

Technical Editor

Graphics and Production Specialists

David Mercer

Jonelle Burns
Carrie A. Foster
Denny Hager
Joyce Haughey
Jennifer Heleine
Alicia B. South

Production Editor
Pamela Hanley

Copy Editor
Susan Hobbs

Quality Control Technicians
Laura Albert
Leeann Harney
Joe Niesen

Editorial Manager
Mary Beth Wakefield

Production Manager
Tim Tate

Proofreading and Indexing
TECHBOOKS Production Services

Vice President & Executive Group Publisher
Richard Swadley

www.it-ebooks.info


www.it-ebooks.info


Contents
Introduction

xvii

Part I: Approaching Relational Database Modeling

1

Chapter 1: Database Modeling Past and Present

3

Grasping the Concept of a Database
Understanding a Database Model
What Is an Application?

4
5
5

The Evolution of Database Modeling
File Systems
Hierarchical Database Model
Network Database Model
Relational Database Model

6
7
8
8
9

Relational Database Management System
The History of the Relational Database Model

11
11

Object Database Model
Object-Relational Database Model

12
14

Examining the Types of Databases

14

Transactional Databases
Decision Support Databases
Hybrid Databases

15
15
16

Understanding Database Model Design
Defining the Objectives
Looking at Methods of Database Design

Summary

16
17
20

21

Chapter 2: Database Modeling in the Workplace
Understanding Business Rules and Objectives
What Are Business Rules?
The Importance of Business Rules

Incorporating the Human Factor
People as a Resource
Talking to the Right People
Getting the Right Information

23
24
25
26

27
27
29
30

www.it-ebooks.info


Contents
Dealing with Unfavorable Scenarios

32

Computerizing a Pile of Papers
Converting Legacy Databases
Homogenous Integration of Heterogeneous Databases
Converting from Spreadsheets
Sorting Out a Messed-up Database

32
33
33
33
34

Summary

34

Chapter 3: Database Modeling Building Blocks
Information, Data and Data Integrity
Understanding the Basics of Tables

35
37
37

Records, Rows, and Tuples
Fields, Columns and Attributes
Datatypes

39
40
42

Simple Datatypes
Complex Datatypes
Specialized Datatypes

42
46
47

Constraints and Validation

47

Understanding Relations for Normalization
Benefits of Normalization
Potential Normalization Hazards

48
49
49

Representing Relationships in an ERD
Crows Foot
One-to-One
One-to-Many
Many-to-Many
Zero, One, or Many
Identifying and Non-Identifying Relationships

Understanding Keys

49
50
51
52
53
55
57

58

Primary Keys
Unique Keys
Foreign Keys
Understanding Referential Integrity

59
59
60
63

Understanding Indexes

64

What Is an Index?
Alternate Indexing
Foreign Key Indexing
Types of Indexes
Different Ways to Build Indexes

65
65
65
66
68

Introducing Views and Other Specialized Objects
Summary
Exercises

x
www.it-ebooks.info

69
70
70


Contents
Part II: Designing Relational Database Models

71

Chapter 4: Understanding Normalization

73

What Is Normalization?

74

The Concept of Anomalies
Dependency, Determinants, and Other Jargon
Defining Normal Forms
Defining Normal Forms the Academic Way
Defining Normal Forms the Easy Way

74
76
80
80
81

1st Normal Form (1NF)

82

1NF the Academic Way
1NF the Easy Way

82
83

2nd Normal Form (2NF)

89

2NF the Academic Way
2NF the Easy Way

89
89

3rd Normal Form (3NF)

96

3NF the Academic Way
3NF the Easy Way

96
97

Beyond 3rd Normal Form (3NF)
Why Go Beyond 3NF?
Beyond 3NF the Easy Way

103
104
104

One-to-One NULL Tables

104

Beyond 3NF the Academic Way
Boyce-Codd Normal Form (BCNF)
4th Normal Form (4NF)
5th Normal Form (5NF)
Domain Key Normal Form (DKNF)

Summary
Exercises

107
108
111
116
121

122
122

Chapter 5: Reading and Writing Data with SQL
Defining SQL

123
124

The Origins of SQL
SQL for Different Databases

125
125

The Basics of SQL

126

Querying a Database Using SELECT

127

Basic Queries
Filtering with the WHERE Clause
Precedence
Sorting with the ORDER BY Clause

127
130
132
134

xi
www.it-ebooks.info


Contents
Aggregating with the GROUP BY Clause
Join Queries
Nested Queries
Composite Queries

135
137
141
143

Changing Data in a Database
Understanding Transactions
Changing Database Metadata

144
144
145

Summary
Exercises

148
149

Chapter 6: Advanced Relational Database Modeling
Understanding Denormalization

152

Reversing Normal Forms
Denormalizing
Denormalizing
Denormalizing
Denormalizing

151
152

Beyond 3NF
3NF
2NF
1NF

153
157
160
161

Denormalization Using Specialized Database Objects
Denormalization Tricks

162
163

Understanding the Object Model
Introducing the Data Warehouse Database Model
Summary
Exercises

165
167
169
170

Chapter 7: Understanding Data Warehouse Database Modeling
The Origin of Data Warehouses

171
172

The Relational Database Model and Data Warehouses
Surrogate Keys in a Data Warehouse
Referential Integrity in a Data Warehouse

The Dimensional Database Model

173
174
174

175

What Is a Star Schema?
What Is a Snowflake Schema?

176
178

How to Build a Data Warehouse Database Model
Data Warehouse Modeling Step by Step
How Long to Keep Data in a Data Warehouse?
Types of Dimension Tables
Understanding Fact Tables

Summary
Exercises

182
183
183
184
190

191
192

xii
www.it-ebooks.info


Contents
Chapter 8: Building Fast-Performing Database Models
The Needs of Different Database Models
Factors Affecting OLTP Database Model Tuning
Factors Affecting Client-Server Database Model Tuning
Factors Affecting Data Warehouse Database Model Tuning
Understanding Database Model Tuning

Writing Efficient Queries

193
194
194
195
196
197

198

The SELECT Command
Filtering with the WHERE Clause
The HAVING and WHERE Clauses
Joins
Auto Counters

200
202
204
205
206

Efficient Indexing for Performance

206

Types of Indexes
How to Apply Indexes in the Real World
When Not to Use Indexes

Using Views
Application Caching
Summary
Exercises

210
211
212
213

Part III: A Case Study in Relational Database Modeling
Chapter 9: Planning and Preparation Through Analysis
Steps to Creating a Database Model
Step
Step
Step
Step

1:
2:
3:
4:

207
207
209

215
217
219

Analysis
Design
Construction
Implementation

219
220
220
220

Understanding Analysis

221

Analysis Considerations
Potential Problem Areas and Misconceptions

222
224

Normalization and Data Integrity
More Normalization Leads to Better Queries
Performance
Generic and Standardized Database Models

224
224
224
225

Putting Theory into Practice

225

Putting Analysis into Practice
Company Objectives

225
226

xiii
www.it-ebooks.info


Contents
Case Study: The OLTP Database Model

229

Establishing Company Operations
Discovering Business Rules

229
232

Case Study: The Data Warehouse Model
Establishing Company Operations
Discovering Business Rules

243
244
248

Project Management

253

Project Planning and Timelines
Budgeting

253
255

Summary
Exercises

256
257

Chapter 10: Creating and Refining Tables During the Design Phase
A Little More About Design
Case Study: Creating Tables

259
260
262

The OLTP Database Model
The Data Warehouse Database Model

262
265

Case Study: Enforcing Table Relationships
Referential Integrity
Primary and Foreign Keys
Using Surrogate Keys
Identifying versus Non-Identifying Relationships
Parent Records without Children
Child Records with Optional Parents
The OLTP Database Model with Referential Integrity
The Data Warehouse Database Model with Referential Integrity

Normalization and Denormalization

269
269
270
271
272
272
273
274
279

282

Case Study: Normalizing an OLTP Database Model
Denormalizing 2NF
Denormalizing 3NF
Denormalizing 1NF
Denormalizing 3NF Again
Deeper Normalization Layers

283
284
285
286
287
289

Case Study: Backtracking and Refining an OLTP Database Model
Example Application Queries

295
298

Case Study: Refining a Data Warehouse Database Model

Summary
Exercises

308

316
317

xiv
www.it-ebooks.info


Contents
Chapter 11: Filling in the Details with a Detailed Design

319

Case Study: Refining Field Structure

320

The OLTP Database Model
The Data Warehouse Database Model

320
323

Understanding Datatypes

329

Simple Datatypes
ANSI (American National Standards Institute) Datatypes
Microsoft Access Datatypes
Specialized Datatypes
Case Study: Defining Datatypes
The OLTP Database Model
The Data Warehouse Database Model

329
330
331
331
332
332
336

Understanding Keys and Indexes

338

Types of Indexes
What, When, and How to Index
When Not to Create Indexes
Case Study: Alternate Indexing

339
342
342
343

The OLTP Database Model
The Data Warehouse Database Model

Summary
Exercises

343
345

352
352

Chapter 12: Business Rules and Field Settings

353

What Are Business Rules Again?
Classifying Business Rules in a Database Model

354
355

Normalization, Normal Forms, and Relations
Classifying Relationship Types
Explicitly Declared Field Settings
Storing Code in the Database
Stored Procedure
Stored Function
Event Trigger
External Procedure
Macro

355
356
357
358
360
362
363
364
364

Case Study: Implementing Field Level Business Rules in a Database Model
Table and Relation Level Business Rules
Individual Field Business Rules
Field Level Business Rules for the OLTP Database Model
Field Level Business Rules for the Data warehouse Database Model

364
364
364
364
370

xv
www.it-ebooks.info


Contents
Encoding Business Rules

373

Encoding Business Rules for the OLTP Database Model
Encoding Business Rules for the Data Warehouse Database Model

Summary

373
374

379

Part IV: Advanced Topics

381

Chapter 13: Advanced Database Structures and Hardware Resources
Advanced Database Structures

383
384

What and Where?

384

Views
Materialized Views
Indexes
Clusters
Auto Counters
Partitioning and Parallel Processing

384
384
385
385
385
385

Understanding Views
Understanding Materialized Views
Understanding Types of Indexes

386
387
390

BTree Index
Bitmap Index
Hash Keys and ISAM Keys
Clusters, Index Organized Tables, and Clustered Indexes

Understanding Auto Counters
Understanding Partitioning and Parallel Processing

391
392
393
393

393
393

Understanding Hardware Resources

396

How Much Hardware Can You Afford?
How Much Memory Do You Need?

396
396

Understanding Specialized Hardware Architectures
RAID Arrays
Standby Databases
Replication
Grids and Computer Clustering

396
397
397
399
400

Summary

401

Glossary

403

Appendix A: Exercise Answers

421

Appendix B: Sample Databases

435

Index

443

xvi
www.it-ebooks.info


Introduction
This book focuses on the relational database model from a beginning perspective. The title is, therefore,
Beginning Database Design. A database is a repository for data. In other words, you can store lots of information in a database. A relational database is a special type of database using structures called tables.
Tables are linked together using what are called relationships. You can build tables with relationships
between those tables, not only to organize your data, but also to allow later retrieval of information from
the database.
The process of relational database model design is the method used to create a relational database model.
This process is mathematical in nature, but very simple, and is called normalization. With the process of
normalization are a number of distinct steps called Normal Forms. Normal Forms are: 1st Normal Form
(1NF), 2nd Normal Form (2NF), 3rd Normal Form (3NF), Boyce-Codd Normal Form (BCNF), 4th Normal
Form (4NF), 5th Normal Form (5NF), and Domain Key Normal Form (DKNF). That is quite a list. This
book presents the technical details of normalization and Normal Forms, in addition to presenting a layman’s version of normalization. Purists would argue that this approach is sacrilegious. The problem
with normalization is that it is so precise by attempting to cater to every possible scenario. The result is
that normalization is often misunderstood and quite frequently ignored. The result is poorly designed
relational database models. A simplified version tends to help bridge a communication gap, and perhaps
prepare the way for learning the precise definition of normalization, hopefully lowering the incline of
the learning curve.
Traditionally, relational database model design (and particularly the topic of normalization), has been
much too precise for commercial environments. There is an easy way to interpret normalization, and this
book contains original ideas in that respect.
You should read this book because these ideas on relational database model design and normalization
techniques will help you in your quest for perhaps even just a little more of an understanding as to how
your database works. The objective here is to teach you to make much better use of that wonderful
resource you have at your fingertips — your personal or company database.

Who This Book Is For
People who would benefit from reading this book would be anyone involved with database technology,
from the novice all the way through to the expert. This includes database administrators, developers, data
modelers, systems or network administrators, technical managers, marketers, advertisers, forecasters,
planners — anyone. This book is intended to explain to the people who actually make use of database
data (such as in a data warehouse) to make forecasting predictions for market research and otherwise.
This book is intended for everyone. If you wanted some kind of clarity as to the funny diagrams you find
in your Microsoft Access database (perhaps built for you by a programmer), this book will do it for you.
If you want to know what on earth is all that stuff in the company SQL-Server or Oracle database, this
book is a terrific place to start — giving just enough understanding without completely blowing your
mind with too much techno-geek-speak.

www.it-ebooks.info


Current Head
Introduction
To find further information, the easiest place to search is the Internet. Search for a
term such as “first normal form,” or “1st normal form,” or “1NF,” in search engines
such as http://www.yahoo.com. Be aware that not all information will be current
and might be incorrect. Verify by crosschecking between multiple references. If no
results are found using Yahoo, try the full detailed listings on http://www.google
.com. Try http://www.amazon.com and http://www.barnesandnoble.com where
other relational database modeling titles can be found.

What This Book Covers
The objective of this book is to provide an easy to understand, step-by-step, simple explanation of
designing and building relational database models. Plenty of examples are offered, and even a multiple
chapter case study scenario is included, really digging into and analyzing all the details. All the scary,
deep-level technical details are also here—hopefully with enough examples and simplistic explanatory
detail to keep you hooked and absorbed, from cover to cover.
As with all of the previous books by this author, this book presents something that appears to be
immensely complex in a simplistic and easy to understand manner. The profligate use of examples
and step-by-step explanations builds the material into the text.

Note that the content of this book is made available “as is.” The author assumes no
responsibility or liability for any mishaps as a result of using this information, in
any form or environment.

How This Book Is Structured
This book is divided into four parts. Each part contains chapters with related material. The book begins
by describing the basics behind relational database modeling. It then progresses onto the theory with
which relational database models are built. The third part performs a case study across four entire chapters, introducing some new concepts, as the case study progresses. In Part IV, new concepts described in
the case study chapters are not directly related to relational database modeling theory. The last part
describes some advanced topics.
It is critical to read the parts in the order in which they appear in the book. Part I examines historical
aspects, describing why the relational database model became necessary. Part II goes through all the theory grounding relational database modeling. You need to know why the relational database model was
devised (from Part I), to fully understand theory covered in Part II. After all the history and theories are
understood, you can begin with the case study in Part III. The case study applies all that you have
learned from Part I and Part II, particularly Part II. Part IV contains detail some unusual information,
related to previous chapters by expanding into rarely used database structures and hardware resource
usage.

xviii
www.it-ebooks.info


Current
Introduction
Head
This book contains a glossary, allowing for the rapid look up of terms without having to page through
the index and the book to seek explicit definitions.






Part I: Approaching Relational Database Modeling — Part I examines the history of relational
database modeling. It describes the practical needs the relational database model fulfilled. Also
included are details about dealing with people, extracting information from people and existing
systems, problematic scenarios, and business rules.


Chapter 1: Database Modeling Past and Present — This chapter introduces basic concepts
behind database modeling, including the evolution of database modeling, different
types of databases, and the very beginnings of how to go about building a database
model.



Chapter 2: Database Modeling in the Workplace — This chapter describes how to approach
the designing and building of a database model. The emphasis is on business rules and
objectives, people and how to get information from them, plus handling of awkward
and difficult existing database scenarios.



Chapter 3: Database Modeling Building Blocks — This chapter introduces the building
blocks of the relational database model by discussing and explaining all the various
parts and pieces making up a relational database model. This includes tables, relationships between tables, and fields in tables, among other topics.

Part II: Designing Relational Database Models — Part II discusses relational database modeling
theory formally, and in detail. Topics covered are normalization, Normal Forms and their application, denormalization, data warehouse database modeling, and database model performance.


Chapter 4: Understanding Normalization — This chapter examines the details of the normalization process. Normalization is the sequence of steps (normal forms) by which a
relational database model is both created and improved upon.



Chapter 5: Reading and Writing Data with SQL — This chapter shows how the relational
database model is used from an application perspective. A relational database model
contains tables. Records in tables are accessed using Structured Query Language (SQL).



Chapter 6: Advanced Relational Database Modeling — This chapter introduces denormalization, the object database model, and data warehousing.



Chapter 7: Understanding Data Warehouse Database Modeling — This chapter discusses
data warehouse database modeling in detail.



Chapter 8: Building Fast-Performing Database Models — This chapter describes various factors affecting database performance tuning, as applied to different database model
types. If performance is not acceptable, your database model does not service the endusers in an acceptable manner.

Part III: A Case Study in Relational Database Modeling — The case study applies all the formal theory learned in Part I and Part II—particularly Part II. The case study is demonstrated across four
entire chapters, introducing some new concepts as the case study progresses. The case study is a
steady, step-by-step learning process, using a consistent example relational database model for
an online auction house company. The case study introduces new concepts, such as analysis and
design of database models. Analysis and design are non-formal, loosely defined processes, and
are not part of relational database modeling theory.

xix
www.it-ebooks.info


Current Head
Introduction


Chapter 9: Planning and Preparation Through Analysis — This chapter analyzes a relational
database model for the case study (the online auction house company) from a company
operational capacity (what a company does for a living). Analysis is the process of
describing what is required of a relational database model — discovering what is the
information needed in a database (what all the basic tables are).



Chapter 10: Creating and Refining Tables During the Design Phase — This chapter describes
the design of a relational database model for the case study. Where analysis describes
what is needed, design describes how it will be done. Where analysis described basic
tables in terms of company operations, design defines relationships between tables, by
the application of normalization and Normal Form, to analyzed information.



Chapter 11: Filling in the Details with a Detailed Design — This chapter continues the
design process for the online auction house company case study — refining fields in
tables. Field design refinement includes field content, field formatting, and indexing
on fields.



Chapter 12: Business Rules and Field Settings — This chapter is the final of four chapters
covering the case study design of the relational database model for the online auction
house company. Business rules application to design encompasses stored procedures,
as well as specialized and very detailed field formatting and restrictions.



Part IV: Advanced Topics —Part IV contains a single chapter that covers details on advanced
database structures (such as materialized views), followed by brief information on hardware
resource usage (such as RAID arrays).



Appendices — Appendix A contains exercise answers for all exercises found at the end of many
chapters ion this book. Appendix B contains a single Entity Relationship Diagram (ERD) for
many of the relational database models included in this book.

What You Need to Use This Book
This book does not require the use on any particular software tool — either database vendor-specific or
front-end application tools. The topic of this book is relational database modeling, meaning the content
of the book is not database vendor-specific. It is the intention of this book to provide non-database vendor specific subject matter. So if you use a Microsoft Access database, dBase database, Oracle Database,
MySQL, Ingres, or any relational database — it doesn’t matter. All of the coding in this book is written
intentionally to be non-database specific, vendor independent, and as pseudo code, most likely matching American National Standards Institute (ASNI) SQL coding standards.
You can attempt to create structures in a database if you want, but the scripts may not necessarily work
in any particular database. For example, with Microsoft Access, you don’t need to create scripts to create
tables. Microsoft Access uses a Graphical User Interface (GUI), allowing you to click, drag, drop, and
type in table and field details. Other databases may force use of scripting to create tables.
The primary intention of this book is to teach relational database modeling in a step-by-step process. It is
not about giving you example scripts that will work in any relational database. There is no such thing as
universally applicable scripting — even with the existence of ANSI SQL standards because none of the
relational database vendors stick to ANSI standards.

xx
www.it-ebooks.info


Current
Introduction
Head
This book is all about showing you how to build the database model — in pictures of Entity Relationship
Diagrams (ERDs). All you need to read and use this book are your eyes, concentration, and fingers to
turn the pages.
Any relational database can be used to create the relational database models in this book. Some adaptation of scripts is required if your chosen database engine does not have a GUI table creation tool.

Conventions
To help you get the most from the text and keep track of what’s happening, a number of conventions are
used throughout the book.
Examples that you can download and try out for yourself generally appear in a box like this:
Example title

This section gives a brief overview of the example.

Source
This section includes the source code.
Source code
Source code
Source code

Output
This section lists the output:
Example output
Example output
Example output

Try It Out
Try It Out is an exercise you should work through, following the text in the book.

1.
2.
3.

They usually consist of a set of steps.
Each step has a number.
Follow the steps through one by one.

How It Works
After each Try It Out, the code you’ve typed is explained in detail.

xxi
www.it-ebooks.info


Current Head
Introduction
Boxes like this one hold important, not-to-be forgotten information that is directly
relevant to the surrounding text.

Tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.
As for styles in the text:


New terms and important words are italicized when introduced.



Keyboard strokes are shown like this: Ctrl+A.



File names, URLs, and code within the text are shown like so: persistence.properties.



Code is presented in two different ways:

In code examples we highlight new and important code with a gray background.
The gray highlighting is not used for code that’s less important in the present
context, or has been shown before.

Syntax Conventions
Syntax diagrams in this book use Backus-Naur Form syntax notation conventions. Backus-Naur Form
has become the de facto standard for most computer texts.


Angle Brackets: < ... > — Angle brackets are used to represent names of categories, also known as
substitution variable representation. In this example is replaced with a table name:

SELECT * FROM
;

Becomes:
SELECT * FROM AUTHOR;



OR: | — A pipe or | character represents an OR conjunction meaning either can be selected. In
this case all or some fields can be retrieved, some meaning one or more:

SELECT { * | { , ... } } FROM
;



Optional: [ ... ] — In a SELECT statement a WHERE clause is syntactically optional:

SELECT * FROM
[ WHERE = ... ];



At least One Of: { ... | ... | ... } — For example, the SELECT statement must include one of *, or a
list of one or more fields:

SELECT { * | { , ... } } FROM
;

This is a not precise interpretation of Backus-Naur Form, where curly braces usually represent zero or
more. In this book curly braces represent one or more iterations, never zero.

xxii
www.it-ebooks.info


Current
Introduction
Head

Errata
Every effort has been made to ensure that there are no errors in the text or in the code; however, no one
is perfect, and mistakes do occur. If you find an error in one of our books, such as a spelling mistake or
faulty piece of code, your feedback would be greatly appreciated. By sending in errata you may save
another reader hours of frustration and at the same time you will be helping us provide even higher
quality information.
To find the errata page for this book, go to http://www.wrox.com and locate the title using the Search box
or one of the title lists. On the book details page, click the Book Errata link. On this page you can view all
errata that has been submitted for this book and posted by Wrox editors. A complete book list including
links to each book’s errata is also available at www.wrox.com/misc-pages/booklist.shtml.
If you don’t spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport
.shtml and complete the form there to send the error you have found. The information will be checked
and, if appropriate, a message will be posted to the book’s errata page and the problem will be fixed in
subsequent editions of the book.

p2p.wrox.com
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other
readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of
your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts,
and your fellow readers are present on these forums.
At http://p2p.wrox.com you will find a number of different forums that will help you not only as
you read this book, but also as you develop your own applications. To join the forums, follow these
steps:

1.
2.
3.

Go to p2p.wrox.com and click the Register link.
Read the terms of use and click Agree.
Complete the required information to join as well as any optional information you want to provide and click Submit.

You will receive an e-mail with information describing how to verify your account and complete the
joining process.
You can read messages in the forums without joining P2P, but you must join to post your own messages.
After you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed
to you, click the Subscribe to this Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox
books. To read the FAQs, click the FAQ link on any P2P page.

xxiii
www.it-ebooks.info


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×