NTNUCSIE112
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
    • 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 No publishing access yet

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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 New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Make a copy 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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
  • 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Database Theories NTNU 資料庫理論 ##### [Back to Note Overview](https://reurl.cc/XXeYaE) {%hackmd @sophie8909/pink_theme %} ###### tags: `NTNU` `CSIE` `必修` `Database Theories` <!-- tag順序 [學校] [系 必選] or [學程 學程名(不含學程的 e.g. 大師創業)] [課程] --> ## Score - Midterm Exam 25% - Final Exam 25% - Homework 20% - Team Project 25% ## Textbook ### Database System Concepts #### Ch.27 ~ 32 <https://www.db-book.com/db7/> ## Schedule ![Schedule](https://i.imgur.com/0ENxDDp.png) ## Chapter 1 Introduction ### 1.3 View of Data ![view of data](https://i.imgur.com/bI3x2R9.png) #### Data Level - Physical Level - Logical Level - View Level #### Instances and Schemas ##### Schema structure ##### Instances value ### 1.4 Database Languages #### Data Manipulation Language (DML) - known as query language #### Data Definition Language (DDL) - DDL compiler generates a set of tables stored in a data dictionary - Data dictionary contains metadata - Database schema - Integrity constraints Primary key (ID uniquely identifies instructors) - Referential integrity - e.g. dept_name value in any instructor tuple must appear in department relation ### 1.6 Database Engine - Storage manager - the interface between - the low-level data stored in the database - the application programs and queries submitted to the system - Authorization and integrity manager 權限控管 - Transaction Manager 過程控管 - Recovery manager - ensures consistent (correct) of the database - state despite failures - Concurrency-control manager - controls the interaction among the concurrent transactions - ensure the consistency of the database. - File manager 倉庫管理 - Buffer manager 取貨控管 ## Chapter 2 Introduction to the Relational Model ### 2.3 Keys - Let $K \subseteq R$ - **superkey** - identify of unique tuple of possible relation - K is a superkey of R if values for K are sufficient to identify a unique tuple of each possible relation r(R - **candidate key**: if superkey $K$ is minimal - 只要沒有多餘的欄位就算,不一定是這個表裡面需要取最小的,所以一個表可以有多個 candidate key - **primary key**: one of the candidate keys - 通常是最常用來查表的 - 只有一個 - 別人的 primary key - **Foreign Key** - value in one relation must appear in another - 連接跟另一個表的關係 - Referencing relation - Referenced relation ### 2.6 The Relational Algebra ![Relational Algebra Table](https://i.imgur.com/TbS8aUa.png) ## Chapter 3 Introduction to SQL ## Chapter 4 Intermediate SQL ### Join operations | operations | meaning | | ---------------- | ------- | | Outer Join | | | Left Outer Join | | | Right Outer Join | | | Full Outer Join | | #### on #### using ### Create Views ### Transactions ### Integrity Constraints #### DDL 的參數設定 - Not null - check - casecade - 如果飲用的東西被刪掉就跟著被刪 - set nu ### Built-in Data Types in SQL ### Index ### Authorization ## Chapter 5 Advanced SQL ## Chapter 6 Database Design Using the E-R Model ## Chapter 7 Relational Database Design ## Chapter 27 Formal Relational Query Languages ### Relational Algebra - Procedural language - Six basic operators - selection: $\sigma$ - project: $\Pi$ - union: $\cup$ - set difference: – - Cartesian product: x - rename: $\rho$ - The operators take one or two relations as inputs and produce a new relation as a result <!-- class note --> ## Relational Model ### Data Definition Language(DDL) - Database schema - Integrity ### Data Manipulation Language (DML) - also known as query language ### Procedure Query Language (relational algebra) ### Embedded SQL ### Database Design - Design Process - Initial - 了解使用者需求 - Outcome: a specification of user requirements - Secomd phase(conceptual design) - 選擇一個資料模型 - 將需求轉換成 - Logical Design - Deciding on the database schema ### Transaction Management - atomicity - consistency - durability - 一旦交易成功,新的資料必須存在disk #### Recovery manager - ensure that the database remains in a consistent(correct) state despite failures - system faiure ### Two-tier and Three-tier architectures ![](https://i.imgur.com/kwtmvwf.png) ### History of Database Systems ## Entity-Relationship Model ### Example attribute tuple ### Binary relations ### Relations notations ## Relational Algebra - Procedural Language <!-- https://hackmd.io/@NTNUCSIE112/DB109-2_RelaAlge --> ### Selection operation - Notation: $\sigma_p(r)$ - $p$ selection predicate - Defined as $\sigma_p(r) = \{ t| t \in r \land p(t)\}$ ### Project Operation - Notation: $\Pi$ ### Union Operation ### Set different Operation ### Cartesian-Product Operation Composition ### Natural Join Operation 相同欄位會合併 #### Theta Join Operation $r\bowtie_\theta s=\sigma_\theta(r\times s)$ 相同欄位會保存 ### Outer Join Operation #### Left #### Right ### Aggregate Function {%hackmd @NTNUCSIE112/DB109-2_RelaAlge %} ## ER Model ### Design Process - Characterize the data needs - Conceptual design - scheme 要有什麼 - Specify functional requirements - 需要哪些功能性需求 - Implementation - Logical-design phase - Physical-design phase - Design alternatives - Redundancy - Incompleteness ## Attributes - Attribute types - Simple and composite ### Composite Attributes ### Strong Entity Set ### Weak Entity Set - Redundant: 關係的表在一邊都已經記錄到了 ### Design Issus - Use of entity set or attributes - Entity set - Attributes - 如果該資料有獨立需要管理的東西 ## Boyce-Codd Normal Form ## Ch.8 Relational Database Design ### Features of Good Relational Design decompose: split up Functional dependency lossy decomposition: cannot reconstruct the original relation 有損 lossless-join decomposition: 無損 ### Atomic Domains and First Normal Form first normal form: the domains of all attributes of R are atomic 沒有多筆資料在一個欄位 - functional dependencies - multivalued dependencies ### Functional Dependency Theory - closure: certain other functional dependencies - denote the closure of F by F+ - $F^+ \supseteq F$ ### Decomposition Using Functional Dependencies ### Decomposition Algorithms ### Decomposition Using Multivalued Dependencies ### Database-Design Process

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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