Tải bản đầy đủ (.doc) (4 trang)

Bài tập thực hành môn cơ sở dữ liệu

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (80.96 KB, 4 trang )


Mục tiêu:
 ! "#
A. CSDL ToyWorld
$ %&'()*''+'
!$ ,-#.!/!!$0!/!
1234#.!#56!
7*!
*,*&8!!9:::;<=>?0@AB?#.
@$C
#$ DEF#GH43!#56'()*''+'1!
!I!J:KIL4!!JL:K
ILMNN
IMC!OC
!J9:::;IILK
L$ P?-?!AQRS/!?!AQA1T1U#.
+!$ 6&..1TVO/!UAVQ
A1T!?!AQ#54R1TA1TA>!$ B
46%&%A-O&G-GAQR
W$ XSOG!J&&K!AY1T!?!AQZ
[!\&.A-!AY$F]^1!
M_!`'!$ B6%&%
a$ POGbSAc?b?AVQA?4ABd
A1TOe?b^T&ZOe?&.A1T%&%#5
67"(*412!&&)/!#.+!$ B
6Ae6A-G#1RS&!O6
7"(*0A1T6
• !AY12fg!&h<XN!<iN
• -0&^?b!&&'!Jh#.!&&K4
[/!?AVQA?F]!
Mj!&&'!


1
9$eck.#G<Xg&&!N!O12
30l!0l7&!!4#.&&
CREATE TRIGGER reminder1
ON Sales.Customer
AFTER INSERT, UPDATE
AS RAISERROR ('Notify Customer Relations', 16, 10);
;$Oe!Zm^E/!12!HO
dAnl!Fl?!AQR$XSm^EhnL:::o4[1RZ#c
pOFT&0lq/#r?!AQR4F#G12
!#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
;$4s4s+AeecF/!GAQ!
+
X
+

!
&&
X!
) 
X!

'!
_! !&&
&


$$
X123t!34sAeuD!-12+!
)_!$ Bv&123646%Tt
w$-6#.#tOx#.!
!!Op?!p?q%&%A-12
fg!&!/!#.1Q]#.
y$ B4s1!
2
'*(*z)*!zs
(
**&&)4{X!jCCj4!X!(#X!
{'+=&&
B)X*(+{)X*'4s4h!SAB?b
1RO34sAe%&OG!RZ12#X!
FA1T%&Ac!Cg8!|!8!C
B. CSDL Headhunt
1. P?}40u46Z~%&%u46J'!
!K4#.*&$ B6Ae6
A-46.A12b}6JK/!

#."
C. CSDL Pubs
$ P&GGAQ#G•R-#.RA1T%&4#.
!1T#G~A1T-V4128!/!
#.$ B6/!#.!
L$ BAenOF&€&pG#tOx#./!
#.!4&#
Bài tập làm thêm
Pe!A-/!G#.!?04G
#1R!
•#.08?G12!
012 PeU6 -^
8! ! X
+8) !J;K X
Xs8) !J;K X
•!
!&!8
&&g&!
!
!I!J;KIL!J;K
IM&&)g
3
ILM&&)g
84!J!JKILIK
•66!
&!&&
&&)M<((((((N
s&&)MN:::::N
•66!
`g8

X%p€‚‚
4

×