当前位置:文档之家› 分布式数据库答案

分布式数据库答案

分布式计算与分布式系统No.1:1.分布式数据库的特点:*物理分布性:分布式数据库中的数据是分散存储在计算机网络中的多个站点上的。

*逻辑整体性:数据逻辑上是互相联系的。

*站点自治性:各站点上的数据由本地的数据库管理系统管理,完成本站点的应用。

2.分布式数据库和集中式数据库的差别:*在集中式数据库中,数据独立性指数据的逻辑独立性与物理独立性。

在分布式数据库中,还增加了数据分布独立性,即分布透明性。

*在集中式数据库中,对共享数据库的控制是集中的,在分布式数据库中,数据可以局部共享或全局共享。

*在集中式数据库中,尽量减少冗余度是系统目标之一,在分布式数据库中却希望增加冗余数据,存储同一数据的多个副本*分布式数据库中各局部数据库应满足集中式数据库的一致性、可串行性和可恢复性。

除此以外还应保证数据库的全局一致性、并行操作的可串行性和系统的全局可恢复性。

3.分片的正确性判据:若R={R1,R2,…,Rn},满足:●完整性:如果a∈R,则必有a∈Ri,i=1,2,…,n●可重构性:R=∪Ri(水平分片),或R=∞Ri(垂直分片)●不可相交性:Ri∩Rj=空集,i≠j,i,j=1,2,…,n(水平分片)Ri∩Rj=主键属性,i≠j,i,j=1,2,…,n(垂直分片)No.2:1. create View v(name) asselect name from proj where pname = “CAD”2. create View v(name) asselect name from proj1No.3:1.Student1=SL dno=1 StudentStudent2=SL dno=2 StudentStudent3=SL dno=3 Student*完整性:∵{dno=1}∈{dno={1,2,3}},{dno=2}∈{dno={1,2,3}},{dno=3}∈{dno={1,2,3}}∴Student中有且只有{dno=1},{dno=2}和{dno=3}三个元素,满足完备性。

*可重构性:∵{dno={1,2,3}}={dno=1}∪{dno=2}∪{dno=3}∴满足可重构性。

*不可相交性:∵{dno=1}∩{dno=2}={dno=1}∩{dno=3}={dno=2}∩{dno=3}=空集∴满足不可相交性。

No.41.(a)LEVEL 1: read(terminal,$sno)Select sname, age, dno, type into $sname, $age, $dno, $type from Studentwhere sno=$snowrite(terminal, $sname, $age, $dno, $type)LEVEL2: read(terminal,$sno)Select sname, age, dno, type into $sname, $age, $dno, $type from Student1where sno=$snoif not #FOUND thenSelect sname, age, dno, type into $sname, $age, $dno, $type from Student2where sno=$snowrite(terminal, $sname, $age, $dno, $type)LEVEL3:read(terminal, $sno)Select sname, age, dno, type into $sname, $age, $dno, $typefrom Student1 at site1where sno=$snoif not #FOUND thenSelect sname, age, dno, type into $sname, $age, $dno, $typefrom Student1 at site2where sno=$snoif not #FOUND thenSelect sname, age, dno, type into $sname, $age, $dno, $typefrom Student2 at site3where sno=$snoif not #FOUND thenSelect sname, age, dno, type into $sname, $age, $dno, $typefrom Student2 at site4where sno=$snowrite(terminal, $sname, $age, $dno, $type)1.(b)LEVEL 1:Update StudentSet dno=2 Where sno=060138LEVEL 2: Select sname into $SNAME from student1Where sno=060138If #FOUND thenUpdate student1Set dno=2 Where sno=060138ElseUpdate student2Set dno=2 Where sno=060138LEVEL 3: Select sname into $SNAME from student1 at site1 Where sno=060138If #FOUND thenUpdate student1 at site1Set dno=2 Where sno=060138ElseSelect sname into $SNAME from student1 at site2 Where sno=060138 If #FOUND thenUpdate student1 at site2Set dno=2 Where sno=060138ElseSelect sname into $SNAME from student2 at site3 Where sno=060138 If #FOUND thenUpdate studen2 at site3Set dno=2 Where sno=060138ElseSelect sname into $SNAME from student2 at site4 Where sno=0601382.分片原则:完备性:P1 v P2 =true;不相交性:P1=!P2这两个断言可能不满足上述原则,因为不能保证职位就只有manager和programmer,所以修改为P1:title=“manager”P2:title≠“manager”。

