ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Lecture 03 Intro to Relational Model

2022-05-31 23:33:50  阅读:214  来源: 互联网

标签:name value Intro same attributes Lecture Model Operation must


Attribute

Attribute values are (normally) required to be atomic; that is, indivisible

The special value null is a member of every domain. Indicated that the value is “unknown”

The null value causes complications in the definition of many operations

 

Order of tuples is irrelevant (tuples may be stored in an arbitrary order)

Database schema -- is the logical structure of the database.

Database instance -- is a snapshot of the data in the database at a given instant in time.

schema:instructor (ID, name, dept_name, salary)

Instance:

 

 

Relational Query Languages:


Notation: σρ (r)

ρ is called the selection predicate

Defined as: σρ (r) = {t | t ∈ r and ρ(t)}

 

Project Operation:

 

where A1 , A2 are attribute names and r is a relation name

The result is defined as the relation of k columns obtained by erasing the columns that are not listed

 

Union Operation:

Notation: r ∪ s
Defined as: r ∪ s = {t | t ∈ r or t ∈ s}

For r ∪ s to be valid,

1. r, s must have the same arity (same number of attributes)

2. The attribute domains must be compatible (example: 2nd column of r deals with the same type of values as does the 2 nd column of s)

 

Set Difference Operation:

Notation r – s

Defined as: r – s = {t | t ∈ r and t ∉ s}

Set differences must be taken between compatible relations.

r and s must have the same arity
attribute domains of r and s must be compatible

 

Intersection Operation:

Notation: r ∩ s
Defined as: r ∩ s = {t | t ∈ r and t ∈ s}

For r ∩ s to be valid.

1. r, s must have the same arity (same number of attributes)

2. The attribute domains must be compatible (example: 2nd column of r deals with the same type of values as does the 2 nd column of s)

 

Cartesian-Product Operation:

Notation r x s
Defined as: r x s = {t q | t ∈ r and q ∈ s}

 

Assume that attributes of r(R) and s(S) are disjoint. (That is, R ∩ S = ∅).

If attributes of r(R) and s(S) are not disjoint, then renaming must be used.

 

 Example for renaming:

 

 

Renaming a Table:

Allows us to refer to a relation, (say E) by more than one name. ρ_x (E)

returns the expression E under the name X

 

Let r and s be relations on schemas R and S respectively.

Then, the “natural join” of relations R and S is a relation on schema R U S obtained as follows:

Consider each pair of tuples tr from r and ts from s.

If tr and ts have the same value on each of the attributes in R U S, add a tuple t to the result, where

 t has the same value as tr on r 

 t has the same value as ts on s

 

 

Each Query input is a table (or set of tables)
Each query output is a table.
All data in the output table appears in one of the input tables.

In summery,

 

 

标签:name,value,Intro,same,attributes,Lecture,Model,Operation,must
来源: https://www.cnblogs.com/M1stF0rest/p/16332741.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有