You are on page 1of 13

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

C S D Liu Quan H

Bi tp 1:
C s d liu qun l bn hng gm c cc quan h sau:
KHACHHANG (MAKH, HOTEN, DCHI, SODT, NGSINH, DOANHSO, NGDK)
Tn t: Quan h khch hng s lu tr thng tin ca khch hng thnh vin gm c cc thuc tnh:
m khch hng, h tn, a ch, s in thoi, ngy sinh, ngy ng k v doanh s (tng tr gi cc
ha n ca khch hng thnh vin ny).
NHANVIEN (MANV,HOTEN, NGVL, SODT)
Tn t: Mi nhn vin bn hng cn ghi nhn h tn, ngy vo lm, in thai lin lc, mi nhn vin
phn bit vi nhau bng m nhn vin.
SANPHAM (MASP,TENSP, DVT, NUOCSX, GIA)
Tn t: Mi sn phm c mt m s, mt tn gi, n v tnh, nc sn xut v mt gi bn.
HOADON (SOHD, NGHD, MAKH, MANV, TRIGIA)
Tn t: Khi mua hng, mi khch hng s nhn mt ha n tnh tin, trong s c s ha n,
ngy mua, nhn vin no bn hng, tr gi ca ha n l bao nhiu v m s ca khch hng nu l
khch hng thnh vin.
CTHD (SOHD,MASP,SL)
Tn t: Din gii chi tit trong mi ha n gm c nhng sn phm g vi s lng l bao nhiu.
(s th hin mi quan h gia cc bng)
NHANVIEN
MANV

HOTEN

DTHOAI

NGVL

NV01

Nguyen Nhu Nhut

0927345678

13/4/2006

NV02

Le Thi Phi Yen

0987567390

21/4/2006

NV03

Nguyen Van B

0997047382

27/4/2006

NV04

Ngo Thanh Tuan

0913758498

24/6/2006

NV05

Nguyen Thi Truc Thanh

0918590387

20/7/2006

KHACHHANG
MAKH

HOTEN

DCHI

SODT

NGSINH

DOANHSO

NGDK

KH01

Nguyen Van A

731 Tran Hung Dao, Q5, TpHCM

08823451

22/10/1960

13,060,000 22/07/2006

KH02

Tran Ngoc Han

23/5 Nguyen Trai, Q5, TpHCM

0908256478

3/4/1974

280,000 30/07/2006

KH03

Tran Ngoc Linh

45 Nguyen Canh Chan, Q1, TpHCM 0938776266

12/6/1980

3,860,000 05/08/2006

KH04

Tran Minh Long

50/34 Le Dai Hanh, Q10, TpHCM

0917325476

KH05

Le Nhat Minh

34 Truong Dinh, Q3, TpHCM

08246108

9/3/1965

250,000 02/10/2006

10/3/1950

21,000 28/10/2006

KH06

Le Hoai Thuong

227 Nguyen Van Cu, Q5, TpHCM

08631738

31/12/1981

915,000 24/11/2006

KH07

Nguyen Van Tam

32/3 Tran Binh Trong, Q5, TpHCM

0916783565

6/4/1971

12,500 01/12/2006

KH08

Phan Thi Thanh

45/2 An Duong Vuong, Q5, TpHCM

0938435756

10/1/1971

365,000 13/12/2006

KH09

Le Ha Vinh

873 Le Hong Phong, Q5, TpHCM

08654763

3/9/1979

70,000 14/01/2007

KH10

Ha Duy Lap

34/34B Nguyen Trai, Q1, TpHCM

08768904

2/5/1983

67,500 16/01/2007

Trang 1

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin


SANPHAM

C S D Liu Quan H
HOADON

MASP

TENSP

DVT

NUOCSX

GIA

SOHD

NGHD

MAKH MANV

TRIGIA

BC01

But chi

cay

Singapore

3,000

1001

23/07/2006 KH01

NV01

320,000

BC02

But chi

cay

Singapore

5,000

1002

12/08/2006 KH01

NV02

840,000

BC03

But chi

cay

Viet Nam

3,500

1003

23/08/2006 KH02

NV01

100,000

BC04

But chi

hop

Viet Nam

30,000

1004

01/09/2006 KH02

NV01

180,000

20/10/2006 KH01

NV02

3,800,000

BB01

But bi

cay

Viet Nam

5,000

1005

BB02

But bi

cay

Trung Quoc

7,000

1006

16/10/2006 KH01

NV03

2,430,000

BB03

But bi

hop

Thai Lan

100,000

1007

28/10/2006 KH03

NV03

510,000

TV01

Tap 100 giay mong

quyen

Trung Quoc

2,500

1008

28/10/2006 KH01

NV03

440,000

28/10/2006 KH03

NV04

200,000

TV02

Tap 200 giay mong

quyen

Trung Quoc

4,500

1009

TV03

Tap 100 giay tot

quyen

Viet Nam

3,000

1010

01/11/2006 KH01

NV01

5,200,000

TV04

Tap 200 giay tot

quyen

Viet Nam

5,500

1011

04/11/2006 KH04

NV03

250,000

TV05

Tap 100 trang

chuc

Viet Nam

23,000

1012

30/11/2006 KH05

NV03

21,000

TV06

Tap 200 trang

chuc

Viet Nam

53,000

1013

12/12/2006 KH06

NV01

5,000

31/12/2006 KH03

NV02

3,150,000

