Mục tiêu:
! "#
A. CSDL ToyWorld
$ %&'()*''+'
!$ ,-#.!/!!$0!/!
1234#.!#56!
7*!
*,*&8!!9:::;<=>?0@AB?#.
@$C
#$ DEF#GH43!#56'()*''+'1!
!I!J:KIL4!!JL:K
ILMNN
IMC!OC
!J9:::;IILK
L$ P?-?!AQRS/!?!AQA1T1U#.
+!$ 6&..1TVO/!UAVQ
A1T!?!AQ#54R1TA1TA>!$ B
46%&%A-O&G-GAQR
W$ XSOG!J&&K!AY1T!?!AQZ
[!\&.A-!AY$F]^1!
M_!`'!$ B6%&%
a$ POGbSAc?b?AVQA?4ABd
A1TOe?b^T&ZOe?&.A1T%&%#5
67"(*412!&&)/!#.+!$ B
6Ae6A-G#1RS&!O6
7"(*0A1T6
• !AY12fg!&h<XN!<iN
• -0&^?b!&&'!Jh#.!&&K4
[/!?AVQA?F]!
Mj!&&'!
1
9$eck.#G<Xg&&!N!O12
30l!0l7&!!4#.&&
CREATE TRIGGER reminder1
ON Sales.Customer
AFTER INSERT, UPDATE
AS RAISERROR ('Notify Customer Relations', 16, 10);
;$Oe!Zm^E/!12!HO
dAnl!Fl?!AQR$XSm^EhnL:::o4[1RZ#c
pOFT&0lq/#r?!AQR4F#G12
!#S
CREATE TRIGGER invalidCredit ON dbo.Orders
AFTER INSERT
AS
DECLARE @creditYear int,@shopperName varchar(25)
SELECT @credityear = datepart(yy,s.dExpiryDate)
, @ShopperName = s.vFirstName+' '+vLastName
FROM dbo.Orders o JOIN inserted i ON o.cOrderNo = i.
cOrderNo
JOIN dbo.Shopper s on s.cShopperId =o.cShopperId
IF @credityear <=2000
BEGIN
RAISERROR ('The credit card of %s is expiry, this new
order is refused',10, 1, @shopperName)
ROLLBACK TRANSACTION
END
;$4s4s+AeecF/!GAQ!
+
X
+
!
&&
X!
)
X!
'!
_! !&&
&
$$
X123t!34sAeuD!-12+!
)_!$ Bv&123646%Tt
w$-6#.#tOx#.!
!!Op?!p?q%&%A-12
fg!&!/!#.1Q]#.
y$ B4s1!
2
'*(*z)*!zs
(
**&&)4{X!jCCj4!X!(#X!
{'+=&&
B)X*(+{)X*'4s4h!SAB?b
1RO34sAe%&OG!RZ12#X!
FA1T%&Ac!Cg8!|!8!C
B. CSDL Headhunt
1. P?}40u46Z~%&%u46J'!
!K4#.*&$ B6Ae6
A-46.A12b}6JK/!
#."
C. CSDL Pubs
$ P&GGAQ#G•R-#.RA1T%&4#.
!1T#G~A1T-V4128!/!
#.$ B6/!#.!
L$ BAenOF&€&pG#tOx#./!
#.!4&#
Bài tập làm thêm
Pe!A-/!G#.!?04G
#1R!
•#.08?G12!
012 PeU6 -^
8! ! X
+8) !J;K X
Xs8) !J;K X
•!
!&!8
&&g&!
!
!I!J;KIL!J;K
IM&&)g
3
ILM&&)g
84!J!JKILIK
•66!
&!&&
&&)M<((((((N
s&&)MN:::::N
•66!
`g8
X%p€‚‚
4