You are on page 1of 24

i hc Cng Ngh Thng Tin

Mn: C S D Liu Thi lng: 45LT+30TH

Khoa HTTT-i hc CNTT

Ni dung
Bi 1: Cc khi nim ca mt h CSDL Bi 2: Cc m hnh CSDL Bi 3: M hnh d liu quan h (ca Codd) Bi 4: Ngn ng i s quan h Bi 5: Ngn ng SQL Bi 6: Ngn ng tn t Bi 7: Rng buc ton vn trong mt CSDL Bi 8: Ti u ha cu hi bng i s quan h
Khoa HTTT-i hc CNTT 2

Bi 1: Cc khi nim ca mt h CSDL

Khoa HTTT-i hc CNTT

Bi 1: Cc khi nim ca mt h CSDL


1. 2. 3. 4. 5. 6. Gii thiu H thng tp tin (File System) nh ngha mt CSDL Cc i tng s dng CSDL H qun tr CSDL Cc mc ca mt CSDL
Khoa HTTT-i hc CNTT 4

1. Gii thiu
Ti sao cn phi c mt c s d liu?

Khoa HTTT-i hc CNTT

2. H thng tp tin
L tp hp cc tp tin ring l phc v cho mt mc ch ca n v s dng. u im:

Trin khai ng dng nhanh Kh nng p ng nhanh chng, kp thi (v ch phc v cho mc ch hn hp) Trng lp d liu lng ph, d liu khng nht qun Chi ph cao Chia s d liu km
Khoa HTTT-i hc CNTT 6

Khuyt im:

3. C s d liu (1)
nh ngha:
C s d liu l mt h thng cc thng tin c cu trc, c lu tr trn cc thit b lu tr nhm tha mn yu cu khai thc thng tin ng thi ca nhiu ngi s dng hay nhiu chng trnh ng dng vi nhng mc ch khc nhau

Khoa HTTT-i hc CNTT

3. C s d liu (2)
u im:

Gim trng lp thng tin xung mc thp nht, m bo tnh nht qun v ton vn d liu. m bo d liu c truy xut theo nhiu cch khc nhau. Kh nng chia s thng tin cho nhiu ngi, nhiu ng dng khc nhau.

Khoa HTTT-i hc CNTT

3. C s d liu
Nhng vn cn gii quyt:

Tnh ch quyn d liu. Tnh bo mt v quyn khai thc thng tin ca ngi s dng Tranh chp d liu m bo d liu khi c s c

Khoa HTTT-i hc CNTT

4. Cc i tng s dng
Ngi s dng CSDL khng chuyn v lnh vc tin hc v CSDL -> cn cng c h c th khai thc CSDL khi cn. Chuyn vin tin hc xy dng cc ng dng phc v cho cc mc ch qun l Qun tr CSDL: t chc CSDL, bo mt, cp quyn, sao lu, phc hi d liu, gii quyt cc tranh chp d liu
Khoa HTTT-i hc CNTT 10

5. H qun tr c s d liu (1)


H qun tr c s d liu (DBMS DataBase Management System) l h thng cc phn mm h tr tch cc cho cc nh phn tch, thit k v khai thc CSDL. Cc DBMS thng dng: Visual FoxPro, Microsoft Access, SQL Server, DB2, Oracle hu ht cc DBMS hin nay u da trn m hnh quan h.

Khoa HTTT-i hc CNTT

11

5. H qun tr c s d liu (2)


Mt DBMS phi c:

Ngn ng giao tip gia ngi s dng v CSDL T in d liu (Data Dictionary) C bin php bo mt khi c yu cu C ch gii quyt tranh chp d liu C c ch sao lu (backup), phc hi (restore) m bo tnh c lp gia d liu v chng trnh

Khoa HTTT-i hc CNTT

12

5. H qun tr c s d liu (3)


