Ch1 introduction to database systems(筆記+習題)

筆記

scheme:根據數據模型和描述的數據結構
transaction:DBMS的訪問邏輯單元
Checkpointing:週期性操作,減少從系統崩潰恢復的時間
DBMS組成:硬盤管理模塊、緩衝區管理模塊、文件和索引結構體層、關係運算符實現器、查詢優化器等
shared locks:共享鎖
exclusive lock:互斥鎖
用戶查詢->查詢解析器(解析後發送)->查詢優化器(產生高效執行計劃,通常爲關係運算符樹)

Exercises

Exercise 1.1 Why would you choose a database system instead of simply storing data inoperating system files? When would it make sense not to use a database system?
用操作系統的文件存儲有如下缺點:

1.主存無法存下太大量的數據。

2.即使主存能存的下,32位系統也無法直接引用超過4GB的數據。

3.需要編寫一個能滿足各種複雜查詢的程序。

4.必須保護數據免受非一致性修改。

5.必須確保數據被存儲在同一區域。

6.操作系統只通過密碼來提供安全性,不能靈活地執行安全策略。

而用數據庫系統存儲能保證數據的獨立性、高效存取、完整性、安全性、簡便管理、並行訪問、快速恢復,以及明顯縮短應用開發的世界。
不使用數據庫系統的原因有:1.DBMS是一個極其複雜的軟件,可能不適合某些特殊應用,如實時應用。2.應用可能需要以查詢語言不支持的方式操作數據。

Exercise 1.2 What is logical data independence and why is it important?
數據獨立性是指應用程序不受數據的邏輯結構的變化或存儲關係變化的影響。這使得我們可以在不改變應用程序的情況下更改存儲細節。

Exercise 1.3 Explain the difference between logical and physical data independence.
邏輯數據獨立性強調應用程序與數據的邏輯結構相互獨立,應用程序不受數據邏輯結構變化的影響,而物理數據獨立性強調應用程序與數據庫中數據相互獨立,應用程序不需要了解DBMS如何存儲數據。邏輯數據獨立性比物理數據獨立性更難做到,因爲應用程序很依賴數據的存儲結構。

Exercise 1.4 Explain the difference between external, internal, and conceptual schemas.How are these different schema layers related to the concepts of logical and physical data independence?
外部模式描述特定用戶感興趣的數據庫部分,例如,來自銷售部門的用戶將僅看到與銷售相關的數據;內部模式定義數據庫的物理結構,是非常底層的表示;概念模式描述了整個數據庫結構,隱藏了具體實現細節,專注於描述數據類型,實體,關係等。模式之間存在映射關係,當概念模式改變時,只要改變外部模式-概念模式的映射關係,就可以使外模式保持不變,對應的應用程序也可保持不變,這就保證了邏輯數據獨立性;當數據的存儲結構發生變化時,只需改變概念模式一內部模式映射,就能保持概念模式不變,對應的應用程序也可保持不變,這就保證了物理數據獨立性。

Exercise 1.5 What are the responsibilities of a DBA? If we assume that the DBA is never interested in running his or her own queries, does the DBA still need to understand query optimization? Why?
DBA的職責:1.設計概念模式和物理模式。2.確保用戶認證和安全性。3.確保數據可訪問和系統崩潰後及時恢復數據。4.用戶需求變化時對數據庫進行相應修改。
DBA需要理解查詢優化,因爲DBA需要保證用戶的查詢經過優化後能訪問到數據。

Exercise 1.6 Scrooge McNugget wants to store information (names, addresses, descriptions of embarrassing moments, etc.) about the many ducks on his payroll. Not surprisingly, the volume of data compels him to buy a database system. To save money, he wants to buy one with the fewest possible features, and he plans to run it as a stand-alone application on his PC clone. Of course, Scrooge does not plan to share his list with anyone. Indicate which of the following DBMS features Scrooge should pay for; in each case also indicate why Scrooge should (or should not) pay for that feature in the system he buys.
1. A security facility.需要,出於隱私保護。
2. Concurrency control.不需要,因爲此數據庫只有單個用戶。
3. Crash recovery.需要,系統可能崩潰,需要此功能。
4. A view mechanism.需要,對訪問數據有幫助。
5. A query language.需要,需要訪問數據。

Exercise 1.7 Which of the following plays an important role in representing information about the real world in a database? Explain briefly.
1. The data definition language.定義表的結構
2. The data manipulation language.對錶裏的數據進行操作
3. The buffer manager.提高存取效率
4. The data model.描述數據與實體的關係

Exercise 1.8 Describe the structure of a DBMS. If your operating system is upgraded to support some new functions on OS files (e.g., the ability to force some sequence of bytes to disk), which layer(s) of the DBMS would you have to rewrite in order to take advantage of these new functions?
Disk Space Manager這一層。

Exercise 1.9 Answer the following questions:
1. What is a transaction?
用戶程序一次運行的所有數據庫操作。
2. Why does a DBMS interleave the actions of different transactions, instead of executing
transactions one after the other?
因爲不同事務之間可能相互影響。
3. What must a user guarantee with respect to a transaction and database consistency?
What should a DBMS guarantee with respect to concurrent execution of several transactions
and database consistency?
用戶不能進行一個數據庫不允許的事務。DBMS必須保證多個事務的順利進行,且不相互影響,數據庫的一致性不被併發執行所影響。
4. Explain the strict two-phase locking protocol.
鎖協議包括互斥鎖和共享鎖。一個事務在執行前必須啓動鎖,並且執行完成之前不釋放鎖。
5. What is the WAL property, and why is it important?
預寫日誌記錄了數據庫在改變映射關係前的每一次寫操作。當執行事務時數據庫崩潰,它能保護數據庫。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章