Introduction | p. xvii |
Introducing Relational Databases | p. 1 |
What Exactly Is a Database? | p. 1 |
Tables | p. 1 |
Rows/Records | p. 2 |
Columns/Fields | p. 2 |
How Is a Database Different from a Spreadsheet? | p. 3 |
Many Rows | p. 3 |
Many Users Simultaneously | p. 4 |
Security | p. 4 |
Relational Abilities | p. 5 |
Constraints to Ensure Data Quality | p. 6 |
Case Study--Clapham Specialty Store | p. 6 |
Designing Your First Database | p. 7 |
How Will Knowing This Help You? | p. 8 |
When Developing Software | p. 8 |
When Doing Database Administration | p. 8 |
When Doing Business Analysis | p. 8 |
If You Just Want to Know How to Use Databases Better | p. 9 |
History of SQL | p. 9 |
Chapter 1 Review | p. 11 |
Storing and Retrieving Data: The Basics | p. 16 |
Prepare to Work with a Database | p. 17 |
Creating a Table | p. 17 |
Inserting Records | p. 18 |
Selecting Records | p. 18 |
Dropping a Table | p. 18 |
Creating Tables | p. 20 |
Guidelines for Naming Tables and Columns | p. 21 |
Creating a More Involved Table | p. 24 |
Determining a Table's Structure | p. 30 |
NULL and NOT NULL Columns | p. 31 |
Inserting Data--Additional Techniques | p. 32 |
How to Insert Records Containing NULL Values | p. 32 |
Creating and Populating a Table | p. 35 |
How to Insert Data That Contains Apostrophes | p. 37 |
Viewing Data from a Table--Additional Techniques | p. 37 |
Selecting Specific Columns | p. 38 |
Changing Column Order | p. 38 |
Performing Math Using Data in a Table | p. 39 |
Connecting Two or More Pieces of Text Together | p. 41 |
Assigning Aliases to Columns | p. 42 |
Changing the Data Values You View | p. 43 |
Chapter 2 Review | p. 45 |
Performing Advanced Data Manipulation | p. 52 |
SQL Command Categories | p. 53 |
Data Definition | p. 53 |
Data Manipulation | p. 53 |
Data Control | p. 53 |
Data Retrieval | p. 54 |
Transaction Control | p. 54 |
Limiting Which Records You Select | p. 54 |
Filtering Records Based on Numbers | p. 55 |
Filtering Records Based on Text | p. 59 |
Filtering Records Based on Dates | p. 60 |
Viewing Records in a Different Order | p. 62 |
Sorting on Individual Columns | p. 63 |
Sorting on Multiple Columns | p. 63 |
Showing Only Unique Values | p. 64 |
Selecting from the DUAL Table | p. 66 |
Modifying Data in a Table | p. 67 |
Removing Records from a Table | p. 68 |
Deleting Rows Matching Specific Criteria | p. 68 |
Deleting All Rows | p. 68 |
Transaction Control | p. 69 |
Undoing DML Transactions | p. 69 |
Making Data Available to Others | p. 72 |
Implicit and Explicit COMMITs | p. 73 |
Performing Advanced Data Manipulation | p. 74 |
Chapter 3 Review | p. 75 |
Controlling SQL*Plus | p. 80 |
Editing Prior Commands | p. 81 |
Using a Text Editor | p. 81 |
Using the EDIT Command | p. 82 |
Line-Level Editing | p. 83 |
Copying and Pasting | p. 85 |
Using Your Mouse to Edit Text | p. 86 |
Clearing the SQL*Plus Screen | p. 87 |
Customizing the SQL*Plus Environment | p. 87 |
Customizing Using the SQL*Plus Menu | p. 87 |
Customizing Using Commands | p. 89 |
Saving Environment Customizations | p. 89 |
Producing More Readable Output | p. 90 |
Formatting Numbers in SQL*Plus | p. 90 |
Formatting Text in SQL*Plus | p. 91 |
Formatting Column Headings in SQL*Plus | p. 92 |
Spooling Output to Disk | p. 94 |
SQL Script Files | p. 95 |
Creating a Script File | p. 95 |
Running a Script File | p. 96 |
Using Variables in Script Files | p. 96 |
Chapter 4 Review | p. 99 |
Oracle SQL Built-in Functions | p. 104 |
Implementing Commonly Used Single-Row Functions | p. 105 |
System Variables | p. 106 |
Number Functions | p. 108 |
Text Functions | p. 110 |
Using Single-Row Functions | p. 120 |
Date | p. 121 |
Data Conversion | p. 126 |
Other Functions | p. 132 |
Implementing Commonly Used Group Functions | p. 139 |
Grouping Data via the GROUP BY Clause | p. 142 |
Including and Excluding Grouped Rows via the HAVING Clause | p. 143 |
Using Group Functions | p. 145 |
Chapter 5 Review | p. 147 |
Indexes, Joins, and Subqueries | p. 152 |
Creating the Test Tables | p. 153 |
Indexes | p. 155 |
Indexes in Databases | p. 155 |
How to Create Indexes | p. 156 |
Types of Indexes | p. 157 |
B-Tree Indexes | p. 157 |
Bitmap Indexes | p. 159 |
Bitmap Versus B-Tree Indexes | p. 160 |
Function-Based Indexes | p. 160 |
When to Use Indexes | p. 161 |
Relationships Between Tables | p. 162 |
Creating an Index | p. 163 |
Writing SELECT Statements to Display Data from More Than One Table | p. 164 |
Types of Joins | p. 167 |
Set Operators | p. 173 |
Writing Subqueries | p. 177 |
What Is a Subquery? | p. 177 |
Types of Problems Subqueries Can Solve | p. 177 |
Single-Row Subqueries | p. 177 |
Multirow Subqueries | p. 179 |
Multicolumn Subqueries | p. 180 |
Correlated Subqueries | p. 181 |
Chapter 6 Review | p. 183 |
Creating a Program with PL/SQL | p. 188 |
What Is PL/SQL? | p. 189 |
Describing PL/SQL | p. 192 |
Who's Who in SQL, PL/SQL, and SQL*Plus | p. 193 |
Stored Procedures, Functions, and Triggers | p. 194 |
Stored Procedures and SQL Scripts | p. 196 |
Structure of a PL/SQL Block | p. 196 |
Header Section | p. 197 |
Declaration Section | p. 197 |
Execution Section | p. 198 |
Exception Section | p. 198 |
Creating a Simple PL/SQL Procedure | p. 199 |
Calling Procedures and Functions | p. 200 |
PL/SQL Variables and Constants | p. 201 |
Declaring PL/SQL Variables | p. 202 |
Declaring PL/SQL Constants | p. 202 |
Assigning Values to Variables | p. 203 |
Using Variables | p. 204 |
Control Structures in PL/SQL | p. 205 |
IF Statement | p. 206 |
Loops | p. 208 |
Cursors | p. 210 |
Nested Loops and Cursor Example | p. 215 |
Error Handling | p. 217 |
Exceptions | p. 217 |
System-Defined Exceptions | p. 218 |
Programmer-Defined Exceptions | p. 220 |
Creating a Programmer-Defined Exception | p. 221 |
Chapter 7 Review | p. 223 |
Reading a Data Model | p. 230 |
Overview of Data Model Design | p. 231 |
Purpose and Benefits of Models | p. 231 |
Relational Integrity: Quality Data | p. 232 |
Types of Data Models | p. 233 |
Conceptual Model | p. 233 |
Logical Data Model | p. 234 |
Physical Data Model | p. 234 |
Reading an Entity Relationship Diagram | p. 236 |
Entities | p. 236 |
Attributes | p. 237 |
Relationships | p. 238 |
Cardinality and Optionality Notations | p. 240 |
Reading an Entity Relationship Diagram | p. 241 |
Chapter 8 Review | p. 242 |
Basics of Designing a Database's Structure | p. 246 |
The Business Specification: Let the Data Tell You Where It Goes | p. 247 |
Selecting the Database's Grain | p. 247 |
Entities and Attributes | p. 248 |
Identifying Records Reliably: Primary Keys | p. 251 |
Why Do You Need a Primary Key? | p. 251 |
Composite Primary Keys | p. 251 |
Natural Primary Keys vs. Surrogate Primary Keys | p. 252 |
Relationships: Referring to Data in Other Tables | p. 254 |
Common Data Model Standards | p. 255 |
Crow's Foot (IE) | p. 256 |
IDEF1X | p. 256 |
Relationships: Cardinality and Optionality | p. 258 |
One-to-Many | p. 258 |
Many-to-Many | p. 259 |
One-to-One | p. 260 |
Optionality | p. 261 |
Dependency: Identifying Relationships | p. 263 |
Recursive vs. Binary | p. 264 |
Modeling Multiple Categories: Supertype and Subtypes | p. 264 |
Creating Basic Data Models | p. 265 |
Categories, Supertypes, and Subtypes | p. 265 |
Implementing Super/Subtypes in a Physical Model | p. 267 |
Chapter 9 Review | p. 268 |
Normalization | p. 272 |
The Process of Normalization | p. 273 |
Dependency | p. 273 |
Dependents and Determinants | p. 273 |
The First Three Normal Forms | p. 275 |
First Normal Form: Eliminate Repeating Groups | p. 275 |
Second Normal Form: Eliminate Redundant Data | p. 277 |
Third Normal Form: Eliminate Attributes Not Dependent on the Primary Key | p. 278 |
Apply the Normal Forms to a Database Model | p. 279 |
The Fourth and Fifth Normal Forms | p. 279 |
Fourth Normal Form: Isolate Independent Multiple Relationships | p. 280 |
Fifth Normal Form: Isolate Semantically Related Multiple Relationships | p. 282 |
The Rules You Really Need | p. 283 |
Anomalies in the Data | p. 283 |
Normalizing the Data | p. 284 |
Insert | p. 285 |
Delete | p. 285 |
Update | p. 285 |
A Tax on Being Law-Abiding | p. 286 |
Moving from Logical to Physical Models | p. 286 |
Choosing Your Engine | p. 286 |
Changing Terminology | p. 287 |
Translating Super- and Subtypes | p. 287 |
Chapter 10 Review | p. 289 |
Analyzing Data Quality Issues | p. 294 |
Datatypes and Missing Data: Quality Basics | p. 295 |
Handling Missing Values | p. 295 |
Apples and Oranges: Defining Datatypes | p. 296 |
Choosing a Datatype | p. 298 |
Creating a Table and Inserting Data | p. 299 |
Converting Datatypes: Weak and Strong Typing | p. 301 |
Data Domains: Sanity Checks | p. 301 |
Domains as Sets of Values | p. 301 |
Column and Table Constraints | p. 302 |
Column Constraints | p. 303 |
Table Constraints | p. 305 |
Primary Key Constraints and Indexes | p. 307 |
Uniqueness and How to Enforce It | p. 307 |
Alternate Keys | p. 310 |
Other Indexes | p. 311 |
Foreign Key Constraints: Values from Other Tables | p. 312 |
Adding the Constraint | p. 313 |
Implementing Cardinality and Optionality | p. 314 |
Cascading Effects | p. 316 |
Cascade Delete on a Recursive Relationship | p. 319 |
The Cascades That Don't | p. 321 |
Creating the Movie Database | p. 322 |
Declarative Relational Integrity: Pros and Cons | p. 326 |
Declaring Foreign Key Constraints | p. 327 |
Triggers and Procedural Code | p. 327 |
Naming Constraints: Make It Easy for the Programmers | p. 329 |
Naming Tables and Columns | p. 330 |
Naming Check Constraints | p. 330 |
Naming Foreign Key Constraints | p. 330 |
Naming Indexes | p. 331 |
Chapter 11 Review | p. 332 |
Other Useful Oracle Techniques | p. 338 |
Transferring Data Between Tables | p. 339 |
Transferring Data Using INSERT | p. 342 |
Creating a New Table Based on an Existing One | p. 343 |
Renaming Tables | p. 344 |
Altering a Table's Structure | p. 345 |
Adding Columns | p. 345 |
Changing Column Datatypes | p. 345 |
Changing NULL Options | p. 346 |
Views | p. 348 |
Creating a View | p. 349 |
Updateable Views | p. 350 |
Dropping Views | p. 351 |
Top N Analysis | p. 352 |
Creating a View on a Table | p. 353 |
Other Database Objects | p. 358 |
Sequences | p. 358 |
Synonyms | p. 362 |
Chapter 12 Review | p. 365 |
On the CD-ROMs | p. 370 |
About Oracle 9i Standard Edition for Windows | p. 370 |
System Requirements | p. 370 |
Registering with the Oracle Technology Network | p. 371 |
Installing Oracle 9i Standard Edition | p. 372 |
Glossary | p. 373 |
Index | p. 385 |
Table of Contents provided by Ingram. All Rights Reserved. |