thiết kế dữ liệu

of 39/39
1 Chương 5: Chương 5: Thiết kế dữ liệu lưu trữ Thiết kế dữ liệu lưu trữ Trường Đại học Khoa học Tự nhiên, ĐHQG-HCM Khoa Công Nghệ Thông Tin Bộ môn Công Nghệ Phần Mềm GVLT: ThS. Trần Minh Triết

Post on 05-Jul-2015

1.903 views

Category:

Documents

7 download

Embed Size (px)

TRANSCRIPT

  • 1. Chng 5: Thit k d liu lu tr Trng i hc Khoa hc T nhin, HQG-HCM Khoa Cng Ngh Thng Tin B mn Cng Ngh Phn Mm GVLT: ThS. Trn Minh Trit

2. Ni dung

  • Lu tr d liu bng CSDL quan h
    • Mt s k thut nh x s lp sang s logic (t chc lu tr d liu bng CSDL quan h)
  • Lu tr d liu bng XML
    • Gii thiu s lc v XML
    • Cch lu tr d liu
  • So snh gia cch s dng lu tr bng XML, lu tr bng CSDL quan h, v kt hp c 2 cch.

3. Lu tr d liu bng CSDL quan h 4. Quy tc #1

  • Thng thng,mi lp i tng n ginc nh x thnhmt bng

V d? 5. Quy tc #2

  • Quan h 1-1

V d? A B 1 1 A B MA MA A B MB MB A B MA MB MB MA A B MA MA A B A B MB MB 6. Quy tc #3

  • Quan h 1-n

V d? A B 1 * A B MA MA 7. Quy tc #4

  • Quan h m-n

V d? A B *C * A C MA MB B MA MB 8. Quy tc #5

  • Quan h k tha

A B A( MA ,x, y , z) C B( MB ,x, y ,t, u ) C( MC ,x, y ,v )

  • + n gin
  • - Khng thy mi lin h gia cc loi i tng A, B, C
  • Kh thng k tng qut

V d? A + x # y - z B # t # u C -v 9. Quy tc #5

  • Quan h k tha

+ C c ci nhn tng qut v cc i tng- Lng ph khng gian lu tr A A( M , Loi, x, y, z, t, u, v) V d? A + x # y - z B # t # u C -v C B A v u t z y x Loi 10. Quy tc #5

  • Quan h k tha

Chung_A R_B Chung_A( M ,x, y ) R_C R_B( M ,t, u ) R_C( M ,v ) + Tit kim khng gian lu tr + Cho php c ci nhn tng qut - T chc kh phc tp R_A R_B( M , z) V d? A + x # y - z B # t # u C -v 11. Quy tc #6

  • Lp i tng c thuc tnh ccu trc phc tp
  • Tch thnh bng ph lu tr thuc tnh c cu trc phc tp

classA { B x; } Cu trc ca B gm: Thuc tnh 1 Thuc tnh 2 V d? A B MA MA ThuocTinh1 ThuocTinh2 12. Quy tc #7

  • Lp i tng cthuc tnh kiu mng
  • Tch thnh bng chi tit

classA { B []x; } V d? A B MA MA 13. Quy tc #8

  • Thuc tnh cgi tr ri rc :Tch thnh bng danh mc

V d? 14. Quy tc #9

  • Bng tham s
    • Dng 1

Mi tham stng ng vimt cttrong bng tham s Bng tham sthngch gm 1 dng(cha gi tr cc tham s hin hnh) ? Cn b sung tham s mi? Cn v hiu ha tc dng ca mt tham s? ThamS#N ThamS#2 ThamS#1 Kha 15. Quy tc #9

  • Bng tham s
    • Dng 2

Mi tham stng ng vimt dngtrong bng tham s Gi tr hin tica tham s c lu bngdng chui Mi tham s cnlu tr kiu gi tr phn mmhiu ng ni dung gi tr hin ti ca tham s ? Cn b sung tham s mi? Cn v hiu ha tc dng ca mt tham s? c lu dng chui TnhTrng GiTr Kiu TnThamS MThamS 16. Lu tr d liu bng XML Lc dch t slide chng 2 XMLtrong mn Managing XML and Semistructured Data ca GS. Dan Suciu, University of Washington Department of Computer Science & Engineering Ti liu gc: http://www.cs.washington.edu/homes/suciu/COURSES/590DS/02xmlsyntax.ppt 17. XML

  • Chun ca W3C
  • tng ban u:vn bnccu trc(SGML)
  • http://www.w3.org/TR/2000/REC-xml-20001006
  • (version 2, 10/2000)

18. HTML v XML HTML m t cch th hin 19. HTML

  • < h1 > Bibliography h1 >
  • < p > < i > Foundations of Databases i >
  • Abiteboul, Hull, Vianu

  • Addison Wesley, 1995
  • < p > < i > Data on the Web i >
  • Abiteoul, Buneman, Suciu
  • < br > Morgan Kaufmann, 1999

