內容簡介
本書是江蘇省精品教材立項建設項目、“十二盼腳夜五”江蘇省高等學校重點教材建設項目成果,以基於資料庫的套用能力培養為腿槳肯主要目標,面向套用型教學需求,重點突出基礎性和套用艱埋應性。按照“理論、實踐、再理論、再實付嚷戒臘踐”的思想關聯知識,以一個貫穿全書的商品訂購管理資料庫示例為主線,將資料庫基本原理、技術和套用三茅船婆者有精酷機結合。全書共9章,內容包括資料庫概覽、關係數據模型、關係資料庫語言SQL、資料庫設計、關係規範化理論、套用系統中的SQL 及相關技術、資料庫套用開發察道霸定、資料庫保護和資料庫新進展。附錄A 和B分別是實驗指導和課程設計指導。附錄C是T-SQL 常用語句。本書免費提供配套電子課件、習題參考解答、示例源程式和視頻資源。
圖書目錄
目 錄
第1 章 資料庫概覽—實例、概念與認識............................................................................................ 1
1.1 數據管理技術的進展.................................................................................................................... 1
1.1.1 人工管理階段.................................................................................................................... 1
1.1.2 檔案系統階段.................................................................................................................... 1
1.1.3 資料庫系統階段................................................................................................................ 2
1.2 理解資料庫系統............................................................................................................................ 3
1.2.1 實例——商品訂購管理系統........................................................................................... 4
1.2.2 什麼是資料庫系統............................................................................................................ 5
1.3 資料庫系統結構............................................................................................................................ 6
1.3.1 資料庫系統的三級模式結構........................................................................................... 6
1.3.2 資料庫系統的二級映像.................................................................................................... 7
1.3.3 資料庫管理系統................................................................................................................ 7
1.3.4 資料庫系統所需人員........................................................................................................ 8
1.4 數據模型......................................................................................................................................... 9
1.4.1 數據模型的概念................................................................................................................ 9
1.4.2 概念數據模型..................................................................................................................10
1.4.3 邏輯數據模型..................................................................................................................12
1.5 資料庫系統的發展......................................................................................................................13
1.5.1 資料庫系統發展的階段..................................................................................................13
1.5.2 資料庫系統主要研究領域..............................................................................................14
本章小結................................................................................................................................................15
習題1 .....................................................................................................................................................15
第2 章 關係數據模型—關係資料庫基礎..........................................................................................16
2.1 關係數據結構..............................................................................................................................16
2.1.1 二維表與關係數據結構..................................................................................................16
2.1.2 關係數據結構的形式化定義.........................................................................................18
2.1.3 關係的性質.......................................................................................................................19
2.1.4 關係模式...........................................................................................................................20
2.1.5 關係資料庫.......................................................................................................................20
2.1.6 碼.......................................................................................................................................21
2.2 關係操作.......................................................................................................................................22
2.2.1 基本關係操作..................................................................................................................23
2.2.2 關係數據語言分類..........................................................................................................23
2.2.3 關係代數...........................................................................................................................23
2.3 關係完整性..................................................................................................................................28
·VI·
2.3.1 實體完整性.......................................................................................................................29
2.3.2 參照完整性.......................................................................................................................29
2.3.3 用戶定義完整性..............................................................................................................29
本章小結................................................................................................................................................30
習題2.............................................................................................................................................30
第3 章 關係資料庫語言SQL—資料庫套用基礎............................................................................31
3.1 SQL 概述......................................................................................................................................31
3.1.1 SQL 的特點......................................................................................................................32
3.1.2 SQL 基本概念..................................................................................................................32
3.1.3 SQL 語言的組成..............................................................................................................33
3.1.4 SQL 語句分類..................................................................................................................34
3.2 SQL 語言的數據類型.................................................................................................................34
3.3 數據定義.......................................................................................................................................36
3.3.1 模式定義...........................................................................................................................36
3.3.2 基本表定義.......................................................................................................................37
3.3.3 索引定義...........................................................................................................................40
3.3.4 視圖定義...........................................................................................................................42
3.4 數據查詢.......................................................................................................................................43
3.4.1 SELECT 語句結構..........................................................................................................43
3.4.2 單表查詢...........................................................................................................................44
3.4.3 連線查詢...........................................................................................................................52
3.4.4 嵌套查詢...........................................................................................................................56
3.4.5 集合查詢...........................................................................................................................61
3.4.6 視圖查詢...........................................................................................................................62
3.5 數據更新.......................................................................................................................................64
3.5.1 數據插入...........................................................................................................................64
3.5.2 數據修改...........................................................................................................................65
3.5.3 數據刪除...........................................................................................................................65
3.5.4 視圖更新...........................................................................................................................66
3.5.5 更新操作與數據完整性..................................................................................................67
本章小結................................................................................................................................................67
習題3......................................................................................................................................................68
第4 章 資料庫設計—資料庫套用系統開發總論············································································69
4.1 資料庫設計概述..........................................................................................................................69
4.1.1 資料庫設計的含義..........................................................................................................69
4.1.2 資料庫設計的特點..........................................................................................................70
4.1.3 資料庫設計的六階段......................................................................................................71
4.2 需求分析.......................................................................................................................................72
4.2.1 需求分析的步驟..............................................................................................................72
·VII·
4.2.2 需求分析常用的調查方法................................................................................................73
4.2.3 需求分析的描述................................................................................................................73
4.3 概念設計.......................................................................................................................................78
4.3.1 概念設計的方法..............................................................................................................78
4.3.2 ER 方法.............................................................................................................................79
4.3.3 基本E-R 模型的擴充.....................................................................................................82
4.3.4 擴展E-R 模型..................................................................................................................85
4.4 邏輯設計.......................................................................................................................................87
4.4.1 E-R 模型轉換為關係模型.................................................................................................87
4.4.2 數據模式的最佳化..............................................................................................................90
4.4.3 設計用戶外模式..............................................................................................................90
4.5 物理設計.......................................................................................................................................91
4.5.1 確定資料庫的物理結構..................................................................................................91
4.5.2 性能評價...........................................................................................................................92
4.6 資料庫實施..................................................................................................................................92
4.6.1 資料庫結構定義及數據載入.........................................................................................93
4.6.2 應用程式編寫與調試......................................................................................................93
4.6.3 資料庫試運行..................................................................................................................94
4.7 資料庫運行與維護......................................................................................................................94
4.7.1 資料庫的轉儲和恢復......................................................................................................94
4.7.2 資料庫安全性、完整性控制.........................................................................................94
4.7.3 資料庫性能監督、分析和改進.....................................................................................95
4.7.4 資料庫的重定義、重構和重組織.................................................................................95
本章小結................................................................................................................................................95
習題4.....................................................................................................................................................95
第5 章 關係規範化理論——關係資料庫設計理論基礎····································································97
5.1 數據冗餘與操作異常問題.........................................................................................................97
5.1.1 數據冗餘與操作異常......................................................................................................97
5.1.2 問題原因分析..................................................................................................................98
5.2 函式依賴.......................................................................................................................................98
5.2.1 函式依賴的基本概念......................................................................................................99
5.2.2 函式依賴的分類..............................................................................................................99
5.2.3 函式依賴與數據冗餘....................................................................................................100
5.3 範式.............................................................................................................................................100
5.3.1 關係模式和碼................................................................................................................100
5.3.2 基於函式依賴的範式....................................................................................................101
5.3.3 多值依賴與4NF............................................................................................................104
5.4 數據依賴公理系統....................................................................................................................106
5.4.1 邏輯蘊含.........................................................................................................................106
·VIII·
5.4.2 Armstrong 公理系統......................................................................................................106
5.4.3 函式依賴集的閉包........................................................................................................107
5.4.4 最小依賴集.....................................................................................................................108
5.5 模式分解.....................................................................................................................................109
5.5.1 無損分解.........................................................................................................................110
5.5.2 函式依賴保持................................................................................................................112
本章小結..............................................................................................................................................114
習題5...................................................................................................................................................114
第6 章 套用系統中的SQL 及相關技術——套用開發關鍵技術····················································116
6.1 在套用中使用SQL ...................................................................................................................116
6.2 T-SQL 程式設計........................................................................................................................117
6.2.1 T-SQL 程式設計基礎....................................................................................................117
6.2.2 流程控制語句................................................................................................................120
6.2.3 批處理和腳本................................................................................................................125
6.2.4 函式.................................................................................................................................126
6.2.5 游標.................................................................................................................................133
6.3 存儲過程和觸發器....................................................................................................................139
6.3.1 存儲過程.........................................................................................................................139
6.3.2 觸發器.............................................................................................................................145
6.4 資料庫訪問接口........................................................................................................................148
6.4.1 開放資料庫互連ODBC ...............................................................................................149
6.4.2 OLE DB 和ADO...........................................................................................................154
6.4.3 ADO.NET.......................................................................................................................158
6.4.4 JDBC...............................................................................................................................160
本章小結..............................................................................................................................................164
習題6.............................................................................................................................................165
第7 章 資料庫套用開發—過程、平台與實例··············································································166
7.1 資料庫套用系統的開發過程...................................................................................................166
7.2 資料庫套用系統的體系結構...................................................................................................168
7.2.1 單用戶模式.....................................................................................................................168
7.2.2 主從式多用戶模式........................................................................................................168
7.2.3 C/S 模式..........................................................................................................................168
7.2.4 B/S 模式..........................................................................................................................169
7.3 常用的資料庫系統....................................................................................................................170
7.3.1 SQL Server......................................................................................................................170
7.3.2 Oracle ..............................................................................................................................172
7.3.3 Sybase..............................................................................................................................173
7.3.4 DB2 .................................................................................................................................173
7.3.5 MySQL............................................................................................................................174
·IX·
7.3.6 VFP..................................................................................................................................174
7.3.7 Access..............................................................................................................................174
7.3.8 SQLite .............................................................................................................................175
7.3.9 資料庫系統的選擇........................................................................................................175
7.4 常用資料庫套用開發工具簡介...............................................................................................175
7.4.1 Visual Studio ...................................................................................................................176
7.4.2 Eclipse .............................................................................................................................176
7.5 C#資料庫套用開發...................................................................................................................177
7.5.1 C#程式設計概述...........................................................................................................177
7.5.2 ADO.NET 資料庫套用技術.........................................................................................183
7.5.3 C#資料庫套用系統開發案例—商品訂購管理系統.............................................191
7.6 Java 資料庫套用開發................................................................................................................203
7.6.1 JDBC 資料庫訪問流程.................................................................................................203
7.6.2 結果集(ResultSet).....................................................................................................208
7.6.3 JDBC 資料庫編程.........................................................................................................210
7.6.4 Java 資料庫套用系統開發案例—商品訂購管理系統.........................................223
本章小結..............................................................................................................................................232
習題7...................................................................................................................................................232
第8 章 資料庫保護—資料庫管理基礎·····································234
8.1 資料庫保護概述........................................................................................................................234
8.2 資料庫安全................................................................................................................................235
8.2.1 資料庫安全保護範圍....................................................................................................235
8.2.2 資料庫安全性目標........................................................................................................235
8.2.3 資料庫安全控制............................................................................................................236
8.2.4 SQL Server 的安全機制................................................................................................238
8.3 資料庫完整性............................................................................................................................243
8.3.1 完整性概念.....................................................................................................................243
8.3.2 DBMS 的完整性控制...................................................................................................245
8.3.3 SQL Server 的完整性機制............................................................................................246
8.4 並發控制.....................................................................................................................................250
8.4.1 事務.................................................................................................................................250
8.4.2 事務的並發執行............................................................................................................252
8.4.3 並發調度的可串列化....................................................................................................253
8.4.4 封鎖.................................................................................................................................253
8.4.5 活鎖與死鎖.....................................................................................................................255
8.4.6 SQL Server 的事務處理和鎖機制...............................................................................256
8.5 資料庫恢復................................................................................................................................260
8.5.1 故障種類.........................................................................................................................260
8.5.2 資料庫恢復技術............................................................................................................260
·X·
8.5.3 SQL Server 的恢復技術................................................................................................263
本章小結..............................................................................................................................................265
習題8...................................................................................................................................................265
第9 章 資料庫新進展—領域知識拓展··············································································266
9.1 資料庫技術的研究與發展.......................................................................................................266
9.1.1 資料庫技術的發展........................................................................................................266
9.1.2 資料庫發展的特點........................................................................................................267
9.1.3 資料庫技術的研究方向................................................................................................268
9.2 數據倉庫與數據挖掘................................................................................................................271
9.2.1 數據倉庫.........................................................................................................................271
9.2.2 數據挖掘.........................................................................................................................272
9.2.3 數據倉庫與數據挖掘....................................................................................................274
9.3 XML 數據管理..........................................................................................................................275
9.3.1 XML 概述.......................................................................................................................275
9.3.2 XML 數據模型..............................................................................................................275
9.3.3 XML 數據查詢..............................................................................................................278
9.3.4 SQL Server 中XML 數據處理....................................................................................278
9.4 非關係型資料庫(NoSQL)...................................................................................................280
9.4.1 NoSQL 概念...................................................................................................................280
9.4.2 NoSQL 架構...................................................................................................................281
9.4.3 CAP 理論........................................................................................................................281
本章小結..............................................................................................................................................282
習題9...................................................................................................................................................282
附錄A 實驗指導·····································································································283
附錄B 課程設計指導································································································310
附錄C T-SQL 常用語句·································································································314
參考文獻·····························································································································316