ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

(数据库原理及应用笔记)数据库管理系统

2020-04-28 19:04:53  阅读:380  来源: 互联网

标签:transaction 管理系统 数据库 笔记 A1 rule attributes E1 E2


  • The component of DBMS core

在这里插入图片描述-> UFI (即席访问)
-> APIs (类库、嵌入式…)
-> Access management (访问原语)

  • The process structure of DBMS

-> Single process structure
在这里插入图片描述

-> Multi processes structure
在这里插入图片描述
-> Multi threads structure

在这里插入图片描述
-> Communication protocols between processes/threads

  1. Access types
    ( Query all or most records of a file(>15%)
    ( Query some special record
    ( Query some records(<15%)
    ( Scope query
    ( Update
  2. File organization
    ( Heap file
    ( Direct file
    ( Indexed file:index + heap file/cluster ->B+Tree
    ( Dynamic hashing
    ( Grid structure file
    ( Raw disk
  3. Index technique
    ( B+ Tree
    ( Clustering index(簇集索引)
    ( Inverted file
    ( Dynamic hashing
    ( Grid structure file and partitioned hash function
    ( Bitmap index(used in data warehouse)
    ( Others
  4. Access primitives
    -> Algebra Optimization(Rewrite
    -> Operation Optimization(存储结构、索引
S(SNUM, SNAME, CITY)
SP(SNUM, PNUM, QUAN)
P(PNUM, PNAME, WEIGHT, SIZE)
SELECT SNAME
FROM S, SP, P
WHERE S.SNUM=SP.SNUM AND
SP.PNUM=P.PNUM AND
S.CITY=‘Nanjing’ AND
P.PNAME=‘Bolt’ AND
SP.QUAN>1000;

在这里插入图片描述在这里插入图片描述

  • The operation optimization of the tree
    -> Nest Loop,R as O,S as I
    -> Nest Loop,R as I,S as O
    -> Nest Loop,use possible index on R or S
    -> Merge Scan
    -> Hash join
  • Algebra optimization
    -> Exchange rule of ⋈/×: E1 × E2 ≡ E2 ×E1
    -> Combination rule of ⋈/×: E1×(E2×E3)≡(E1×E2)×E3
    -> Cluster rule of ∏: ∏A1…An(∏B1…Bm(E))≡∏A1…An(E),
    legal when A1…An is the sub set of {B1…Bm}
    -> Cluster rule of δ: δF1(δF2(E))≡δF1∧F2(E)
    -> Exchange rule of ∏ and δ: δF(∏A1…An(E))≡∏A1…An (δF(E)) if F includes attributes B1…Bm which don’t belong to A1…An, then ∏A1…An (δF(E)) ≡ ∏A1…An δF(∏A1…An, B1…Bm(E))
    -> If the attributes in F are all the attributes in E1, thenδF(E1×E2) ≡ δF(E1)×E2;
    if F in the form of F1∧F2, and there are only E1’s attributes in F1, and there are only E2‟s attributes in F2, then δF(E1×E2) ≡δF1(E1)×δF2(E2);
    if F in the form of F1∧F2, and there are only E1‟s
    attributes in F1, while F2 includes the attributes both in E1 and E2, then δF(E1×E2) ≡δF2(δF1(E1)×E2);
    -> δF(E1 ⋃ E2) ≡ δF(E1) ⋃ δF(E2)
    -> δF(E1 - E2) ≡ δF(E1) - δF(E2)
    -> Suppose A1…An is a set of attributes, in which B1…Bm are E1‟s attributes, and C1…Ck are E2‟s attributes, then∏A1…An(E1×E2)≡∏B1…Bm(E1)×∏C1…Ck(E2)
    -> ∏A1…An(E1 ⋃ E2)≡∏A1…An(E1) ⋃ ∏A1…An(E2)
  • Basic principles
    -> Push down the unary operations as low as possible
    -> Look for and combine the commo n sub-expression
  • The operation optimization
    -> Optimization of select operation
    -> Optimization of project operation
    -> Optimization of set operation
    -> Optimization of join operation
    -> Optimization of combined operations
  • Recovery
    -> Reducing the likelihood of failures
    -> Recover from failures
    -> Restore DB to aconsistent state after some failures
    (Redundancy is necessary
    (Should inspect all possible failures
    -> Periodical dumping
    在这里插入图片描述
    -> Backup + Log
    在这里插入图片描述
  • Transaction
    -> Atomic action
    -> Consistency preservation(保持一致性)
    -> Isolation
    -> Durability
  • Some structures to support recovery
    -> Commit list
    -> Active list
    -> Log
    在这里插入图片描述
  • Commit rule and Log ahead rule
    -> Commit rule: A.I must be written to nonvolatile strorage(非挥发存储器) before commit of the transaction
    -> Log ahead rule: If A.I is written to DB before commit then B.I must first written to log
    -> Recovery strategies
  • Three kinds of update strategy
    -> A.I-DB before commit
    在这里插入图片描述在这里插入图片描述-> A.I-D.B after commit
    在这里插入图片描述在这里插入图片描述-> A.I-D.B concurrently with commit
    在这里插入图片描述在这里插入图片描述-> 异地更新
  • Concurrency control
    在这里插入图片描述-> Serializable
  • Locking Protocol
  • X locks
    在这里插入图片描述

在这里插入图片描述
-> Conclusions
-> Well-formed + 2PL: serializable
-> Well-formed + 2PL + unlock update at EOT: serializable and recoverable.(without domino phenomena)
-> Well-formed + 2PL + holding all locks to EOT: strict two phase locking transaction

  • (S,X) locks
    -> S lock — if read access is intended.
    -> X lock — if update access is intended.
    在这里插入图片描述- (S,U,X) locks
    -> U lock — update lock.For an update access the transaction first acquires a U-lock and then promote it to X-lock.
    -> Purpose — shorten the time of exclusion,so as to boost concurrency degree, and reduce deadlock.
    在这里插入图片描述
  • Deadlock & Livelock
    -> Deadlock — wait in cycle,no transaction can obtain all of resources needed to complete
    -> Prevention(do not let it occur)
    -> Solving(permit it occurs,but can solve it)
    在这里插入图片描述

-> Livelock — although other transaction release their resource in limited time,some transaction can not get the resources needed for a very long time.
-> Adjust schedule strategy,such as FIFO
在这里插入图片描述

  • Deadlock Detection
    -> Timeout
    -> Detect deadlock by wait-for graph G=<V,E>
    -> When to detect? —
    whenever one transaction waits.
    -> What to do when detected? —
    ①Pick a victim;
    ②Abort the victim and release its locks and resources;
    ③Grant a waiter;
    ④Restart the victim(automatically or manually)
    -> Deadlock avoidance —
    ①Requestin all locks at initial time of transaction
    ②Requesting locks in a specified order of resource
    ③Abort once conflicted
    ④Transaction Retry
    -> Every transaction is uniquely time stamped.If Ta requires a lock on a data object that is already locked by Tb,one of the following methods is uesd
    ①Wait-die
    ②Wound-wait
    In above,both have only one direction wait,either older->younger or younger->older.It is impossible to occur wait in cycle,so the dead lock is avoided.

标签:transaction,管理系统,数据库,笔记,A1,rule,attributes,E1,E2
来源: https://blog.csdn.net/zhuangww05/article/details/105534479

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有