Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

CS143MidtermCheatsheet

GENERALSQL

CREATETABLEname(
Attr_nameREFERENCEStable(attr),
Attr<TYPE>,
PRIMARYKEY(attr1,attr2),
FOREIGNKEYattrREFERENCEStable(attr)
);
SELECT<DISTINCT>attributes,aggregates
FROMrelations<ASrename>
<EXCEPTrelation>
WHEREconditions<EXISTS><IN><NOTIN><ANY><ALL><SOME>
<relation>
GROUPBYattributes
HAVINGconditionsonaggregates<SUM><COUNT><AVG><MIN>
<MAX>
ORDERBYattributes,aggregates<ASC><DESC>
Evaluationorder:FROMWHEREGROUPBYHAVINGORDER
BYSELECT
R1LEFTOUTERJOINR2ONR1.A=R2.A(keepalldanglingtuplesfrom
R1bypaddingR2attributeswithNULL)
R1RIGHTOUTERJOINR2ONR1.A=R2.A(keepalldanglingtuples
fromR2bypaddingR1attributeswithNULL)
R1FULLOUTERJOINR2ONR1.A=R2.A(keepalldanglingtuplesfrom
bothR1andR2withappropriatepadding
U^T=U,U^F=F,U^U=U
UvT=T,UvF=U,UvU=U

PRIVILEGES

GRANT<SELECT><INSERT><DELETE><UPDATE(attribute)>
ONrelation
TOusers
<WITHGRANTOPTION>
REVOKE<SELECT><INSERT><DELETE><UPDATE(attribute)>
ONrelation
FROMusers
<CASCADE><RESTRICT>
P*=privilegePwithgrantoption
P**=sourceofprivilegeP(impliesgrant)

DISK

Capacity=(#platters)(#surfaces/platter)(#tracks/surface)(#sectors/track)(#
bytes/sector)
Accesstime=(seektime)+(rotationaldelay)+(transfertime)
Rotationaldelay=(60sec/#RPM)
Timetoread1track=(60sec/#RPM)
Timetoread1sector=(timetoread1track)/(#sectors/track)
Transferrate=(#bytes/sector)/(timetoread1sector)
Sequentialaccess=(seektime)+(rotationaldelay)+(#blocks*transfertime)
Randomaccess=(accesstime)*(#blocks)
Tableintodisk:
block:(#bytes/block)(#bytes/tuple)=(#tuples/block)
Table:(#tuples/table)(#tuples/block)=(#blocks/table)
Size=(#blocks/table)(#bytes/block)
Indexsize:
(#byte/key)+(#byte/pointer)=(#byte/entry)
(#byte/block)/(#byte/entry)=(#entry/block)
(#records)/(#entry/block)=#blocks
(#blocks)(#bytes/block)=sizeofindex

You might also like