| About the Author |
|
xv | |
| About the Technical Reviewer |
|
xvii | |
| Acknowledgments |
|
xix | |
| Introduction |
|
xxi | |
| Chapter 1 The Fundamentals |
|
1 | (64) |
|
|
|
3 | (11) |
|
Codd's Rules for an RDBMS |
|
|
5 | (8) |
|
|
|
13 | (1) |
|
Recognizing Relational Data Structures |
|
|
14 | (26) |
|
Introducing Databases and Schemas |
|
|
15 | (1) |
|
Understanding Tables, Rows, and Columns |
|
|
16 | (8) |
|
Working with Missing Values (NULL) |
|
|
24 | (2) |
|
|
|
26 | (3) |
|
|
|
29 | (1) |
|
Uniqueness Constraints (Keys) |
|
|
30 | (10) |
|
Understanding Relationships |
|
|
40 | (10) |
|
|
|
43 | (6) |
|
|
|
49 | (1) |
|
Understanding Data Dependencies |
|
|
50 | (3) |
|
|
|
51 | (1) |
|
|
|
52 | (1) |
|
|
|
53 | (3) |
|
Outlining the Database-Specific Project Phases |
|
|
56 | (5) |
|
|
|
57 | (1) |
|
|
|
58 | (1) |
|
|
|
59 | (1) |
|
|
|
60 | (1) |
|
|
|
61 | (4) |
| Chapter 2 Introduction to Requirements |
|
65 | (26) |
|
|
|
70 | (2) |
|
|
|
72 | (17) |
|
|
|
74 | (2) |
|
Getting the Answers to the Right Questions |
|
|
76 | (10) |
|
Finding Obscure Requirements |
|
|
86 | (3) |
|
|
|
89 | (1) |
|
|
|
90 | (1) |
| Chapter 3 The Language of Data Modeling |
|
91 | (58) |
|
Introducing Data Modeling |
|
|
92 | (2) |
|
|
|
94 | (5) |
|
|
|
99 | (14) |
|
|
|
102 | (3) |
|
|
|
105 | (2) |
|
|
|
107 | (1) |
|
|
|
108 | (5) |
|
|
|
113 | (23) |
|
Identifying Relationships |
|
|
115 | (2) |
|
Nonidentifying Relationships |
|
|
117 | (4) |
|
|
|
121 | (1) |
|
|
|
122 | (11) |
|
Verb Phrases (Relationship Names) |
|
|
133 | (3) |
|
|
|
136 | (3) |
|
Alternative Modeling Methodologies |
|
|
139 | (5) |
|
|
|
140 | (3) |
|
|
|
143 | (1) |
|
|
|
144 | (2) |
|
|
|
146 | (3) |
| Chapter 4 Conceptual and Logical Data Model Production |
|
149 | (66) |
|
|
|
151 | (1) |
|
Building the Conceptual Model |
|
|
152 | (31) |
|
|
|
153 | (13) |
|
Identifying Relationships Between Entities |
|
|
166 | (16) |
|
Testing the Conceptual Model |
|
|
182 | (1) |
|
Building the Logical Model |
|
|
183 | (29) |
|
Identifying Attributes and Domains |
|
|
183 | (19) |
|
Identifying Business Rules |
|
|
202 | (3) |
|
Identifying Fundamental Processes |
|
|
205 | (3) |
|
Finalizing the Logical Model |
|
|
208 | (4) |
|
|
|
212 | (1) |
|
|
|
213 | (2) |
| Chapter 5 Normalization |
|
215 | (70) |
|
The Process of Normalization |
|
|
217 | (1) |
|
|
|
218 | (26) |
|
All Columns Must Be Atomic |
|
|
220 | (14) |
|
All Rows Must Contain the Same Number of Values |
|
|
234 | (5) |
|
All Rows Must Be Different |
|
|
239 | (4) |
|
Clues That an Existing Design Is Not in First Normal Form |
|
|
243 | (1) |
|
Non-Key Column Relationships |
|
|
244 | (20) |
|
|
|
245 | (3) |
|
|
|
248 | (2) |
|
|
|
250 | (2) |
|
Surrogate Keys' Effect on Dependency |
|
|
252 | (5) |
|
|
|
257 | (1) |
|
Clues That Your Database Is Not in BCNF |
|
|
258 | (4) |
|
|
|
262 | (2) |
|
|
|
264 | (11) |
|
Fourth Normal Form: Independent Multivalued Dependencies |
|
|
265 | (5) |
|
|
|
270 | (5) |
|
|
|
275 | (4) |
|
|
|
279 | (1) |
|
|
|
280 | (5) |
| Chapter 6 Physical Model Case Study |
|
285 | (62) |
|
|
|
289 | (9) |
|
|
|
291 | (3) |
|
|
|
294 | (2) |
|
|
|
296 | (2) |
|
Choosing Key Implementation |
|
|
298 | (10) |
|
|
|
298 | (7) |
|
|
|
305 | (3) |
|
Determining Column Domain Implementation |
|
|
308 | (29) |
|
Enforce Domain in the Column or With a Table? |
|
|
312 | (3) |
|
|
|
315 | (16) |
|
|
|
331 | (2) |
|
Collation and Code Page of Character Data |
|
|
333 | (4) |
|
|
|
337 | (2) |
|
Adding Implementation Columns |
|
|
339 | (2) |
|
|
|
341 | (2) |
|
|
|
343 | (1) |
|
The Story of the Book So Far |
|
|
343 | (4) |
| Chapter 7 Physical Model Implementation |
|
347 | (80) |
|
Choosing the Engine for Your Tables |
|
|
349 | (3) |
|
Using DDL to Create the Database |
|
|
352 | (61) |
|
|
|
354 | (2) |
|
Creating the Basic Table Structures |
|
|
356 | (17) |
|
Adding Uniqueness Constraints |
|
|
373 | (6) |
|
Building DEFAULT Constraints |
|
|
379 | (3) |
|
Adding Relationships (Foreign Keys) |
|
|
382 | (11) |
|
Adding Basic CHECK Constraints |
|
|
393 | (4) |
|
Triggers to Maintain Automatic Values |
|
|
397 | (7) |
|
Documenting Your Database |
|
|
404 | (5) |
|
Viewing the Basic System Metadata |
|
|
409 | (4) |
|
Unit Testing Your Structures |
|
|
413 | (9) |
|
|
|
422 | (1) |
|
|
|
423 | (1) |
|
|
|
424 | (3) |
| Chapter 8 Data Protection Patterns with Check Constraints and Triggers |
|
427 | (80) |
|
|
|
430 | (25) |
|
CHECK Constraints Based on Simple Expressions |
|
|
434 | (8) |
|
CHECK Constraints Using Functions |
|
|
442 | (7) |
|
Enhancing Errors Caused by Constraints |
|
|
449 | (6) |
|
|
|
455 | (39) |
|
|
|
457 | (23) |
|
|
|
480 | (14) |
|
Dealing with TRIGGER and Constraint Errors |
|
|
494 | (8) |
|
|
|
502 | (2) |
|
|
|
504 | (3) |
| Chapter 9 Patterns and Anti-patterns |
|
507 | (140) |
|
|
|
508 | (121) |
|
|
|
509 | (25) |
|
|
|
534 | (2) |
|
|
|
536 | (23) |
|
Images, Documents, and Other Files |
|
|
559 | (11) |
|
|
|
570 | (8) |
|
Storing User-Specified Data |
|
|
578 | (19) |
|
Storing Graph Data in SQL Server |
|
|
597 | (32) |
|
|
|
629 | (14) |
|
|
|
631 | (2) |
|
One-Size-Fits-All Key Domain |
|
|
633 | (4) |
|
|
|
637 | (4) |
|
Overusing Unstructured Data |
|
|
641 | (2) |
|
|
|
643 | (4) |
| Chapter 10 Database Security and Security Patterns |
|
647 | (126) |
|
Database Security Prerequisites |
|
|
651 | (26) |
|
Guidelines for Host Server Security Configuration |
|
|
651 | (3) |
|
|
|
654 | (1) |
|
Granting and Denying Access to Securables |
|
|
655 | (3) |
|
Connecting to a SQL Server Database |
|
|
658 | (14) |
|
|
|
672 | (5) |
|
Database Object Securables |
|
|
677 | (24) |
|
|
|
678 | (7) |
|
|
|
685 | (13) |
|
|
|
698 | (3) |
|
Controlling Access to Data via T-SQL Coded Objects |
|
|
701 | (15) |
|
Stored Procedures and Scalar Functions |
|
|
702 | (12) |
|
Views and Table-Valued Functions |
|
|
714 | (2) |
|
|
|
716 | (18) |
|
Using Specific-Purpose Views to Provide Row-Level Security |
|
|
718 | (4) |
|
Using the Row-Level Security Feature |
|
|
722 | (8) |
|
Using Data-Driven Row-Level Security |
|
|
730 | (2) |
|
Row-Level Security and Impersonation |
|
|
732 | (2) |
|
|
|
734 | (17) |
|
Using Cross-Database Chaining |
|
|
736 | (8) |
|
Using Impersonation to Cross Database Lines |
|
|
744 | (2) |
|
Using a Certificate-Based Trust |
|
|
746 | (3) |
|
Accessing Data on a Different Server |
|
|
749 | (2) |
|
|
|
751 | (10) |
|
|
|
752 | (3) |
|
Using Dynamic Data Masking to Hide Data from Users |
|
|
755 | (6) |
|
|
|
761 | (7) |
|
Defining an Audit Specification |
|
|
763 | (4) |
|
Viewing the Audit Configuration |
|
|
767 | (1) |
|
|
|
768 | (2) |
|
|
|
770 | (3) |
| Chapter 11 Data Structures, Indexes, and Their Application |
|
773 | (104) |
|
|
|
776 | (1) |
|
|
|
777 | (4) |
|
|
|
781 | (48) |
|
|
|
789 | (10) |
|
|
|
799 | (29) |
|
|
|
828 | (1) |
|
Memory-Optimized Indexes and Data Structures |
|
|
829 | (14) |
|
|
|
830 | (11) |
|
|
|
841 | (2) |
|
Common OLTP Patterns of Index Usage |
|
|
843 | (20) |
|
|
|
844 | (7) |
|
|
|
851 | (6) |
|
|
|
857 | (2) |
|
|
|
859 | (4) |
|
Indexing Dynamic Management View Queries |
|
|
863 | (9) |
|
|
|
864 | (4) |
|
|
|
868 | (1) |
|
|
|
869 | (2) |
|
Memory-Optimizeti Table Index Stats |
|
|
871 | (1) |
|
|
|
872 | (3) |
|
|
|
875 | (2) |
| Chapter 12 Matters of Concurrency |
|
877 | (106) |
|
|
|
881 | (2) |
|
|
|
883 | (22) |
|
|
|
884 | (2) |
|
|
|
886 | (19) |
|
SQL Server Concurrency Methods |
|
|
905 | (62) |
|
|
|
906 | (5) |
|
Pessimistic Concurrency Enforcement |
|
|
911 | (27) |
|
Optimistic Concurrency Enforcement |
|
|
938 | (29) |
|
Coding for Asynchronous Contention |
|
|
967 | (12) |
|
Row-Based Change Detection |
|
|
969 | (7) |
|
Coding for Logical Unit of Work Change Detection |
|
|
976 | (3) |
|
|
|
979 | (2) |
|
|
|
981 | (2) |
| Chapter 13 Coding Architecture |
|
983 | (104) |
|
Building the Data Access Layer |
|
|
984 | (67) |
|
|
|
987 | (29) |
|
Using a T-SQL Coded Encapsulation Layer |
|
|
1016 | (33) |
|
Stored Procedure or Ad Hoc? |
|
|
1049 | (2) |
|
Building Reusable Components |
|
|
1051 | (30) |
|
|
|
1054 | (5) |
|
|
|
1059 | (3) |
|
|
|
1062 | (8) |
|
|
|
1070 | (7) |
|
|
|
1077 | (4) |
|
|
|
1081 | (1) |
|
|
|
1082 | (2) |
|
|
|
1084 | (3) |
| Appendix A: Scalar Datatype Reference |
|
1087 | (52) |
|
|
|
1090 | (12) |
|
|
|
1091 | (3) |
|
|
|
1094 | (6) |
|
|
|
1100 | (2) |
|
|
|
1102 | (9) |
|
|
|
1103 | (1) |
|
|
|
1103 | (1) |
|
|
|
1104 | (1) |
|
datetimeoffset [ (precision)] |
|
|
1104 | (1) |
|
|
|
1105 | (1) |
|
|
|
1106 | (1) |
|
Discussion on All Date Types |
|
|
1107 | (4) |
|
|
|
1111 | (10) |
|
|
|
1111 | (2) |
|
varchar[ (number of bytes)] |
|
|
1113 | (2) |
|
|
|
1115 | (1) |
|
|
|
1116 | (1) |
|
|
|
1117 | (1) |
|
binary[ (number ot bytes)] |
|
|
1118 | (1) |
|
|
|
1119 | (1) |
|
|
|
1119 | (1) |
|
|
|
1120 | (1) |
|
|
|
1121 | (15) |
|
|
|
1121 | (1) |
|
rowversion (aka timestamp) |
|
|
1122 | (2) |
|
|
|
1124 | (4) |
|
|
|
1128 | (1) |
|
|
|
1128 | (5) |
|
|
|
1133 | (3) |
|
Not Simply Scalar Datatypes |
|
|
1136 | (3) |
| Index |
|
1139 | |