TV07

Tap 100 trang

chuc

Trung Quoc

34,000

1014

ST01

So tay 500 trang

quyen

Trung Quoc

40,000

1015

01/01/2007 KH06

NV01

910,000

ST02

So tay loai 1

quyen

Viet Nam

55,000

1016

01/01/2007 KH07

NV02

12,500

ST03

So tay loai 2

quyen

Viet Nam

51,000

1017

02/01/2007 KH08

NV03

35,000

13/01/2007 KH08

NV03

330,000

ST04

So tay

quyen

Thai Lan

55,000

1018

ST05

So tay mong

quyen

Thai Lan

20,000

1019

13/01/2007 KH01

NV03

30,000

ST06

Phan viet bang

hop

Viet Nam

5,000

1020

14/01/2007 KH09

NV04

70,000

ST07

Phan khong bui

hop

Viet Nam

7,000

1021

16/01/2007 KH10

NV03

67,500

ST08

Bong bang

cai

Viet Nam

1,000

1022

16/01/2007 Null

NV03

7,000

ST09

But long

cay

Viet Nam

5,000

1023

17/01/2007 Null

NV01

330,000

ST10

But long

cay

Trung Quoc

7,000

SL

CTHD
SOHD

MASP

1001
1001
1001
1001
1001
1002
1002
1002
1003
1004
1004
1004
1004
1005
1005

TV02
ST01
BC01
BC02
ST08
BC04
BB01
BB02
BB03
TV01
TV02
TV03
TV04
TV05
TV06

1006

TV07

CTHD
SL

SOHD

MASP

10
5
5
10
10
20
20
20
10
20
10
10
10
50
50

1006
1006
1007
1008
1009
1010
1010
1010
1010
1010
1011
1012
1013
1014
1014

ST01
ST02
ST03
ST04
ST05
TV07
ST07
ST08
ST04
TV03
ST06
ST07
ST08
BC02
BB02

20

1014

BC04

CTHD
SL

SOHD

MASP

30
10
10
8
10
50
50
100
50
100
50
3
5
80
100

1014
1015
1015
1016
1017
1017
1017
1018
1019
1019
1020
1021
1021
1021
1022

BB01
BB02
BB03
TV01
TV02
TV03
TV04
ST04
ST05
ST06
ST07
ST08
TV01
TV02
ST07

60

1023

ST04

50
30
7
5
1
1
5
6
1
2
10
5
7
10
1
6

Trang 2

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

C S D Liu Quan H

BNG THUC TNH


Quan h

Thuc tnh

Din gii

Kiu d liu

MAKH
HOTEN
DCHI
SODT
NGSINH
NGDK
DOANHSO

M khch hng
H tn
a ch
S in thai
Ngy sinh
Ngy ng k thnh vin
Tng tr gi cc ha n khch hng mua

char(4)
varchar(40)
varchar(50)
varchar(20)
smalldatetime
smalldatetime
money

NHANVIEN

MANV
HOTEN
SODT
NGVL

M nhn vin
H tn
S in thoi
Ngy vo lm

char(4)
varchar(40)
varchar(20)
smalldatetime

SANPHAM

MASP
TENSP
DVT
NUOCSX
GIA

M sn phm
Tn sn phm
n v tnh
Nc sn xut
Gi bn

char(4)
varchar(40)
varchar(20)
varchar(40)
money

HOADON

SOHD
NGHD
MAKH
MANV
TRIGIA

S ha n
Ngy mua hng
M khch hng no mua
Nhn vin bn hng
Tr gi ha n

int
smalldatetime
char(4)
char(4)
money

CTHD

SOHD
MASP
SL

S ha n
M sn phm
S lng

int
char(4)
int

KHACHHANG

I. Ngn ng nh ngha d liu (Data Definition Language):


1.

To cc quan h v khai bo cc kha chnh, kha ngoi ca quan h.

2.

Thm vo thuc tnh GHICHU c kiu d liu varchar(20) cho quan h SANPHAM.

3.

Thm vo thuc tnh LOAIKH c kiu d liu l tinyint cho quan h KHACHHANG.

4.

Sa kiu d liu ca thuc tnh GHICHU trong quan h SANPHAM thnh varchar(100).

5.

Xa thuc tnh GHICHU trong quan h SANPHAM.

6.

Lm th no thuc tnh LOAIKH trong quan h KHACHHANG c th lu cc gi tr l: Vang


lai, Thuong xuyen, Vip,

7.

n v tnh ca sn phm ch c th l (cay,hop,cai,quyen,chuc)

8.

Gi bn ca sn phm t 500 ng tr ln.

9.

Mi ln mua hng, khch hng phi mua t nht 1 sn phm.

10.

Ngy khch hng ng k l khch hng thnh vin phi ln hn ngy sinh ca ngi .
Trang 3

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

11.

C S D Liu Quan H
Ngy mua hng (NGHD) ca mt khch hng thnh vin s ln hn hoc bng ngy khch hng
ng k thnh vin (NGDK).

12.

Ngy bn hng (NGHD) ca mt nhn vin phi ln hn hoc bng ngy nhn vin vo lm.

13.

Mi mt ha n phi c t nht mt chi tit ha n.

14.

Tr gi ca mt ha n l tng thnh tin (s lng*n gi) ca cc chi tit thuc ha n .

15.

Doanh s ca mt khch hng l tng tr gi cc ha n m khch hng thnh vin mua.