No.5:Emp1Emp2 pay1Emp3 pay2Emp4可采用半连接方式进行查询优化,减少站之间的数据输出量,但同时要增加通信次数和本地处理时间。

No.6:1.Create view vemp (eno,ename,pno,resp) asselect eno,ename,pno,resp from emp,respwhere emp.eno =resp.eno and resp.dur >=362.Create view Vemp1 (eno,ename) as select eno,ename from emp1Create view Vemp2 (eno,ename) as select eno,ename from emp2Create view Vresp1 (eno,pno,resp) as select eno,pno,resp from resp1 where dur >=36Create view Vresp2 (eno,pno,resp) as select eno,pno,resp from resp2Site1: select eno,ename,pno,resp into $eno,$ename,$pno,$resp from Vemp1at home, Vresp1at home, Vemp2at site2, Vresp2at site3 where and Vemp.eno=Vresp.enoSite2: select eno,ename,pno,resp into $eno,$ename,$pno,$resp from Vemp2at home, Vemp1at site1, Vresp1at site1, Vresp2at site3 where Vemp.eno= Vresp.enoSite3:select eno,ename,pno,resp into $eno,$ename,$pno,$resp from Vemp2at site2, Vemp1at site1, Vresp1at site1, Vresp2at home where Vemp.eno= Vresp.eno3.Select ename,resp from vemp,proj where vemp.pno=proj.pno and proj.pname=”e-commerce”Select ename,resp from vemp,proj1 where vemp.pno=proj1.pnoNo.7:1.集中式目录:全局系统采取集中式存放方式,具体又分为:(1)单一主目录方式:系统将全局目录只存放在某一站点上。

缺点是系统过分依赖存放主目录的站点,易形成瓶颈。

(2)分组主目录:将系统站点分为若干组,每一组设置一个主目录,形成系统分组主目录方式。

2.局部式目录每个站点只为存放在本站点的数据保留一份(局部目录),系统的整体目录是所有这些不相交的局部目录的集合。

利于站点的自制性,容易进行目录的更新。

但如果不采用目录定位表,则需要较高的通信代价和使目录查询响应时间延长3.全复制式目录在每个站点上都存放一个完整的全局目录,但目录的更新必须传播到每一个站点。

这种方式不存在目录查询的通讯开销,查询响应速度最高,系统的可靠性也较高,但这种方式的目录冗余太多,使得目录更新开销过No.8:8.设:C0 = 0, C1 = 1。

所有可选的Semi-Join:P1: R NSJ B=B U;Benefit=0.6*(3+4+25)*5,000 = 96,000;Cost=4*20 = 80 P2: R NSJ A=A S;Benefit=0.8*(3+4+25)*5,000 = 128,000;Cost=3*20 = 60 P3: U NSJ B=B R;Cost=4*50 = 200P4: U NSJ C=C S;Benefit=0.5*(4+2+20)*100 = 1,300;Cost=2*5 = 10P5: S NSJ A=A R;Cost=3*100 = 300P6: S NSJ C=C U;Cost=2*10 = 20∴选P2,对R的影响:card(R) = 0.2*5,000 = 1,000n =5,000 r = 1,000 m B剩下的Semi-Join:P1: R NSJ B=B U;Benefit=0.6*(3+4+25)*1,000 = 192,000;Cost=4*20 = 80 P3: U NSJ B=B R;Cost=4*50 = 200P4: U NSJ C=C S=0.5;Benefit=0.5*(4+2+20)*100 = 1,300;Cost=2*5 = 10P5: S NSJ A=A R;Cost=3*20 = 60P6: S NSJ C=C U;Cost=2*10 = 20∴选P1,对R的影响:card(R) = 0.4*1,000 = 400n = 1,000 r = 400剩下的Semi-Join:P3: U NSJ B=B R;Cost=4*20 = 80P4: U NSJ C=C S;Benefit=0.5*(4+2+20)*100 = 1,300;Cost=2*5 = 10P5: S NSJ A=A R;Cost=3*20 = 60P6: S NSJ C=C U;Cost=2*10 = 20∴选P4,对U的影响:card(U) = 0.5*100 = 50n = 100 r = 50剩下的Semi-Join:P3: U NSJ B=B R;Cost=4*20 = 80P5: S NSJ A=A R;Cost=3*20 = 60P6: S NSJ C=C U;Cost=2*5 = 10只有Cost没有Benefit,故停止。

相关主题