TheRiseOfDavid
    • 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
      • Invitee
    • 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
    • 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 Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync 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
Invitee
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
--- tags: NTUT_Note --- # 資料庫管理期中考 ```cpp= int main(){ cout << "hello world" ; } ``` ## 老師說得必考 * 非主鍵的外來鍵(Foreign key) 畫虛線 * 外來鍵用其他表的主鍵表示兩表格的關係 * 候選鍵一定要有值,非候選鍵不一定有值 * 主鍵是從候選鍵挑出來的 ### determinant(行列式) and Candidate key(候選鍵) 可以識別一筆row的資料,但若為複合鍵的情況下,Candidate key的所有屬性都不能是多餘的(redundancy),也就是不能有屬性是刪除後對於Candidate key識別一筆row資料沒有影響;Candidate key 一定是 Determinant,但Determinant不一定是Candidate key。 ### 問你主鍵(Primary Keys)是什麼 參考限制條件 * 一定要畫**實線** * 不可有空值(Not Null) * 永遠不會改變(Never Change) * 非識別值(Nonidentifying Value) 即「值」本身沒有意義。例如買電子產品都會有一個「序號」,假設第一碼代表供應商麼,第二碼代表所在地區(台北、台中…),有一天供應商搬家了,從台北搬到台中,那第二碼就不會符合現況。 * 主鍵是關係的唯一標識符。 示例包括員工編號,社會保險號等。這可以確保所有行都是唯一的。 * Primary keys are unique identifiers of the relation. Examples include employee numbers, social security numbers, etc. This guarantees that all rows are unique. #### Domain Constraints 域約束 * Allowable values for an attribute (includes data types and restrictions on values) * 屬性的允許值(包括數據類型和值限制) #### Entity Integrity 實體完整性 * No primary key attribute may be null. All primary key fields MUST contain data values. * 主鍵屬性不能為空。 所有主鍵字段必須包含數據值。 #### Referential Integrity 參照完整性 * Rules that maintain consistency between the rows of two related tables. * 維護兩個相關表的行之間一致性的規則。 ### 資料正規化 3個異常 4-38 4-39 ![](https://i.imgur.com/pQz0S5h.png) #### Insertion * can’t enter a new employee without having the employee take a class (or at least empty fields of class information) * 在沒有讓員工參加課程的情況下(或至少在課程信息的空白字段中)不能輸入新員工 #### Deletion * if we remove employee 140, we lose information about the existence of a Tax Acc class * 如果我們刪除員工140,我們將丟失有關Tax Acc類的信息 #### Modification * giving a salary increase to employee 100 forces us to update multiple records * 給員工100加薪迫使我們更新多個記錄 ## 資料正規化 ### 1NF * 是指在資料表中的所有記錄之屬性內含值都是基元值(Atomic Value)。 基元值(Atomic Value) = 亦即無重覆項目群 * 沒有任何兩筆以上的資料是完全重覆 * 資料表中有主鍵, 而其他所有的欄位都相依於「主鍵」。 ### 2NF [看這裡就可以](https://hackmd.io/DafKP08ARwKBz-78gBSFYQ#%E8%B3%87%E6%96%99%E6%AD%A3%E8%A6%8F%E5%8C%96-3%E5%80%8B%E7%95%B0%E5%B8%B8-4-38-4-39) ### 3NF 各欄位與「主鍵」之間沒有「遞移相依」的關係。 * 遞移相依 A 跟 B 有關係,B 跟 C 有關係,則 A 跟 C 就是**遞移相依** ### 實務範例 ![](https://i.imgur.com/YLLLT5T.png) ## 資料來源 [關聯資料表正規化(NORMALIZATION)--鍵,KEY](https://blog.kkbruce.net/2010/10/normalization-key.html#.X7qQVM0zaUl) [Key and Non-Key Fields](https://answers.sap.com/questions/2689632/key-and-non-key-fields.html) [1031 - 資料庫管理概論 Chapter 4 Database design](http://abbydoubleb.blogspot.com/2014/10/1031-chapter-4-database-design.html) [資料庫正規化](http://cc.cust.edu.tw/~ccchen/doc/db_04.pdf)

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