II. Ngn ng thao tc d liu (Data Manipulation Language):


1.

Nhp d liu cho cc quan h trn.

2.

To quan h SANPHAM1 cha ton b d liu ca quan h SANPHAM. To quan h


KHACHHANG1 cha ton b d liu ca quan h KHACHHANG.

3.

Cp nht gi tng 5% i vi nhng sn phm do Thai Lan sn xut (cho quan h SANPHAM1)

4.

Cp nht gi gim 5% i vi nhng sn phm do Trung Quoc sn xut c gi t 10.000 tr xung


(cho quan h SANPHAM1).

5.

Cp nht gi tr LOAIKH l Vip i vi nhng khch hng ng k thnh vin trc ngy
1/1/2007 c doanh s t 10.000.000 tr ln hoc khch hng ng k thnh vin t 1/1/2007 tr v
sau c doanh s t 2.000.000 tr ln (cho quan h KHACHHANG1).

III. Ngn ng truy vn d liu c cu trc:


1.

In ra danh sch cc sn phm (MASP,TENSP) do Trung Quoc sn xut.

2.

In ra danh sch cc sn phm (MASP, TENSP) c n v tnh l cay, quyen.

3.

In ra danh sch cc sn phm (MASP,TENSP) c m sn phm bt u l B v kt thc l 01.

4.

In ra danh sch cc sn phm (MASP,TENSP) do Trung Quc sn xut c gi t 30.000 n


40.000.

5.

In ra danh sch cc sn phm (MASP,TENSP) do Trung Quoc hoc Thai Lan sn xut c gi t
30.000 n 40.000.

6.

In ra cc s ha n, tr gi ha n bn ra trong ngy 1/1/2007 v ngy 2/1/2007.

7.

In ra cc s ha n, tr gi ha n trong thng 1/2007, sp xp theo ngy (tng dn) v tr gi ca


ha n (gim dn).

8.

In ra danh sch cc khch hng (MAKH, HOTEN) mua hng trong ngy 1/1/2007.

9.

In ra s ha n, tr gi cc ha n do nhn vin c tn Nguyen Van B lp trong ngy


28/10/2006.

10.

In ra danh sch cc sn phm (MASP,TENSP) c khch hng c tn Nguyen Van A mua trong
thng 10/2006.

11.

Tm cc s ha n mua sn phm c m s BB01 hoc BB02.

12.

Tm cc s ha n mua sn phm c m s BB01 hoc BB02, mi sn phm mua vi s


lng t 10 n 20.

13.

Tm cc s ha n mua cng lc 2 sn phm c m s BB01 v BB02, mi sn phm mua vi


s lng t 10 n 20.
Trang 4

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

14.

C S D Liu Quan H
In ra danh sch cc sn phm (MASP,TENSP) do Trung Quoc sn xut hoc cc sn phm c
bn ra trong ngy 1/1/2007.

15.

In ra danh sch cc sn phm (MASP,TENSP) khng bn c.

16.

In ra danh sch cc sn phm (MASP,TENSP) khng bn c trong nm 2006.

17.

In ra danh sch cc sn phm (MASP,TENSP) do Trung Quoc sn xut khng bn c trong


nm 2006.

18.

Tm s ha n mua tt c cc sn phm do Singapore sn xut.

19.

Tm s ha n trong nm 2006 mua t nht tt c cc sn phm do Singapore sn xut.

20.

C bao nhiu ha n khng phi ca khch hng ng k thnh vin mua?

21.

C bao nhiu sn phm khc nhau c bn ra trong nm 2006.

22.

Cho bit tr gi ha n cao nht, thp nht l bao nhiu ?

23.

Tr gi trung bnh ca tt c cc ha n c bn ra trong nm 2006 l bao nhiu?

24.

Tnh doanh thu bn hng trong nm 2006.

25.

Tm s ha n c tr gi cao nht trong nm 2006.

26.

Tm h tn khch hng mua ha n c tr gi cao nht trong nm 2006.

27. In ra danh sch 3 khch hng (MAKH, HOTEN) c doanh s cao nht.
28.

In ra danh sch cc sn phm (MASP, TENSP) c gi bn bng 1 trong 3 mc gi cao nht.

29.

In ra danh sch cc sn phm (MASP, TENSP) do Thai Lan sn xut c gi bng 1 trong 3 mc
gi cao nht (ca tt c cc sn phm).

30.

In ra danh sch cc sn phm (MASP, TENSP) do Trung Quoc sn xut c gi bng 1 trong 3 mc
gi cao nht (ca sn phm do Trung Quoc sn xut).

31.

* In ra danh sch 3 khch hng c doanh s cao nht (sp xp theo kiu xp hng).

32.

Tnh tng s sn phm do Trung Quoc sn xut.

33.

Tnh tng s sn phm ca tng nc sn xut.

34.

Vi tng nc sn xut, tm gi bn cao nht, thp nht, trung bnh ca cc sn phm.

35.

Tnh doanh thu bn hng mi ngy.

36.

Tnh tng s lng ca tng sn phm bn ra trong thng 10/2006.

37.

Tnh doanh thu bn hng ca tng thng trong nm 2006.

38.

Tm ha n c mua t nht 4 sn phm khc nhau.

39.

Tm ha n c mua 3 sn phm do Viet Nam sn xut (3 sn phm khc nhau).

40.

Tm khch hng (MAKH, HOTEN) c s ln mua hng nhiu nht.

