Professional Documents
Culture Documents
-
Division
By
Riham
ELSAADANY
2.
Enrollement
cid
sid
semester
336
101
S2015
336
102
S2015
550
101
S2012
550
102
S2013
Dpt
550
103
S2015
336 DB
CS
660
101
S2015
550 OS
CS
660
102
S2015
660 Network CS
770
101
S2015
770 Security
770
102
S2015
Cources
cid
cname
CS
cid Courses.
cid,sid Enrollement.
3. Then
we
divide
both
projec;ons:
the
division
will
simplify
the
values
of
the
colomns,
to
get
rid
of
the
sid
colomn
(common
eld):
The
result
will
get
us
only
the
sid
colomn
but
with
the
exact
values
that
are
enrolled
in
all
courses:
101,
102.
Division Concept
Get the en;re (all) Y colomn from table C, so we project on that Y column.
2.
yC
Get
X
(the
sid
we
want)
from
table
E,
but
to
relate
the
2
tables
C
and
E:
we
need
to
get
the
common
eld
Y
(cid)
,
which
will
happen
to
be
the
foreign
key
in
E
table,
along
with
X
(sid)
:
so
project
on
X,Y.
3.
x,yE
Divide
2./1.,
so
divide
both
projec;ons
of
XY/Y
=
X
(Y
is
simplied,
so
it
doesnt
appear
in
the
result,
and
X
values
that
have
associa;on
with
all
Y
is
what
we
end
up
with).
x,yE/ yC
Enrollement
gpa
101 Mike
M44
3.9
102 Suzan
Sxx9
3.8
103 Andy
Addd
3.7
cid
sid
semester
336
101
S2015
336
102
S2015
550
101
S2012
550
102
S2013
Courses
cid
cname
Dpt
550
103
S2015
336 DB
CS
660
101
S2015
550 OS
CS
660
102
S2015
660 Network CS
770
101
S2015
770 Security
770
102
S2015
CS
Final
Answer
So
well
select
all
the
results
from
the
division
and
put
them
into
Tmp
table:
the
selec;on
here
is
equivalent
to
select
*
without
a
condi;on,
which
gets
everything
from
the
result
(the
result
has
only
one
colomn
containing
2
values:
101,
102).
x,yE / yC) )
(Tmp, (
Then
well
associate
that
Tmp
to
Student
table:
so
we
join
both
tables
(remember:
join
will
omit
the
repe;;on
of
common
colomns,
that
will
get
us
all
columns
from
the
Students
table,
corresponding
to
sid
101
and
102).
But
we
only
need
sname
for
those
resul;ng
students:
so
we
project
on
that
colomn: