This presentation is the property of its rightful owner.
Sponsored Links
1 / 76

第二章 关系数据库 PowerPoint PPT Presentation


  • 64 Views
  • Uploaded on
  • Presentation posted in: General

第二章 关系数据库. 本章内容概述. 关系模型的基本概念 关系的码 关系代数 关系演算 关系代数表达式的优化. §2.1 关系模型概述. 关系数据库,是建立在关系数据模型基础上的数据库系统 关系模型又是基于数学方面的数据抽象理论 关系数据库,用数学的方法来处理数据库中的数据. § 2.1.1 关系数据模型的基本概念. 关系模型的组成: 数据结构 关系的操作 完整性约束. 数据结构: 关系模型中数据的逻辑结构是一张二维表 关系的操作: ( 1 )查询操作: A 选择 B 连接 C 除 D 并 E 交 F 差

Download Presentation

第二章 关系数据库

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


6472473


6472473


6472473

2.1


2 1 1

2.1.1


6472473

  • 1A B C D E F

    2A B C


6472473

  • SQLStructured Query Language


6472473

:(P37)

  • 1

  • 2

  • 3


2 1 2

2.1.2

D1, D2,,Dn

D1D2Dn={(d1,d2dn)|diDii=1, n}D1,

D2,,Dn

d1,d2, ,dnn(n-Tuple)

(Tuple)di(Component)diDi

DimiM


2 1 3

2.1.3

  • D1D2 DnD1, D2, ,DnR(D1, D2, , Dn )

  • RnDegree


6472473

  • , attributen n , Di(i=1, n) (Domain)


2 1 4

2.1.4


6472473

1


6472473

2

2


6472473

3


6472473

!

4


6472473

5


6472473

6


6472473

2.2 (


2 2 1

2.2.1()()

  • , (Candidate key),

  • , ,+ ,+


6472473

()


2 2 2

2.2.2()

F R , R ( ) F S Ks , F R (Foreign key), R (Referencing Relation), S (Referenced Relation) (Target Relation)


6472473

()


6472473

(R2)

(R1)


2 2 3

2.2.3

(Entity Integrity)

ARA

(1)

(2)


6472473

  • Referential Integrity

    ( )F R S Ks ( R S ), R F(F) S


6472473

  • "":,:,"",""""


6472473

,

O100 60


6472473

2.3


2 3 1

2.3.1

R(Al,A2, An)

R(U)R(A1,A2, An)

R A1,A2, An (i=1,2, n)

R(U,D,dom,F)


6472473

U D U dom F ,


6472473

( ), ,


6472473

,


2 3 2

2.3.2


6472473


6472473

2.4


2 4 1

2.4.1

:


6472473

  • (1) :

    ( ), ( ),( ), ( )

  • (2) :

    ( ), ( ), ( ), ( )

  • (3) :

    > (), (),<(), (),=(), ()

  • (4) :

    ( ), ( ), ( )


6472473

"" ( )


2 4 2

2.4.2

R S n( n ), ,


Union

Union

R S :

RS={t|tR V tS }

R S n

R S

2.1

2.1 RS

RS


Differrence

Differrence

R S :

R-S={t|tRtS }

:R S n

R S

2.2

2.2 RS

R - S


Intersection

Intersection

R S :

RS={t|tRtS }

: RS=R(R-S)

:R S n

R S

2.3

2.3 RS

RS


6472473

R

S

RS


6472473

R

S

RS


6472473

R

S

RS


6472473

n m R S,(n + m)

n R m S R Kl S K2 RS Kl K2 R S : RS={t1t2|t1Rt2S }


6472473

RS

R

S


2 4 3

2.4.3

1. (Selection)

R

:

F(R)={t|tRF(t)=''}

F ,,


6472473

SA=d(S),

S

A=d(S)

F(t)A=d


6472473

2. (Projection)

R R

A (R)={t[A]| tR}

A R


6472473

SA (S),

A (S)

S


6472473

3.(Join)

: RS={t1,t2|t1Rt2St1[A]t2[B]}

AB


6472473

A B R S ,R S R S ,AB ,R A S B


6472473

RS

R.B=S.B

R

S


6472473

  • ,

  • R S B, :

    RS={t1t2|t1Rt2St1[A]=t2[B]}


6472473

S T

T

S


6472473

4. (Division)

R(X,Y) S (Y,Z), ,X,Y, Z RYSY, R S ,P(X), PRX : X x Yx S Y ,:

RS ={t1[X]|t1RY(S)Yx}

Yx x R


6472473

,,R : Y X R ,X ,X Y ,X


6472473

W=PQ

Q

P


6472473

2.6STSCCD

2.1

Tsex=(T)3=(T)


6472473

  • 2.2

  • Tnum,Tname,Tsex,Ttitle(T)

  • 1,2,3,5(T)


6472473

  • 2.3.2

  • Snum,Sname(Ssex=Dnum=2(S))

  • 2.4.

  • Snum,Sname,Sphone(Cname=(SSCC))


6472473

  • 2.5.3

  • Snum,Sname,Score(Dnum=3Cname=(SSCC))


6472473

  • 2.6

  • SC

  • 1 (1=425(SCSC))


6472473

  • 2.7 13

  • Snum,Cnum(SC)Cnum(Cnum=1Cnum=3(C))

  • Snum(Cnum=1(SC))Snum(Cnum=3(SC))


6472473

  • 2.8. S002

  • Snum,Cnum(SC)Cnum(Snum=S002 (SC))


6472473


6472473


6472473

  • 2.1

  • 2.2

  • 2.3


6472473

  • 2.4

  • 2.5


6472473

2.6RS6

RS, R-S, S-R, RS,

RS, 3,2(S), B<5(R),

RS


6472473

R

S

6


6472473

  • 2.7

  • S(Sno,Sname,Ssex,Sage,Sdept,Sspecial)

  • C(Cno,Cname,Ccredit,Cdept,Cprecno,Tno)

  • T(Tno,Tname,Tsex,Tspecial)

  • SC(Sno,Cno,Grade)


6472473

  • Sno,SnameSsexSageSdeptSspecialCnoCnameCcreditCdeptCprecnoTnoTnameTsexTspecialGrade


6472473

  • 1

  • 2

  • 3

  • 4


6472473

  • 5

  • 6

  • 7


  • Login