41.

Thng my trong nm 2006, doanh s bn hng cao nht ?

42.

Tm sn phm (MASP, TENSP) c tng s lng bn ra thp nht trong nm 2006.

43.

*Mi nc sn xut, tm sn phm (MASP,TENSP) c gi bn cao nht.

44.

Tm nc sn xut sn xut t nht 3 sn phm c gi bn khc nhau.

45.

*Trong 10 khch hng c doanh s cao nht, tm khch hng c s ln mua hng nhiu nht.
Trang 5

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

C S D Liu Quan H

Bi tp 2:
Cho c s d liu qun l gio v gm c nhng quan h sau:
HOCVIEN (MAHV, HO, TEN, NGSINH, GIOITINH, NOISINH, MALOP)
Tn t: mi hc vin phn bit vi nhau bng m hc vin, lu tr h tn, ngy sinh, gii tnh, ni
sinh, thuc lp no.
LOP (MALOP, TENLOP, TRGLOP, SISO, MAGVCN)
Tn t: mi lp gm c m lp, tn lp, hc vin lm lp trng ca lp, s s lp v gio vin ch
nhim.
KHOA (MAKHOA, TENKHOA, NGTLAP, TRGKHOA)
Tn t: mi khoa cn lu tr m khoa, tn khoa, ngy thnh lp khoa v trng khoa (cng l mt
gio vin thuc khoa).
MONHOC (MAMH, TENMH, TCLT, TCTH, MAKHOA)
Tn t: mi mn hc cn lu tr tn mn hc, s tn ch l thuyt, s tn ch thc hnh v khoa no
ph trch.
DIEUKIEN (MAMH, MAMH_TRUOC)
Tn t: c nhng mn hc hc vin phi c kin thc t mt s mn hc trc.
GIAOVIEN (MAGV, HOTEN,
MUCLUONG, MAKHOA)

HOCVI,HOCHAM,GIOITINH,

NGSINH,

NGVL,HESO,

Tn t: m gio vin phn bit gia cc gio vin, cn lu tr h tn, hc v, hc hm, gii tnh,
ngy sinh, ngy vo lm, h s, mc lng v thuc mt khoa.
GIANGDAY (MALOP, MAMH, MAGV, HOCKY, NAM, TUNGAY, DENNGAY)
Tn t: mi hc k ca nm hc s phn cng ging dy lp no hc mn g, gio vin no ph trch.
KETQUATHI (MAHV, MAMH, LANTHI, NGTHI, DIEM, KQUA)
Tn t: lu tr kt qu thi ca hc vin: hc vin no thi mn hc g, ln thi th my, ngy thi l ngy
no, im thi bao nhiu v kt qu l t hay khng t.
KHOA
MAKHOA

TENKHOA

KHMT

Khoa hoc may tinh

7/6/2005 GV01

HTTT

He thong thong tin

7/6/2005 GV02

CNPM

Cong nghe phan mem

7/6/2005 GV04

MTT

Mang va truyen thong

20/10/2005 GV03
20/12/2005 Null

KTMT

Ky thuat may tinh

NGTLAP

TRGKHOA
LOP
MALOP

TENLOP

TRGLOP SISO

MAGVCN

K11

Lop 1 khoa 1

K1108

11 GV07

K12

Lop 2 khoa 1

K1205

12 GV09

K13

Lop 3 khoa 1

K1305

12 GV14

Trang 6

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

C S D Liu Quan H
GIANGDAY

MONHOC
MAMH

TENMH

TCLT TCTH MAKHOA

THDC

Tin hoc dai cuong

1 KHMT

CTRR

Cau truc roi rac

0 KHMT

CSDL

Co so du lieu

1 HTTT

CTDLGT

Cau truc du lieu va giai thuat

1 KHMT

PTTKTT

Phan tich thiet ke thuat toan

0 KHMT

DHMT

Do hoa may tinh

1 KHMT

KTMT

Kien truc may tinh

0 KTMT

TKCSDL

Thiet ke co so du lieu

1 HTTT

PTTKHTTT Phan tich thiet ke he thong thong tin

1 HTTT

HDH

He dieu hanh

0 KTMT

NMCNPM

Nhap mon cong nghe phan mem

0 CNPM

LTCFW

Lap trinh C for win

1 CNPM

LTHDT

Lap trinh huong doi tuong

1 CNPM

MALOP

MAMH

MAGV

K11
K12
K13
K11
K12
K13
K11
K12
K13
K13
K13
K11
K12
K11
K12
K11

THDC
THDC
THDC
CTRR
CTRR
CTRR
CSDL
CSDL
CTDLGT
CSDL
DHMT
CTDLGT
CTDLGT
HDH
HDH
DHMT

GV07
GV06
GV15
GV02
GV02
GV08
GV05
GV09
GV15
GV05
GV07
GV15
GV15
GV04
GV04
GV07

HOCKY

NAM

1
1
1
1
1
1
2
2
2
3
3
3
3
1
1
1

TUNGAY

2006
2006
2006
2006
2006
2006
2006
2006
2006
2006
2006
2006
2006
2007
2007
2007

2/1/2006
2/1/2006
2/1/2006
9/1/2006
9/1/2006
9/1/2006
1/6/2006
1/6/2006
1/6/2006
1/8/2006
1/8/2006
1/8/2006
1/8/2006
2/1/2007
2/1/2007
18/2/2007

