'# & ! 0) 3
(
) )
4
*) '
+ ,
-. / 1'
&
"
2
56786987669
!
!
! !
!# # #
! $
" ! " !
&
$!%
" ! $!%
! "
#
$ %
& '
(
CONS TRAI NT
) * ) CREA TE TABL E ALTE R TABL E
' &
ALTE R TABL E !
CONS TRAI NT !
'
+
,- ./01 . 2 /1 "0/34%35( 1 6(%5 -. (&&5 /%7%/% ,% 8 9 8 8 - ( *0.%,0 ,0*%5 %. (&&: 8 - *%&%.%,0 ,0*%5 %. (&&: <
: ;:
'
%
'
,/%0.%.0=&%7
9 17
+
1 .%>%/ ,-
'
./01 .,
/1 "0/34%3;
+
,- ./01 . 2 /1 "0/34%39 8 8 : : ;5 ( 1 6(%9 8 8 : : ;5 7-/%1 > 4%38 - 1 *%?:9 8 8 : : ; /%7%/% ,% 8 - ( *0.%,0 ,0*%5 %. (&&: 8 - *%&%.%,0 ,0*%5 %. (&&: <
8 9
8
0
8
: : ;:
+
0&.%/ .0=&%,
0** ,-
./01 .,
7
( 1 6(%9
,1 7;
0
$ % %
)
%
) '
@
%
!
%
)
!
% ) !
CONS TRAI NT+ UNIQ UE+
'
% '
! ' ' PRIM ARY KEY+ . '
'
,
PRIM ARY KEY
! FORE IGN KEY+
! ! ' !
! ! "
$
!" 6&+
#
!
"
0&.%/ .0=&%7
0** ,-
./01 .,
A7
7-/%1 > 4%39
,
; /%7%/% ,% ,
9 1,
FORE IGN KEY
0
!" #
#
0
;
!
"
!
)
( ' '
(
> ! ; ( ! & ' '
!
9
"
#
!
NULL 9
( &
;
!
&
) ( 9!
! ; 1 ! ;
" ! $
%
'
!
! # )
)
!
9 .
: ;
9 .
; !
;
17 $
%
#
& ' ,
(
) 0
CONS TRAI NT ) $
*
$ 9
!
! ;
)
) )
9
%!
& "
*
*
6&
# + CREA TE T ABLE
0 ,
ALTE R TA BLE
,
CREA TE I NDEX
,
! CREA TE TABL E
ALTE R TABL E
CREA TE INDE X
$ CONS TRAI NT % !
!
" !
CREA TE TABL E
) ALTE R TABL E
B
)
" "
!
!
0
#
" ! CONS TRAI NT; 9
! CREA TE TABL E (
CREA TE INDE X
!
CONS TRAI NT
' CREA TE TABL E
%
'
+
,/%0.%.0=&%, 9 1, 1 .%>%/ ,- ./01 .,1 .%?.9 CD; E1 .B ,-" -. (&&;
/1 "0/34%3
0
+
,/%0.%.0=&%, 9 .%?.9 CD; E1 .B ,-" 1, 1 .%>%/< ,- ./01 .1 , ( 1 6(%9
&
!
1,
;;
' CONS TRAI NT )
!
! CREA TE TABL E
" !
!
$ ! +
CONS TRAI NT
ALTE R TABL E
0&.%/ .0=&% 0** ,- ./01 . 2 /1 "0/34%39 8 8 : : ;5 ( 1 6(%9 8 8 : : ;5 7-/%1 > 4%39 8 8 : : ; /%7%/% ,%
8 9
%
8
!
0&.%/ .0=&%%
0** ,-
0
./01 .,
0** ,-
!
,
( 1 6(%9
'
7
0&.%/ .0=&%0 0** ,- ./01 . 0 7-/%1 > 4%39 7 ; /%7%/% ,% 7 - ( *0.%,0 ,0*% - *%&%.%,0 ,0*%
! (
;
'
./01 .
9 17
: : ;: <
+
/1 "0/34%39 1%
'
0&.%/ .0=&%0
8
0
+
;
9
;
0
9
!
;+
;
!# # # $!%
!
!+
,/%0.%8 ( 1 6(%:1 *%? 9 8 0 ,5 *% ,: 8 8 0 ,5 *% ,: : ; 8 E1 .B 2 /1 "0/35*1 0&&-E (&&51 > -/% (&&<:
% E1 .B
+
/1 "0/3 *1 0&&-E
(&&
1 > -/% (&&
!
&
9 E1 .B /1 "0/3 *1 0&&-E (&&1 > -/% (&&; ( 1 6(% *1 0&&-E (&& % *1 0&&-E
/1 "0/3 ' (&&
+
=
! ;
$
>
;
!
.
7
F
(&&
G
7
7
F
(&&
G
.
F
(&&
.
7
$ $ G
$
(&& 1 > -/%
E1 .B %
1,
,/%0.%1 *%? " A1
0 1,
- ,
9 1,
+
;
$
E1 .B
$
'
+
,/%0.%( 1 6(%1 *%? " A1
- ,
9 1,
; E1 .B *1 0&&-E
(&&
(
' !
6&
"
# ! +
, *
!
!
ALTE R TA BLE
)
!
" ! ALTE R TA BLE
0&.%/ .0=&%
)
*/- ,-
./01 .
!+
*
! 9
7 ;
#
)
+ +
H% 0&.%/ .0=&%0 H% 0&.%/ .0=&%,
! / INDE X
! */- ,-
*/- ,-
./01 .
0
./01 .,
$
&
$!% DROP
! ! +
*/- 1 *%?
*
-
)
0
+
0&.%/ .0=&%0
*/- ,-
%
0*6& ; +
1 0 0 6&0
,
%.
!
"
9
! !
;
) 9 0*-;
$
- *
I- * , I- * ,
H, E ) ,
,
%
!
JA K J" # -&%*= LDG KM A K * J,+N " N =O K 9 ; E )
) !0 %! " = ! ) I9 !" A K % ! KA " = != -4 " %!
= !1
%!
;
.
H, 6& 6&J K 0&.%/ .0=&%0
*/- ,-
./01 .7
0
K
. H, E ) , , , %! % E ) "
,
%
, J . ! J 6& . J, 6 9 ;
.
= ! ) I9 K ) K 0&.%/ .0=&%K " " = !1 1
.!
= != ;
) !0 %! " = ! ) I9 !" K % " = != -4 "
KA -4 A
A KA = !1 %!
;
.
H, 6& 6&J K 0&.%/ .0=&%0
*/- ,-
./01 .,
K
. H% , %! "
. ! J 6& 6 9 ;
= ! ) I9 K ) K 0&.%/ .0=&%K " " = !1 1
0 = != ;
-4 A
" &
.
%
0
!
*
* * *
./01 .
KA
! 9 *0-;+
9 6&
,
) !0 %! " = ! ) I9 !" K % " = != -4 "
%
A = !1
KA %!
;
.
H, 6& 6&J K */- 1 *%? ,
- 70,.(/0 K
. H% , %! "
,
. ! J 6& 6 9 ;
= ! ) I9 K ) K */- 1 *%?K " = != " = !1 1 ;
) !0 %! " = ! ) I9 !" K % " = != -4 "
%
7
KA
-4 A
A = !1
KA %!
;
.
H,
!
-
,
9 ;
+
'
? #
-
$ %66@5
-
$ %6AA5
-
$ %6A75
<
< $ % $ % $ %
!
(
)
*)
+ 1 7669
+ & !
)
B
)
(
! .)
I )
I
)
3
P