上海交通大学数据库原理陆朝俊复习docxWord文件下载.docx
《上海交通大学数据库原理陆朝俊复习docxWord文件下载.docx》由会员分享,可在线阅读,更多相关《上海交通大学数据库原理陆朝俊复习docxWord文件下载.docx(10页珍藏版)》请在冰豆网上搜索。
(B)
ConvertthefollowingE/Rdiagram(withdetailsomitted)toarelationaldatabaseschemausingtheobject-orientedmethod・Howmanyrelationschemaswillbeproduced?
(Assumethateachentitysethasitsownspecialattributes.)
RelationalTheory
GivenarelationR(A,B,C,D,E)andFDsABtCE,BtD,andDtE,whichofthefollowingFD'
scannotbeinferred?
(A)ADtCE(B)BCtD(C)ABtA(D)BtE
GivenarelationR(A,B,C,D)withFD:
AtBC,whichofthefollowingMVD'
(A)AttEC
(B)AttB
(C)AttBD
(D)Noneoftheabove.
SupposewehavearelationR(A,B,C,D,E)andtheFD'
sAtDE,DtB,andE—>
C.IfweprojectR(andthereforeitsFD,s)ontoschemaS(A,B,C),whatistrueaboutthekey(s)forS?
(A)OnlyABCisakey
(B)OnlyAisakey
(C)OnlyDEisakey
(D)A5B,andCareeachkeys
SupposewearegivenarelationschemaR(A,B,C,D,E)withfunctionaldependenciesAtB,BCtDandEtC.IfweprojectRontoS(B,C,D,E),whichofthefollowingfunctionaldependenciesholdsinSandisnotaBCNFviolationforS?
(A)BCtD(B)BEtD(C)BtE(D)EtC
SupposethatR(A,B,C,D)satisfiesMVD:
AttBanditisknownthatRhastuples(al,bl,cl,dl),(al,b2?
c25d2)?
and(a2,bl,cl,d2)・HowmanytuplesmustRhaveatleast?
(A)3(B)4(C)5(D)6
RelationalalgebraandDatalog
Inthefollowingquestion,assumeRandSarebags,andtheoperatorsarebagoperators.
Q1:
(RUS)-(RAS)
Q2:
(S-R)U(R-S)
(A)QIandQ2producethesameanswer.
(B)TheanswertoQIisalwayscontainedintheanswertoQ2.
(C)TheanswertoQ2isalwayscontainedintheanswertoQI.
(D)QIandQ2producedifferentanswers.
GivenrelationsP(A,B,C)andQ(C,D),whichofthefollowingrelationalalgebraexpressionsisequivalenttothisDatalogrule:
Answer(x,w)P(x,y,z)ANDQ(y,w)ANDx<
y
(A)兀P.A,Q.D(6.A<
P.B(P°
°
P.C=Q.CQ))
(B)兀P.A,Q.D(6.A<
Q.CandP.C=Q.C(?
XQ))
(C)兀p.a,q.d(6.a<
p.c(P)00Q)
(D)兀p.a,q.d(6.a<
q.c(P°
p.b=q.cQ))
SQL
QI:
SELECTDISTINCTaFROMRWHEREb>
10;
SELECTaFROMRWHEREb>
10GROUPBYa;
ConsiderthefollowingtwoSQLqueriesonrelationsR(a,b)andS(c):
SELECTaFROMR
WHEREb>
ALL(SELECTcFROMS);
ANY(SELECTcFROMS);
(A)Q1andQ2alwaysproducethesameanswer.
(B)TheanswertoQIisalwayscontainedintheanswertoQ2・
GivenR(A,B)={('
a;
10),('
b;
20),('
c'
30)},andexecutethefollowingthreestatements.Whatistheresultofthelaststatement?
createviewVasselectAfromRwhereB>
10;
insertintoVvalues('
cT);
selectcount(*)fromV;
GivenarelationR(x)andtwoqueriesasfollows:
SELECTxFROMR;
(SELECTxFROMR)UNION(SELECTxFROMR);
Inthe3-valuedlogicusedbySQL,supposexhasthevalueNULLandyisTRUE,theresultfor(x>
1)ORyis:
(A)FALSE(B)UNKNOWN(C)TRUE(D)NULL
ConsiderthefollowingtwoSQLqueriesonrelationsR(a?
b)andS(b9c):
(RNATURALFULLOUTERJOINS)
UNION
(RNATURALJOINS);
(RNATURALLEFTOUTERJOINS)
(RNATURALRIGHTOUTERJOINS);
SupposethatrelationR(A,B)has100tuplesandS(B,C)has50tuples.ThenumberoftuplesinRNATURALLEFTOUTERJOINSisatmost:
(A)50(B)100(C)150(D)5000
AssumethatarelationR(a,b)hasnoNULL'
sbutmayhaveduplicates・Comparethefollowingtwoqueries:
SELECTcount(*)FROMRGROUPBYa;
SELECTcount(b)FROMRGROUPBYa;
Inthefollowing,theresultsofQIandQ2shouldbetakentobetheresultofthefinalSELECT*FROMR.Assumethattheschema