DENNGAY

12/5/2006
12/5/2006
12/5/2006
17/5/2006
17/5/2006
17/5/2006
15/7/2006
15/7/2006
15/7/2006
15/12/2006
15/12/2006
15/12/2006
15/12/2006
18/2/2007
20/3/2007
20/3/2007

GIAOVIEN
MAGV

HOTEN

HOCVI

HOCHAM

GIOITINH

NGSINH

GV01
GV02
GV03
GV04
GV05
GV06
GV07
GV08
GV09
GV10
GV11
GV12
GV13
GV14
GV15

Ho Thanh Son
Tran Tam Thanh
Do Nghiem Phung
Tran Nam Son
Mai Thanh Danh
Tran Doan Hung
Nguyen Minh Tien
Le Thi Tran
Nguyen To Lan
Le Tran Anh Loan
Ho Thanh Tung
Tran Van Anh
Nguyen Linh Dan
Truong Minh Chau
Le Ha Thanh

PTS
TS
TS
TS
ThS
TS
ThS
KS
ThS
KS
CN
CN
CN
ThS
ThS

GS
PGS
GS
PGS
GV
GV
GV
Null
GV
Null
GV
Null
Null
GV
GV

Nam
Nam
Nu
Nam
Nam
Nam
Nam
Nu
Nu
Nu
Nam
Nu
Nu
Nu
Nam

2/5/1950
17/12/1965
1/8/1950
22/2/1961
12/3/1958
11/3/1953
23/11/1971
26/3/1974
31/12/1966
17/7/1972
12/1/1980
29/3/1981
23/5/1980
30/11/1976
4/5/1978

NGVL

11/1/2004
20/4/2004
23/9/2004
12/1/2005
12/1/2005
12/1/2005
1/3/2005
1/3/2005
1/3/2005
1/3/2005
15/5/2005
15/5/2005
15/5/2005
15/5/2005
15/5/2005

HESO

5.00
4.50
4.00
4.50
3.00
4.50
4.00
1.69
4.00
1.86
2.67
1.69
1.69
3.00
3.00

MUCLUONG

2,250,000
2,025,000
1,800,000
2,025,000
1,350,000
2,025,000
1,800,000
760,500
1,800,000
837,000
1,201,500
760,500
760,500
1,350,000
1,350,000

MAKHOA

KHMT
HTTT
CNPM
KTMT
HTTT
KHMT
KHMT
KHMT
HTTT
CNPM
MTT
CNPM
KTMT
MTT
KHMT

DIEUKIEN
MAMH

MAMH_TRUOC

CSDL

CTRR

CSDL

CTDLGT

CTDLGT

THDC

PTTKTT

THDC

PTTKTT

CTDLGT

DHMT

THDC

LTHDT

THDC

PTTKHTTT

CSDL

Trang 7

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin


KETQUATHI
MAHV

MAMH

C S D Liu Quan H
KETQUATHI

LT

NGTHI

DIEM

KQUA

MAHV

MAMH

LT

NGTHI

DIEM

KQUA

K1101 CSDL

20/7/2006

10.00 Dat

K1202

CTRR

20/5/2006

4.00 Khong Dat

K1101 CTDLGT

28/12/2006

9.00 Dat

K1202

CTRR

30/6/2006

6.25 Dat

K1101 THDC

20/5/2006

9.00 Dat

K1203

CSDL

20/7/2006

9.25 Dat

K1101 CTRR

13/5/2006

9.50 Dat

K1203

CTDLGT

28/12/2006

9.50 Dat

K1102 CSDL

20/7/2006

4.00 Khong Dat

K1203

THDC

20/5/2006

10.00 Dat

K1102 CSDL

27/7/2006

4.25 Khong Dat

K1203

CTRR

13/5/2006

10.00 Dat

K1102 CSDL

10/8/2006

4.50 Khong Dat

K1204

CSDL

20/7/2006

8.50 Dat

K1102 CTDLGT

28/12/2006

4.50 Khong Dat

K1204

CTDLGT

28/12/2006

6.75 Dat

K1102 CTDLGT

5/1/2007

4.00 Khong Dat

K1204

THDC

20/5/2006

4.00 Khong Dat

K1102 CTDLGT

15/1/2007

6.00 Dat

K1204

CTRR

13/5/2006

6.00 Dat

K1102 THDC

20/5/2006

5.00 Dat

K1301

CSDL

20/12/2006

K1102 CTRR

13/5/2006

7.00 Dat

K1301

CTDLGT

25/7/2006

8.00 Dat

K1103 CSDL

20/7/2006

3.50 Khong Dat

K1301

THDC

20/5/2006

7.75 Dat

K1103 CSDL

27/7/2006

8.25 Dat

K1301

CTRR

13/5/2006

8.00 Dat

K1103 CTDLGT

28/12/2006

7.00 Dat

K1302

CSDL

20/12/2006

6.75 Dat

K1103 THDC

20/5/2006

8.00 Dat

K1302

CTDLGT

25/7/2006

5.00 Dat

K1103 CTRR

13/5/2006

6.50 Dat

K1302

THDC

20/5/2006

8.00 Dat

K1104 CSDL

20/7/2006

3.75 Khong Dat

K1302

CTRR

13/5/2006

8.50 Dat

K1104 CTDLGT

28/12/2006

4.00 Khong Dat

K1303

CSDL

20/12/2006

4.00 Khong Dat

K1104 THDC

20/5/2006

4.00 Khong Dat

K1303

CTDLGT

25/7/2006

4.50 Khong Dat

K1104 CTRR

13/5/2006

4.00 Khong Dat

K1303

CTDLGT

7/8/2006

4.00 Khong Dat

K1104 CTRR

20/5/2006

3.50 Khong Dat

K1303

CTDLGT

15/8/2006

4.25 Khong Dat

K1104 CTRR

30/6/2006

4.00 Khong Dat

K1303

THDC

20/5/2006

4.50 Khong Dat

K1201 CSDL

20/7/2006

6.00 Dat

K1303

CTRR

13/5/2006

3.25 Khong Dat

K1201 CTDLGT

28/12/2006

5.00 Dat

K1303

CTRR

20/5/2006

5.00 Dat

K1201 THDC

20/5/2006

8.50 Dat

K1304

CSDL

20/12/2006

7.75 Dat

K1201 CTRR

13/5/2006

9.00 Dat

K1304

CTDLGT

25/7/2006

9.75 Dat

K1202 CSDL

20/7/2006

8.00 Dat

K1304

THDC

20/5/2006

5.50 Dat

K1202 CTDLGT

28/12/2006

4.00 Khong Dat

K1304

CTRR

13/5/2006

5.00 Dat

K1202 CTDLGT

5/1/2007

5.00 Dat

K1305

CSDL

20/12/2006

9.25 Dat

K1202 THDC

20/5/2006

4.00 Khong Dat

K1305

CTDLGT

25/7/2006

10.00 Dat

K1202 THDC

27/5/2006

4.00 Khong Dat

K1305

THDC

20/5/2006

8.00 Dat

K1202 CTRR

13/5/2006

3.00 Khong Dat

K1305

CTRR

13/5/2006

10.00 Dat

4.25 Khong Dat

Trang 8

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

C S D Liu Quan H

HOCVIEN
MAHV

HO

TEN

K1101

Nguyen Van

K1102

Tran Ngoc

K1103

NGSINH

GIOITINH

NOISINH

MALOP

27/1/1986

Nam

TpHCM

K11

Han

14/3/1986

Nu

Kien Giang

K11

Ha Duy

Lap

18/4/1986

Nam

Nghe An

K11

K1104

Tran Ngoc

Linh

30/3/1986

Nu

Tay Ninh

K11

K1105

Tran Minh

Long

27/2/1986

Nam

TpHCM

K11

K1106

Le Nhat

Minh

24/1/1986

Nam

TpHCM

K11

K1107

Nguyen Nhu

Nhut

27/1/1986

Nam

Ha Noi

K11

K1108

Nguyen Manh

Tam

27/2/1986

Nam

Kien Giang

K11

K1109

Phan Thi Thanh

Tam

27/1/1986

Nu

Vinh Long

K11

K1110

Le Hoai

Thuong

5/2/1986

Nu

Can Tho

K11

K1111

Le Ha

Vinh

25/12/1986

Nam

Vinh Long

K11

K1201

Nguyen Van

11/2/1986

Nam

TpHCM

K12

K1202

Nguyen Thi Kim

Duyen

18/1/1986

Nu

TpHCM

K12

K1203

Tran Thi Kim

Duyen

17/9/1986

Nu

TpHCM

K12

K1204

Truong My

Hanh

19/5/1986

Nu

Dong Nai

K12

K1205

Nguyen Thanh

Nam

17/4/1986

Nam

TpHCM

K12

K1206

Nguyen Thi Truc

Thanh

4/3/1986

Nu

Kien Giang

K12

K1207

Tran Thi Bich

Thuy

8/2/1986

Nu

Nghe An

K12

K1208

Huynh Thi Kim

Trieu

8/4/1986

Nu

Tay Ninh

K12

K1209

Pham Thanh

Trieu

23/2/1986

Nam

TpHCM

K12

K1210

Ngo Thanh

Tuan

14/2/1986

Nam

TpHCM

K12

K1211

Do Thi

Xuan

9/3/1986

Nu

Ha Noi

K12

K1212

Le Thi Phi

Yen

12/3/1986

Nu

TpHCM

K12

K1301

Nguyen Thi Kim

Cuc

9/6/1986

Nu

Kien Giang

K13

K1302

Truong Thi My

Hien

18/3/1986

Nu

Nghe An

K13

K1303

Le Duc

Hien

21/3/1986

Nam

Tay Ninh

K13

K1304

Le Quang

Hien

18/4/1986

Nam

TpHCM

K13

K1305

Le Thi

Huong

27/3/1986

Nu

TpHCM

K13

K1306

Nguyen Thai

Huu

30/3/1986

Nam

Ha Noi

K13

K1307

Tran Minh

Man

28/5/1986

Nam

TpHCM

K13

K1308

Nguyen Hieu

Nghia

8/4/1986

Nam

Kien Giang

K13

K1309

Nguyen Trung

Nghia

18/1/1987

Nam

Nghe An

K13

K1310

Tran Thi Hong

Tham

22/4/1986

Nu

Tay Ninh

K13

K1311

Tran Minh

Thuc

4/4/1986

Nam

TpHCM

K13

K1312

Nguyen Thi Kim

Yen

7/9/1986

Nu

TpHCM

K13

Trang 9

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

C S D Liu Quan H

BNG THUC TNH


Quan h
KHOA

MONHOC

DIEUKIEN

GIAOVIEN

LOP

HOCVIEN

GIANGDAY

KETQUATHI

Thuc tnh

Din gii

Kiu d liu

MAKHOA

M khoa (kha chnh)

varchar(4)

TENKHOA

Tn khoa

varchar(40)

NGTLAP

Ngy thnh lp khoa

smalldatetime

TRGKHOA

Trng khoa (m gio vin)

char(4)

MAMH

M mn hc (kha chnh)

varchar(10)

TENMH

Tn mn hc

varchar(40)

TCLT

S tn ch l thuyt

tinyint

TCTH

S tn ch thc hnh

tinyint

MAKHOA

Mn hc thuc khoa no

varchar(4)

MAMH

M mn hc (thuc tnh kha)

varchar(10)

MAMH_TRUOC

M mn hc phi hc trc (thuc tnh kha)

varchar(10)

MAGV

M gio vin (kha chnh)

char(4)

HOTEN

H tn

varchar(40)

HOCVI, HOCHAM

Hc v, hc hm

varchar(10)

GIOITINH

Gii tnh

varchar(3)

NGSINH, NGVL

Ngy sinh, ngy vo lm vic

smalldatetime

HESO

H s lng

numeric(4,2)

MUCLUONG

Mc lng

money

MAKHOA

Thuc khoa no

varchar(4)

MALOP

M lp (kha chnh)

char(3)

TENLOP

Tn lp

varchar(40)

TRGLOP

Lp trng (m hc vin)

char(5)

SISO

S s lp

tinyint

MAGVCN

M gio vin ch nhim

char(4)

MAHV

M hc vin (kha chnh)

char(5)

HO

H v tn lt

varchar(40)

TEN

Tn

varchar(10)

NGSINH

Ngy sinh

smalldatetime

GIOITINH

Gii tnh

varchar(3)

NOISINH

Ni sinh

varchar(40)

MALOP

M lp

char(3)

MALOP

M lp (thuc tnh kha)

char(3)

MAMH

M mn hc (thuc tnh kha)

varchar(10)

MAGV

M gio vin

char(4)

HOCKY

Hc k

tinyint

NAM

Nm hc

smallint

TUNGAY, DENNGAY

Ngy bt u v ngy kt thc mn hc

smalldatetime

MAHV

M hc vin (thuc tnh kha)

char(5)

MAMH

M mn hc (thuc tnh kha)

varchar(10)

LANTHI

Ln thi (thuc tnh kha)

tinyint

NGTHI

Ngy thi

smalldatetime

DIEM

im thi

numeric(4,2)

KQUA

Kt qu thi

varchar(10)

Trang 10

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

C S D Liu Quan H

I. Ngn ng nh ngha d liu (Data Definition Language):


1.

To quan h v khai bo tt c cc rng buc kha chnh, kha ngoi. Thm vo 3 thuc tnh
GHICHU, DIEMTB, XEPLOAI cho quan h HOCVIEN.

2.

M hc vin l mt chui 5 k t, 3 k t u l m lp, 2 k t cui cng l s th t hc


vin trong lp. VD: K1101

3.

Thuc tnh GIOITINH ch c gi tr l Nam hoc Nu.

4.

im s ca mt ln thi c gi tr t 0 n 10 v cn lu n 2 s l (VD: 6.22).

5.

Kt qu thi l Dat nu im t 5 n 10 v Khong dat nu im nh hn 5.

6.

Hc vin thi mt mn ti a 3 ln.

7.

Hc k ch c gi tr t 1 n 3.

8.

Hc v ca gio vin ch c th l CN, KS, Ths, TS, PTS.

9.

Lp trng ca mt lp phi l hc vin ca lp .

10. Trng khoa phi l gio vin thuc khoa v c hc v TS hoc PTS.
11. Hc vin t nht l 18 tui.
12. Ging dy mt mn hc ngy bt u (TUNGAY) phi nh hn ngy kt thc
(DENNGAY).
13. Gio vin khi vo lm t nht l 22 tui.
14. Tt c cc mn hc u c s tn ch l thuyt v tn ch thc hnh chnh lch nhau khng
qu 3.
15. Hc vin ch c thi mt mn hc no khi lp ca hc vin hc xong mn hc ny.
16. Mi hc k ca mt nm hc, mt lp ch c hc ti a 3 mn.
17. S s ca mt lp bng vi s lng hc vin thuc lp .
18. Trong quan h DIEUKIEN gi tr ca thuc tnh MAMH v MAMH_TRUOC trong cng
mt b khng c ging nhau (A,A) v cng khng tn ti hai b (A,B) v
(B,A).
19. Cc gio vin c cng hc v, hc hm, h s lng th mc lng bng nhau.
20. Hc vin ch c thi li (ln thi >1) khi im ca ln thi trc di 5.
21. Ngy thi ca ln thi sau phi ln hn ngy thi ca ln thi trc (cng hc vin, cng mn
hc).
22. Hc vin ch c thi nhng mn m lp ca hc vin hc xong.
23. Khi phn cng ging dy mt mn hc, phi xt n th t trc sau gia cc mn hc (sau
khi hc xong nhng mn hc phi hc trc mi c hc nhng mn lin sau).
24. Gio vin ch c phn cng dy nhng mn thuc khoa gio vin ph trch.

Trang 11

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

C S D Liu Quan H

II. Ngn ng thao tc d liu (Data Manipulation Language):