20.

  • < bibliography >
    • < book >
    • < title > Foundations title >
    • < author > Abiteboul author >
    • < author > Hull author >
    • < author > Vianu author >
    • < publisher > Addison Wesley publisher >
    • < year > 1995 year >
    • book >
  • bibliography >

XML XML m t ni dung 21. XML

  • < bibliography >
    • < book >
    • < title > Foundations title >
    • < author > Abiteboul author >
    • < author > Hull author >
    • < author > Vianu author >
    • < publisher > Addison Wesley publisher >
    • < year > 1995 year >
    • book >
  • bibliography >

Start tag End tag 22. XML

  • < bibliography >
    • < book >
    • < title > Foundations title >
    • < author > Abiteboul author >
    • < author > Hull author >
    • < author > Vianu author >
    • < publisher > Addison Wesley publisher >
    • < year > 1995 year >
    • book >
  • bibliography >

23. C bn v XML

  • tag:book ,title ,author ,
  • start tag: < book >,end tag: book >
  • element: < book >< book >,< author > author >
  • Cc element c th lng nhau
  • Element rng: < red > red > hay < red />
  • Mt ti liu XML: c 1root element

Ti liu XML c gi l well formed nu cctag bt uvtag kt thctng ng xut hiny vng v tr(k c vi cc tag lng nhau) 24. XML: Attribute

  • < book price= 55currency= USD>
  • < title > Foundations of Databases title >
  • < author > Abiteboul author >
  • < year > 1995 year >
  • book >

Attribute: cch khc biu din d liu(khng dng Element) 25. XML: Oid v Tham chiu

  • < person id =o555>< name > Jane name > person >
  • < person id =o456>< name > Mary name >
  • < children idref =o123 o555/>
  • person >
  • < person id =o123mother =o456>< name >John name >
  • person >

OID va tham chiu trong XML 26. Tham chiu n entity

  • C php: &entityname;
  • V d:< element > this is less than < element >
  • Mt s entity thng dng:

Unicode char & " ' & & > > < < 27. S dng Comment

28. XML Namespace

  • http://www.w3.org/TR/REC-xml-names (1/99)
  • name ::= [prefix:]localpart

< book xmlns:isbn =www.isbn-org.org/def> < title > title > < number > 15 number > < isbn:number > . isbn:number > book > 29. XML Namespace

  • C php: < number > , < isbn:number >

< tag xmlns:mystyle= http://> < mystyle:title > mystyle:title > < mystyle:number > tag > nh ngha ti 30. M hnh truy vn d liu XML

  • Node::=DocNode |ElemNode| ValueNode |AttrNode |NSNode| PINode| CommentNode | InfoItemNode |RefNode

31. M hnh truy vn d liu XML

  • Nt Element:
  • elemNode: ( QNameValue ,{ AttrNode}, [ElemNode|ValueNode ]) ElemNode
  • QNameValue= tn tag
  • {...} = tp hp gm
  • [...]= danh sch gm

32. M hnh truy vn d liu XML

  • V d

< book price= 55 currency= USD> < title > Foundations title > < author > Abiteboul author > < author > Hull author > < author > Vianu author > < year > 1995 year > book > book1=elemNode ( book , {price2, currency3}, [title4, author5,author6,author7, year8]) price2 =attrNode ()/* next */ currency3 =attrNode () title4 =elemNode ( title , string9) 33. M hnh truy vn d liu XML

  • Nt Attribute:
  • attrNode: ( QNameValue ,ValueNode ) AttrNode

34. M hnh truy vn d liu XML

  • V d

< book price= 55 currency= USD> < title > Foundations title > < author > Abiteboul author > < author > Hull author > < author > Vianu author > < year > 1995 year > book > price2 =attrNode ( price ,string10)string10 =valueNode ()/* next */ currency3 =attrNode ( currency , string11) string11 =valueNode () 35. M hnh truy vn d liu XML

  • Nt Value:
  • ValueNode=StringValue |BoolValue|FloatValue
  • stringValue : string StringValue
  • boolValue: booleanBoolValue
  • floatValue: floatFloatValue

36. M hnh truy vn d liu XML

  • V d

< book price= 55 currency= USD> < title > Foundations title > < author > Abiteboul author > < author > Hull author > < author > Vianu author > < year > 1995 year > book > price2 =attrNode ( price ,string10) string10 =valueNode (stringValue(55)) currency3 =attrNode ( currency , string11) string11 =valueNode (stringValue(USD)) title4 =elemNode ( title , string9) string9 =valueNode (stringValue(Foundations)) 37. Luyn tp

  • Lm quen vic s dng XML lu tr thng tin (thay cho c s d liu)
  • M rng:
    • Tm hiu cch khai bo XML Schema
    • Tm hiu v XQuery

38. So snh gia cch s dng lu tr bng CSDL v bng XML 39. So snh

  • S dng CSDL
  • u im
  • Khuyt im
  • Trng hp nn s dng
  • S dng XML
  • u im
  • Khuyt im
  • Trng hp nn s dng

Tho luntrc tip ti lp