COMPSCI 186 Study Guide - Midterm Guide: Timeflies
Midterm2:CS186,Spring2015
Prof.J.Hellerstein
You should receive a double-sided answer sheet and an 8-page exam.
Mark your name and login on both sides of the answer sheet, and in the blanks above.
For each question, place only your final answer on the answer sheet—do not show work or
formulas there.
You may use the backs of the questions for scratch paper, but do not tear off any pages.
We will ask you to turn in your question sheets as well as your answers.
1
I.ERDiagrams[18points]
1.[4points]TrueorFalse:
a. ERdiagramsareusedtomodelthephysicalschemaofadatabase.
False,theyareusedtomodelthelogicalschema.Physicalschemareferstothings
likefileandindexlayout.
b. AnentitysetEcanbeassociatedwitharelationshipsetRmorethanonce.
True,forexamplearelationshipReports_TowhichhastheentityEmployees
participatingtwice,sinceManagersarealsoEmployees.
c. Atmost2distinctentitysetscanbeassociatedwithanyrelationshipsetR.
False,forexample,aternaryrelationship“Covers”withparticipatingentities
Employees,Dependents,andPolicies.
d. Aweakentitysetmusthavetotalparticipationinitsidentifyingrelationshipset.
True,bydefinition.
ChancellorDirkswantsyoutoexplainhowarelationaldatabasemanagementsystem,
(e.g.Postgres)works.DirksisfamiliarwithreadingERdiagrams,sowe'vecreatedthe
diagrambelow,butitismissingafewedges.
Answerquestions2to5choosingthebestoptionfromthefollowingmultiplechoiceoptions:
A.partialparticipation,nonkey
B.partialparticipation,key
C.totalparticipation,nonkey
D.totalparticipation,key
E.noneoftheabove
2.[2point]WhatisthecorrectedgebetweenTableRowandTable?
Aatablehas0ormorerows
2
3.[2point]WhatisthecorrectedgebetweenTableColumnandTable?
Catablehas1ormorecolumns
4.[2point]WhatisthecorrectedgebetweenColumnandPrimaryKey?
BEachcolumnparticipatesinatmostoneprimarykey.Thereisatmostoneprimarykey,
theremaybenone,andevenifthereisonenoteverycolumnwillbeinit.
5.[2point]WhatisthecorrectedgebetweenTableandPrimaryKey?
AAtablemayhaveaprimarykeywith0columns(meaningitdoesn’thaveaprimarykey),1
column,ormanycolumns,sothetablecanparticipateinthePrimaryKeyrelationship0or
moretimes.
ERtoSQL
6.[6points]Onyouranswersheet,fillintheblankstoconverttheRowentityset,andthe
TableColumnrelationshipsetintheERdiagramaboveintoSQLtables.Youmaynotneed
alltheblanks.
CREATE TABLE Row (
rid INTEGER
PRIMARY KEY (rid)
);
CREATE TABLE TableColumn (
tname STRING,
cname STRING,
col_position INTEGER,
FOREIGN KEY (tname)
REFERENCES Table
FOREIGN KEY (cname)
REFERENCES Column
PRIMARY KEY (tname, cname)
);
3
Document Summary
You should receive a double-sided answer sheet and an 8-page exam. Mark your name and login on both sides of the answer sheet, and in the blanks above. For each question, place only your final answer on the answer sheet do not show work or formulas there. You may use the backs of the questions for scratch paper, but do not tear off any pages. We will ask you to turn in your question sheets as well as your answers. Create table tablecolumn ( tname string, cname string, col_position integer, [5 points] which of the following changes to the above schedule will result in a schedule that is possible using strict two phase locking? ( mark all that apply : make t1 abort instead of commit, make t2 abort instead of commit, remove r(a) from t1 and t3, remove t2 from the schedule, make t3 write to a page d instead of page b.