Ngn ng giao tip: Ngn ng m t d liu (DDL Data Definition Language): cho php khai bo cu trc CSDL, cc mi lin h ca d liu, cc quy nh, rng buc d liu. Ngn ng thao tc d liu (DML Data Manipulation Language): cho php thc hin thao tc thm, xa, sa d liu. Ngn ng truy vn c cu trc (SQL Structured Query Language): cho php ngi khai thc s dng truy vn thng tin cn thit. Ngn ng qun l d liu (DCL Data Control Language) cho php thay i cu trc bng, khai bo bo mt, cp quyn cho ngi s dng.
Khoa HTTT-i hc CNTT 13

6. Cc mc biu din 1 CSDL


Mc trong: (mc vt l Physical) l mc lu tr CSDL (cn gii quyt vn g? D liu g? Lu tr nh th no? u? Cn cc ch mc g? Truy xut tun t hay ngu nhin. Dnh cho ngi qun tr v ngi s dng chuyn mn. Mc quan nim: (Conception hay Logical) cn phi lu tr bao nhiu loi d liu? l d liu g? mi quan h Mc ngoi: ca ngi s dng v cc chng trnh ng dng
Khoa HTTT-i hc CNTT 14

6. Cc mc biu din 1 CSDL


NSD1
Cu trc ngoi 1

Mi trng thc th gii thc


Mc quan nim hoc mc logic

NSD2

Cu trc ngoi 2 Cu trc ngoi n

Mc vt l Cu trc vt l

Chng trnh ng dng n


Khoa HTTT-i hc CNTT

CSDL
15

Bi 2: Cc m hnh d liu

Khoa HTTT-i hc CNTT

16

Ni dung
1. Gii thiu 2. M hnh d liu mng 3. M hnh thc th mi kt hp

Khoa HTTT-i hc CNTT

17

1. Gii thiu
M hnh d liu l s tru tng ha ca mi trng thc, biu din d liu mc quan nim. Gii thiu mt s m hnh nh:

M hnh d liu mng M hnh d liu phn cp M hnh d liu thc th mi kt hp M hnh d liu quan h M hnh d liu hng i tng
Khoa HTTT-i hc CNTT 18

2. M hnh d liu mng (1)


M hnh d liu mng (Network Data Model) cn gi tt l m hnh mng hoc m hnh li l m hnh c biu din bi mt th c hng.

Mu tin (record) Loi mu tin Loi lin h (set type) Bn s

Khoa HTTT-i hc CNTT

19

2. M hnh d liu mng (2)


Mu tin: m t 1 i tng trong th gii thc.
(NV001,Nguyen Lam,Nam,10/10/1970,Dong Nai)

Loi mu tin: l 1 tp cc mu tin c cng tnh cht. V d: NHANVIEN

K hiu:

NHANVIEN

CONGVIEC

Loi lin h: m t s lin kt gia 1 loi mu tin ch v 1 loi mu tin thnh vin

K hiu:
Tham gia
Khoa HTTT-i hc CNTT 20

2. M hnh d liu mng (3)


Bn s: ch ra s lng cc mu tin tham gia trong mi lin h

(1:1) (one-to-one): mi mu tin ca loi mu tin ch kt hp vi ng 1 mu tin ca loi mu tin thnh vin. (1:n) (one-to-many): mi mu tin ca loi mu tin ch kt hp vi 1 hay nhiu mu tin thnh vin. (n:1) (many-to-one): nhiu mu tin ca loi mu tin ch kt hp vi ng 1 mu tin ca loi mu tin thnh vin. (Recursive): mt loi mu tin ch cng c th ng thi l loi mu tin thnh vin vi chnh n. Loi lin h ny l quy
Khoa HTTT-i hc CNTT 21

2. M hnh d liu mng (4)


PHONG LYLICH

gm

1:n

1:1

NHANVIEN

1:n
CONGVIEC cng lm

qun l trc tip

n:1
Khoa HTTT-i hc CNTT 22

2. M hnh d liu mng (5)


M hnh d liu mng:

Tng i n gin D s dng Khng thch hp biu din CSDL c quy m ln Kh nng din t ng ngha km

Khoa HTTT-i hc CNTT

23

2. M hnh d liu mng (6)


Bi tp: Xy dng m hnh d liu mng cho c s d liu qun l bn hng trong mt siu th (gio vin m t hin trng, xc nh cc yu cu)

Khoa HTTT-i hc CNTT

24