baiyanchen8
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Overview of Database Systems {%hackmd theme-dark %} ## Database Systems 資料庫系統是一種組織化、存儲和管理資料的系統。它是許多應用程式的基石,包括企業應用、網站和軟體開發項目。在資料庫系統中,資料以表格的形式組織,每個表格包含一組相關的資料,並使用唯一的識別碼來標識每個資料項。 常見的資料庫系統包括MySQL、Microsoft SQL Server和Oracle Database。這些系統支援結構化查詢語言(SQL),用於執行對資料庫的查詢、插入、更新和刪除操作。 資料庫系統的主要功能包括資料的持久性儲存、資料的快速檢索、多用戶並發控制、數據完整性保護和安全性控制。這些功能確保資料庫中的資料可靠、一致,同時允許多個使用者同時訪問資料庫。 資料庫系統的設計和管理是一項複雜的任務,需要考慮資料模型、索引、正規化和性能優化等方面。開發人員和數據庫管理員(DBA)在建立和維護資料庫系統時需要深入了解這些概念。 總的來說,資料庫系統在現代信息科技中扮演著重要的角色,它們不僅提供有效的數據管理,還支援應用程式和業務流程的順利運作。 ## Database Applications 企業資訊管理通常涵蓋多個部門,包括銷售、會計和人力資源。以下是每個部門的一些基本資訊管理方面: 1. **銷售部門**: - **客戶資訊**:包括客戶名稱、地址、聯絡方式等。 - **產品資訊**:包括產品名稱、描述、價格等。 - **購買記錄**:包括客戶的購買歷史、訂單、交易紀錄等。 2. **會計部門**: - **支付信息**:記錄公司支付給供應商的款項。 - **收款信息**:包括客戶支付給公司的款項。 - **資產管理**:追蹤和管理公司的資產,包括固定資產和流動資產。 3. **人力資源部門**: - **員工信息**:包括員工的基本信息、職位、部門歸屬等。 - **薪資管理**:包括薪水、獎金、津貼等薪酬相關信息。 - **薪資稅收管理**:記錄並管理公司支付的薪資稅款。 這些資訊管理方面通常透過資料庫系統進行組織和存儲,以便於查詢、分析和報告。這有助於企業更有效地運作,提高管理效率,並支援各個部門在日常業務中的需求。資料庫系統的正確使用可以確保資料的一致性、完整性和安全性,從而促進企業的持續發展。 ## Purpose of Database Systems ### file systems 檔案系統是一種用於組織和存儲電腦檔案的系統。這種系統通常由操作系統提供,它確保檔案被儲存在合適的位置,以便應用程式和使用者能夠訪問和管理它們。以下是一些檔案系統的基本特點和概念: 1. **檔案和目錄**:檔案系統使用檔案和目錄來組織資料。檔案是存儲數據的基本單位,而目錄則是用於組織和存儲檔案的容器。 2. **檔案路徑**:每個檔案在檔案系統中都有一個唯一的路徑,指定了檔案的位置。檔案路徑通常包括目錄的層次結構。 3. **檔案屬性**:檔案系統通常會跟蹤檔案的屬性,如檔案大小、創建時間、修改時間等。這些屬性提供了對檔案的基本描述。 4. **權限和訪問控制**:檔案系統使用權限和訪問控制來確保只有授權的用戶能夠訪問或修改檔案。這保障了數據的安全性。 5. **檔案操作**:檔案系統提供一組基本的檔案操作,如創建、讀取、寫入、刪除等。應用程式和用戶可以通過這些操作來管理檔案。 6. **檔案系統層次結構**:檔案系統通常形成一個樹狀的層次結構,根目錄包含所有其他目錄和檔案。這種層次結構使得檔案的組織更為有序。 7. **檔案系統類型**:不同的操作系統使用不同的檔案系統,如NTFS和FAT32用於Windows,而EXT4用於Linux。每種檔案系統都有其自己的特點和優勢。 8. **儲存設備**:檔案系統可以存在於不同的儲存設備上,包括硬碟、固態硬碟、USB閃存驅動器等。 總的來說,檔案系統是一個基本的數據管理系統,用於組織和存儲檔案,並提供應用程式和使用者對數據的訪問。它是操作系統中重要的一個組成部分。 <p class ="text-center"> <a href="https://searchstorage.techtarget.com/definition/file-system" title="link"><img src="https://hackmd.io/_uploads/HybXh-7B6.png" alt="測試圖片" border="0"width="" height="288"></a> </p> ### Probelm of file System to manage big data 資料冗余和不一致性是在使用傳統的檔案系統管理數據時可能出現的問題。以下是一些與這些問題相關的主要挑戰: 1. **資料冗余**: - 資料存儲在多種檔案格式中,<font color="ffff">可能導致相同的資訊在不同的檔案中重複存在</font>。 2. **難以存取資料**: - 因為數據存儲在多個不同的檔案中,存取和檢索資訊變得困難。 3. **資料隔離**: - 不同的資料存儲在多個不同的檔案和格式中,<font color="ffff">沒有統一的方式</font>將其組織在一起。 4. **完整性問題**: - 完整性約束,例如帳戶餘額大於0,<font color="ffff">可能被埋在程式碼中</font>,而不是明確地陳述。 - 難以確保資料的完整性,並且難以添加新的約束或更改現有的約束。 5. **更新的原子性**: - 在更新過程中發生故障可能會導致數據庫處於不一致的狀態,這可能對業務運營產生負面影響。 6. **多用戶同時訪問**: - 需要支援性能的同時訪問,但未受控制的同時訪問可能導致資料不一致。 - 例如,兩人同時讀取帳戶餘額並同時提取資金可能導致不一致的結果。 7. **安全性問題**: - 難以設定用戶對某些但不是所有數據的訪問權限。 - 可能會面臨未經授權的用戶訪問敏感數據的風險。 為了克服這些問題,許多組織轉向使用資料庫管理系統(DBMS),這種系統提供更統一、結構化和高效的方式來管理和存取數據。 ## View of Data 資料庫系統是一個相互關聯的資料集合,以及一組允許使用者訪問和修改這些資料的程式。資料庫系統的一個主要目的是為使用者提供對數據的抽象視圖。 以下是一些相關概念: 1. **資料模型**: - **描述**:資料模型是一套概念工具,用於描述數據、數據關係、數據語義和一致性約束。 - **重要性**:資料模型提供了一種抽象的方式,以理解和組織資料庫中的數據,有助於定義數據的結構和相互關係。 2. **資料抽象**: - **描述**:資料抽象的目的是隱藏用於表示資料的數據結構的複雜性,通過數據抽象的多個層次,將資料結構從用戶中隱藏起來。 - **重要性**:透過資料抽象,使用者可以在不了解實際數據結構的情況下,以更簡單的方式進行訪問和操作數 ### database layer 在資料庫管理系統中,存在不同層次的數據抽象,這些層次有助於組織和管理數據。這三個主要層次分別是物理層次、邏輯層次和視圖層次。 1. **物理層次(Physical Level)**: - **描述**:物理層次涉及到數據在底層存儲媒體上的實際組織和存儲方式。這包括存儲結構、索引機制、數據文件的物理排列等。 - **例子**:硬碟上的數據存儲格式、索引結構、數據分區等。 2. **邏輯層次(Logical Level)**: - **描述**:邏輯層次定義了數據的組織結構和之間的相互關係,而不考慮具體的物理實現。它包括表格、關係、約束和索引等概念。 - **例子**:關聯模型中的表格結構、實體之間的關係、主鍵和外鍵等。 3. **視圖層次(View Level)**: - **描述**:視圖層次是對邏輯層次的一種抽象,它定義了用戶或應用程式可以看到和訪問的數據的部分。視圖提供了對特定數據子集的定制視圖。 - **例子**:基於用戶需求的查詢結果、虛擬表格。 這三個層次之間存在一種分層結構,每個層次都提供了特定的抽象,使得不同的用戶或應用程式可以在不同的層次上處理數據。這種分層結構有助於提高系統的模組化、可維護性和可擴展性。 ## Database Languages ### DDL 用於定義資料庫結構的規格表示法通常是資料定義語言(DDL)。DDL 包括一組語句,這些語句用於描述資料庫中的表格、索引、視圖等對象的結構。下面是一個使用 SQL DDL 語句創建表格的例子: ```sql= CREATE TABLE instructor ( ID CHAR(5), name VARCHAR(20), dept_name VARCHAR(20), salary NUMERIC(8,2) ); ``` 在這個例子中,使用了 `CREATE TABLE` 來指定創建一個名為 "instructor" 的表格,並指定了表格中的欄位名稱、數據類型和大小。 這些 DDL 語句由 DDL 編譯器生成,並被存儲在資料字典中。資料字典包含了有關資料庫的元資料,這些元資料描述了資料庫的結構、完整性約束、主鍵、授權信息等。主要的元資料項目包括: 1. **資料庫結構(Database Schema)**: - 描述了資料庫中的表格、欄位、索引等對象的結構。 2. **完整性約束(Integrity Constraints)**: - 定義了資料庫中數據的合法性和一致性要求,如主鍵約束、外鍵約束等。 3. **主鍵(Primary Key)**: - 定義了唯一標識表格中每條記錄的欄位。 4. **授權信息(Authorization)**: - 指定了誰有權限訪問和操作資料庫中的對象。 DDL 的使用使得開發人員和數據庫管理員能夠定義和管理資料庫的結構,確保數據能夠被有效地組織和存儲。DDL 規定了物理層次、邏輯層次和視圖層次的結構。 ### DML 用於存取和更新由適當資料模型組織的數據的語言被稱為資料操作語言(Data Manipulation Language,簡稱DML),也稱為查詢語言。DML 可以分為兩種主要類型:程序化 DML 和聲明式 DML。 1. **程序化 DML**: - **描述**:需要用戶具體指定需要哪些數據以及如何獲取這些數據。 - **特點**:用戶需要提供具體的操作步驟,指導系統如何執行。 - **例子**:傳統的編程語言中的迴圈、條件語句等。 2. **聲明式 DML**: - **描述**:要求用戶指定需要哪些數據,而不指定如何獲取這些數據。 - **特點**:用戶僅需描述期望的結果,而不需提供具體實現步驟。 - **優勢**:通常比程序化 DML 更容易學習和使用。 - **別稱**:也被稱為非程序化 DML。 在聲明式 DML 中,用戶只需描述需要檢索或更新的數據,而不需要指定具體的操作流程。這使得語言更為簡潔和易於理解。聲明式 DML 的一個常見應用是查詢語言,其中用戶通過描述他們想要的數據集合,而不必指定如何獲取這些數據。在這種情況下,DML 的部分涉及到信息檢索被稱為查詢語言。 SQL 是一個常見的聲明式 DML,用於關聯型資料庫的查詢和操作。 ### SQL Structured Query Language(SQL)是一種非程序性的資料操作語言(DML)。它主要用於查詢、插入、更新和刪除資料庫中的資料。以下是有關 SQL 的一些特點: 1. **非程序性 DML**: - SQL 是一種非程序性 DML,這意味著用戶只需描述他們想要的結果,而不需指定實現這些目標的具體步驟。這種風格使得 SQL 更接近自然語言的表達方式,更容易學習和使用。 2. **查詢結果**: - SQL 查詢通常以表格的形式返回結果。一個查詢可以涉及一個或多個表格,但它始終返回一個表格作為結果。 3. **示例查詢**: - 下面是一個 SQL 查詢的例子,該查詢返回在"Comp. Sci."系的所有教師的姓名: ```sql SELECT name FROM instructor WHERE dept_name = 'Comp. Sci.'; ``` 4. **不是圖靈機等效語言**: - SQL 不是一種圖靈機等效的語言,意味著它沒有足夠的計算能力來處理某些複雜的計算。因此,對於需要執行複雜函數的情況,SQL 通常嵌入在一些高階語言中。 5. **嵌入式 SQL**: - 為了執行複雜的計算,SQL 通常嵌入在一些高階語言中,這樣應用程序就可以使用這些語言的功能並利用 SQL 進行數據操作。 6. **應用程序接口**: - 應用程序通常通過一些語言擴展或應用程序接口(例如ODBC/JDBC)訪問資料庫,這些接口允許應用程序向資料庫發送 SQL 查詢。 總的來說,SQL 是一種強大的語言,用於管理和操作資料庫中的數據。它的非程序性風格使得用戶可以以更自然和簡潔的方式表達他們的需求。 ## Database Design 資料庫設計包含兩個主要方面:邏輯設計和物理設計。 1. **邏輯設計**: - **描述**:邏輯設計階段涉及決定資料庫的結構,即資料庫模式(schema)。這包括在資料庫中定義哪些關聯模式,以及這些模式中應該包含哪些屬性。 - **業務決策**:需要在這個階段進行業務上的決策,例如在資料庫中應該記錄哪些屬性,以滿足業務需求。 - **計算機科學決策**:同時需要進行計算機科學上的決策,確定應該擁有哪些關聯模式,以及屬性應該如何在這些模式之間分佈。 2. **物理設計**: - **描述**:物理設計階段涉及決定資料庫在存儲媒介上的實際佈局,包括索引的建立、數據的分區和儲存方式等。 - **目標**:這個階段的目標是優化資料庫的性能,提高查詢效率,減少存儲空間的浪費,並確保資料的高效檢索。 簡而言之,邏輯設計涉及確定資料庫的結構和關係,而物理設計則關注如何在實際存儲層面上優化這些結構。這兩者的合理結合有助於構建一個高效、靈活且滿足業務需求的資料庫系統。 ## Database Engine 資料庫系統被分為不同的模組,每個模組負責整體系統的不同職責。資料庫系統的功能組件可以分為以下三個主要部分: 1. **儲存管理器(Storage Manager)**: - **職責**:儲存管理器負責處理資料的儲存和檢索,包括數據的物理儲存結構、索引的建立和管理、磁碟空間的分配和回收等。 - **操作**:儲存管理器確保資料庫的數據安全地存儲在磁碟上,並提供有效的檢索機制。 2. **查詢處理器組件(Query Processor Component)**: - **職責**:查詢處理器組件負責解釋和執行用戶提交的查詢,轉換高級查詢語言(如 SQL)為可執行的計算機操作。 - **操作**:查詢處理器分析查詢語句,優化查詢計劃,並與儲存管理器協同工作,確保有效率的資料檢索。 3. **交易管理組件(Transaction Management Component)**: - **職責**:交易管理組件處理並確保資料庫的事務完整性,包括事務的開始、提交和回滾。它還負責管理並實現並發控制,以確保多個事務能夠同時運行而不產生不一致的結果。 - **操作**:交易管理組件跟踪事務的狀態,確保在一個事務中所做的更改要麼全部生效,要麼全部回滾,從而保持資料庫的一致性。 這些組件共同工作,形成一個完整的資料庫引擎,使資料庫系統能夠有效地存儲、檢索和管理數據,同時確保數據的一致性和完整性。 ## Database Architecture ### **儲存管理器(Storage Manager)** 儲存管理器是一個程式模組,它提供低層次數據庫中儲存的資料與應用程式和系統提交的查詢之間的接口。儲存管理器負責執行以下任務: 1. **與作業系統檔案管理器的交互(Interaction with the OS file manager)**: - 與操作系統檔案管理器的協同工作,以確保數據庫的儲存和檢索在操作系統層面上得以管理。 2. **有效的儲存、檢索和更新數據(Efficient storing, retrieving and updating of data)**: - 提供有效的機制,以便有效地儲存、檢索和更新數據,確保數據的高效管理。 3. **儲存管理器的組件**: - 授權和完整性管理器(Authorization and Integrity Manager) - 事務管理器(Transaction Manager) - 檔案管理器(File Manager) - 緩衝區管理器(Buffer Manager) 4. **實現的數據結構**: - 數據檔案(Data files):用於儲存資料庫本身的檔案。 - 數據字典(Data dictionary):儲存有關資料庫結構的元數據,特別是資料庫的模式。 - 索引(Indices):提供對數據項的快速訪問。資料庫索引提供指向具有特定值的數據項的指針。 儲存管理器的角色是確保數據庫的有效管理、一致性和安全性。透過與其他系統組件協同工作,它確保應用程式和查詢可以有效地與底層的數據庫交互。 ## Database Users and Administrators ## History of Database Systems

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully