212 Appendix A Getting Started with Microsoft SQL Server.. 217 Appendix B Getting Started with MySQL.. Appendix C Getting Started with Oracle.. 225 Installing Oracle Database Express Edi
Trang 1Correlated Subquery Updates 181
Looking Ahead 183
Chapter 18 Maintaining Tables 185
Data Definition Language 185
Table Attributes 186
Table Columns 187
Primary Keys and Indexes 188
Foreign Keys 189
Creating Tables 190
Creating Indexes 192
Looking Ahead 192
Chapter 19 Principles of Database Design 195
Goals of Normalization 196
How to Normalize Data 198
The Art of Database Design 202
Alternatives to Normalization 203
Looking Ahead 205
Chapter 20 Strategies for Displaying Data 207
Beyond SQL 207
Reporting Tools and Crosstab Reports 208
Spreadsheets and Pivot Tables 210
Looking Ahead 212
Appendix A Getting Started with Microsoft SQL Server 215
Overview 215
Installing SQL Server Express 2008 215
Installing SQL Server Management Studio 216
Using SQL Server Management Studio 217
Appendix B Getting Started with MySQL 219
Overview 219
Installing MySQL Community Server 220
Installing MySQL Workbench 221
Using MySQL Workbench 222
Trang 2Appendix C Getting Started with Oracle 225
Overview 225
Installing Oracle Database Express Edition 225
Using Oracle Database Express Edition 227
Appendix D Listing of All SQL Statements 229
Index 231
Trang 3Research has shown that, being pressed for time, most readers tend to skip the introduction of any book they happen to read and then proceed immediately to the first real chapter.
With that fact firmly in mind, we will only cover relatively unimportant material
in the introduction, such as an explanation of what you will and will not learn by
reading this book.
On second thought, perhaps the introduction really is relevant, so you might as
well stick with it We’ll make it brief.
Even if you’re not yet familiar with SQL, suffice it to say that it is a complex language with many components and features In this book, we’re going to focus
on one main topic:
■ How to use SQL to retrieve data from a database
To a lesser extent, we will also cover:
■ How to update data in a database
■ How to build and maintain databases
■ How to design relational databases
■ Strategies for displaying data after it has been retrieved
xii
Trang 4A number of features make this book unique among introductory SQL books:
■ You will not be required to download software or sit with a computer as
you read the text.
Our intent is to provide examples of SQL usage that can be understood
simply by reading the book The text includes small data samples that will
allow you to see clearly how SQL statements work.
■ A language-based approach is employed to enable you to learn SQL as
you would learn English.
Topics are organized in an intuitive and logical sequence SQL keywords are
introduced one at a time, allowing you to build on your prior
under-standing as you encounter new words and concepts.
■ This book covers the syntax of three widely used databases: Microsoft
SQL Server, MySQL, and Oracle.
If there are any differences between the three databases, the Microsoft SQL
Server syntax is shown in the main text Special ‘‘Database Differences’’
boxes show and explain any variations in the syntax for MySQL or Oracle.
■ An emphasis is given to relevant aspects of SQL for retrieving data.
This approach is useful for those who only need to use SQL in conjunction
with a reporting tool.
Additionally, a final chapter is provided that covers strategies for displaying
data after it has been retrieved, including ideas on how to use crosstab
reports and pivot tables.
Finally, one additional question that we’ll address in the introduction: How is
SQL pronounced?
There are actually two choices One option is to simply say it as individual letters,
like ‘‘S-Q-L.’’ Another possibility is to pronounce it as ‘‘sequel.’’ There are
peo-ple who claim that only one of the two pronunciations is correct, but there is no
real agreement on the question It’s basically a matter of personal preference.
As for what the letters S-Q-L mean, most agree that they stand for ‘‘structured
query language.’’ However, there are a few people who will argue that SQL stands
Trang 5for nothing at all since the language is derived from an old language from IBM
called sequel, which did not stand for structured query language.
At any rate, the introduction is done And now on to some real information.
Companion Web Site Downloads
Please see Appendix D, for a description of the files available on the companion Web site These files list all SQL statements and provide all data shown in the book.
You may download the companion Web site files from www.courseptr.com/ downloads.