Copyrighted Material
Total Page:16
File Type:pdf, Size:1020Kb
Acknowledgements...........................xxiii Introduction...............................xxv Part I SQL Basic Concepts and Principles Chapter 1: SQL and Relational Database Management Systems . .....3 Desirable Database Characteristics ...................................................................................3 Sufficient capacity ..........................................................................................................4 Adequate security and auditing ....................................................................................4 Multiuser environment ..................................................................................................4 Effectiveness and searchability ......................................................................................4 Scalability .......................................................................................................................5 User friendliness ............................................................................................................5 Selecting Your Database Software .....................................................................................6 Market share ..................................................................................................................6 Total cost of ownership .................................................................................................6 Support and persistence ................................................................................................7 Major DBMS Implementations ...........................................................................................7 Real-Life Database Examples .............................................................................................9 Order management system database ............................................................................9 Health care provider database .....................................................................................10 Video sharing and editing database ............................................................................10 Scientific database .......................................................................................................11 Nonprofit organization database .................................................................................11 Database Legacy .................................................................................................................11 Flat file databases ........................................................................................................11 Hierarchical databases .................................................................................................12 NetworkCOPYRIGHTED databases ......................................................................................................14 MATERIAL Relational Databases .........................................................................................................15 Tables ...........................................................................................................................16 Relationships ................................................................................................................17 Primary key .................................................................................................................17 Foreign key ..................................................................................................................18 Invasion of RDBMS .....................................................................................................18 Other DBMS Models ..........................................................................................................19 xiii Contents Brief History of SQL and SQL Standards ......................................................................20 Humble beginnings: RDBMS and SQL evolution .......................................................20 A brief history of SQL standards ................................................................................23 Summary ..............................................................................................................................26 Chapter2:FundamentalSQLConceptsandPrinciples...........27 Promises and Deliverables ................................................................................................27 SQL: The First Look .........................................................................................................32 Database example ........................................................................................................32 Getting the data in and out ........................................................................................33 Slice and dice: Same data, different angle .................................................................35 Aggregation ..................................................................................................................37 Data security ................................................................................................................38 Accessing data from a client application ....................................................................39 New developments ......................................................................................................40 Any Platform, Any Time ....................................................................................................40 Summary ..............................................................................................................................43 Chapter3:SQLDataTypes........................45 No Strings Attached ...........................................................................................................46 Character strings ..........................................................................................................46 Binary strings ...............................................................................................................54 In Numbers Strength .........................................................................................................56 Exact numbers .............................................................................................................56 Approximate numbers .................................................................................................60 Once Upon a Time: Date and Time Data Types ...........................................................61 Introduction to complex data types ...........................................................................62 Date and time implementations ..................................................................................63 XML Data Type ...................................................................................................................69 XML data type implementations .................................................................................69 Constructed and User-Defined Data Types ...................................................................70 SQL:2003 .....................................................................................................................71 Oracle 11g ...................................................................................................................73 DB2 9.5 ........................................................................................................................75 Microsoft SQL Server 2008 .........................................................................................76 Other Data Types ...............................................................................................................77 BOOLEAN ...................................................................................................................77 ROWID ........................................................................................................................77 UROWID .....................................................................................................................78 BFILE ...........................................................................................................................78 DATALINK ..................................................................................................................78 BIT ...............................................................................................................................78 TIMESTAMP ................................................................................................................78 SQL VARIANT .............................................................................................................78 xiv Contents NULL ....................................................................................................................................79 Summary ..............................................................................................................................79 Part II Creating and Modifying Database Objects Chapter4:CreatingRDBMSObjects....................83 Tables ...................................................................................................................................83 CREATE TABLE Statement .........................................................................................84 Indexes ...............................................................................................................................113