1.

Tng h s lng thm 0.2 cho nhng gio vin l trng khoa.

2.

Cp nht gi tr im trung bnh tt c cc mn hc (DIEMTB) ca mi hc vin (tt c cc


mn hc u c h s 1 v nu hc vin thi mt mn nhiu ln, ch ly im ca ln thi sau
cng).

3.

Cp nht gi tr cho ct GHICHU l Cam thi i vi trng hp: hc vin c mt mn bt


k thi ln th 3 di 5 im.

4.

Cp nht gi tr cho ct XEPLOAI trong quan h HOCVIEN nh sau:


o Nu DIEMTB 9 th XEPLOAI =XS
o Nu 8 DIEMTB < 9 th XEPLOAI = G
o Nu 6.5 DIEMTB < 8 th XEPLOAI = K
o Nu 5 DIEMTB < 6.5 th XEPLOAI = TB
o Nu DIEMTB < 5 th XEPLOAI = Y

III. Ngn ng truy vn d liu:


1.

In ra danh sch (m hc vin, h tn, ngy sinh, m lp) lp trng ca cc lp.

2.

In ra bng im khi thi (m hc vin, h tn , ln thi, im s) mn CTRR ca lp K12,


sp xp theo tn, h hc vin.

3.

In ra danh sch nhng hc vin (m hc vin, h tn) v nhng mn hc m hc vin thi


ln th nht t.

4.

In ra danh sch hc vin (m hc vin, h tn) ca lp K11 thi mn CTRR khng t (


ln thi 1).

5.

* Danh sch hc vin (m hc vin, h tn) ca lp K thi mn CTRR khng t ( tt c


cc ln thi).

6.

Tm tn nhng mn hc m gio vin c tn Tran Tam Thanh dy trong hc k 1 nm


2006.

7.

Tm nhng mn hc (m mn hc, tn mn hc) m gio vin ch nhim lp K11 dy


trong hc k 1 nm 2006.

8.

Tm h tn lp trng ca cc lp m gio vin c tn Nguyen To Lan dy mn Co So


Du Lieu.

9.

In ra danh sch nhng mn hc (m mn hc, tn mn hc) phi hc lin trc mn Co So


Du Lieu.

10. Mn Cau Truc Roi Rac l mn bt buc phi hc lin trc nhng mn hc (m mn hc,
tn mn hc) no.
11. Tm h tn gio vin dy mn CTRR cho c hai lp K11 v K12 trong cng hc k 1
nm 2006.

Trang 12

Khoa H Thng Thng Tin - i hc Cng Ngh Thng Tin

C S D Liu Quan H

12. Tm nhng hc vin (m hc vin, h tn) thi khng t mn CSDL ln thi th 1 nhng
cha thi li mn ny.
13. Tm gio vin (m gio vin, h tn) khng c phn cng ging dy bt k mn hc no.
14. Tm gio vin (m gio vin, h tn) khng c phn cng ging dy bt k mn hc no
thuc khoa gio vin ph trch.
15. Tm h tn cc hc vin thuc lp K11 thi mt mn bt k qu 3 ln vn Khong dat
hoc thi ln th 2 mn CTRR c 5 im.
16. Tm h tn gio vin dy mn CTRR cho t nht hai lp trong cng mt hc k ca mt nm
hc.
17. Danh sch hc vin v im thi mn CSDL (ch ly im ca ln thi sau cng).
18. Danh sch hc vin v im thi mn Co So Du Lieu (ch ly im cao nht ca cc ln
thi).
19. Khoa no (m khoa, tn khoa) c thnh lp sm nht.
20. C bao nhiu gio vin c hc hm l GS hoc PGS.
21. Thng k c bao nhiu gio vin c hc v l CN, KS, Ths, TS, PTS trong mi
khoa.
22. Mi mn hc thng k s lng hc vin theo kt qu (t v khng t).
23. Tm gio vin (m gio vin, h tn) l gio vin ch nhim ca mt lp, ng thi dy cho
lp t nht mt mn hc.
24. Tm h tn lp trng ca lp c s s cao nht.
25. * Tm h tn nhng LOPTRG thi khng t qu 3 mn (mi mn u thi khng t tt c
cc ln thi).
26. Tm hc vin (m hc vin, h tn) c s mn t im 9,10 nhiu nht.
27. Trong tng lp, tm hc vin (m hc vin, h tn) c s mn t im 9,10 nhiu nht.
28. Trong tng hc k ca tng nm, mi gio vin phn cng dy bao nhiu mn hc, bao
nhiu lp.
29. Trong tng hc k ca tng nm, tm gio vin (m gio vin, h tn) ging dy nhiu nht.
30. Tm mn hc (m mn hc, tn mn hc) c nhiu hc vin thi khng t ( ln thi th 1)
nht.
31. Tm hc vin (m hc vin, h tn) thi mn no cng t (ch xt ln thi th 1).
32. * Tm hc vin (m hc vin, h tn) thi mn no cng t (ch xt ln thi sau cng).
33. * Tm hc vin (m hc vin, h tn) thi tt c cc mn u t (ch xt ln thi th 1).
34. * Tm hc vin (m hc vin, h tn) thi tt c cc mn u t (ch xt ln thi sau cng).
35. ** Tm hc vin (m hc vin, h tn) c im thi cao nht trong tng mn (ly im ln
thi sau cng).
Trang 13