Figure 1: The er diagram for the terrorist database ... - ByteLABS
Figure 1: The er diagram for the terrorist database ... - ByteLABS
Figure 1: The er diagram for the terrorist database ... - ByteLABS
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
s<strong>er</strong>ial : char(20),<br />
primary key (date, location, s<strong>er</strong>ial),<br />
<strong>for</strong>eign key (date, location)<br />
ref<strong>er</strong>ences Crimes,<br />
<strong>for</strong>eign key (s<strong>er</strong>ial),<br />
ref<strong>er</strong>ences Weapons);<br />
create table Stolen (name : char(30), s<strong>er</strong>ial : char(20),<br />
date : char(20), location : char(30),<br />
primary key (name, s<strong>er</strong>ial),<br />
<strong>for</strong>eign key (name)<br />
ref<strong>er</strong>encesGroups,<br />
<strong>for</strong>eign key (s<strong>er</strong>ial)<br />
ref<strong>er</strong>ences Weapons);<br />
(c) <strong>The</strong> qu<strong>er</strong>y in tuple-relational calculus is:<br />
{P | T ∈ T<strong>er</strong>rorists ∧ W ∈ Wanted For∧<br />
U ∈ Used In ∧ V ∈ Weapons ∧<br />
T.name = W.name ∧<br />
W.date = U.date ∧ W.location = U.location ∧<br />
U.s<strong>er</strong>ial = V.s<strong>er</strong>ial ∧<br />
P.name = T.name ∧ P.type = V.type}<br />
2. (a) (i). <strong>The</strong> cosine between two vectors ⃗x and ⃗y is defined as:<br />
cos(⃗x, ⃗y) =<br />
⃗x · ⃗y<br />
|⃗x||⃗y| =<br />
∑ ni=1<br />
x i y i<br />
√ ∑ni=1<br />
x 2 √ ∑ni=1<br />
y 2 (1)<br />
(ii).<br />
cos(Q, D 1 ) =<br />
0 · 2 + 1 · 4 + 1 · 2 + 0 · 1 + 0 · 0<br />
√<br />
02 + 1 2 + 1 2 + 0 2 + 0 2√ 2 2 + 4 2 + 2 2 + 1 2 + 0 = 6<br />
2 5 √ 2 (2)<br />
cos(Q, D 2 ) =<br />
0 · 0 + 1 · 0 + 1 · 2 + 0 · 2 + 0 · 1<br />
√<br />
02 + 1 2 + 1 2 + 0 2 + 0 2√ 0 2 + 0 2 + 2 2 + 2 2 + 1 = √ 2 (3)<br />
2 2<br />
This means that D 1 is clos<strong>er</strong> to Q than D 2 and will be ranked high<strong>er</strong> by <strong>the</strong><br />
in<strong>for</strong>mation retrieval engine.<br />
(b) <strong>The</strong> basic patt<strong>er</strong>n <strong>for</strong> noun phrases is: DT? JJ* NN. Instead of det<strong>er</strong>min<strong>er</strong>s,<br />
we can have num<strong>er</strong>als, and instead of simple nouns, we can have compounds<br />
(such as Apogee common stock). This yields <strong>the</strong> following regular expression:<br />
(DT|CD)? JJ* (NN|JJ)* NN. If we allow pre-nominal det<strong>er</strong>min<strong>er</strong> phrases such<br />
as each of, we get: (DT IN)? (DT|CD)? JJ* (NN|JJ)* NN.<br />
In CQP notation (as required in <strong>the</strong> question), this regular expression is:<br />
([pos="DT"] [pos="IN"])? [pos="DT|CD"]? [pos="JJ"]*<br />
[pos="NN|JJ"]* [pos="NN"]<br />
ii