ch3-relational model.ppt

ch3-relational model

Chapter2 Relational Model Chapter 3: Relational Model Data model data model defines how the data is organized and manipulated in a database Data structure Operation on the data Constraint on the data Data model Hierachical model Network model Relational model Object relational model Semi-structure model Why study relation model Codd 1976 Simple data structure Table the most formal of all data models mathematical concept of a relation in set theory Widely used Basic Structure Each row of a relation can be referred to as tuple Each column of a relation has a name ? named columns of a relation are referred to as attributes Basic Structure The cardinality of a table T is the number of tuples in T, denoted by |T|. The arity, or degree, of a table is the number of columns or attributes. Basic Structure The set of allowed values for each attribute is called the domain of the attribute Domain- legal type and range of values of an attribute denoted by dom(Ai) Attribute: Age Domain: [0-100] Attribute: EmpName Domain: 50 alphabetic chars Attribute: Salary Domain: non-negative integer Relation Formally, given sets D1, D2, …. Dn a relation r is a subset of D1 x D2 x … x Dn D1×D2×?×Dn={(d1,d2,?,dn)|di∈Di, i=1,2,?,n} Thus, a relation is a set of n-tuples (a1, a2, …, an) where each ai ? Di 例如:D1=MAN={王兵,李平,张英}, D2=WOMAN={丁梅,吴芳} D3=CHILD={王一,李一,李二} 笛卡尔积可以表示为一个二维表,表中的每一行对应一个元组,每一列对应一个域 MAN WOMAN CHILD 王兵 丁梅 王一 王兵 丁梅 李一 王兵 丁梅 李二 王兵 吴芳 王一 王兵 吴芳 李一 王兵 吴芳 李二 李平 丁梅 王一 李平 丁梅 李一 李平 丁梅 李二 李平 吴芳 王一 李平 吴芳 李一 李平 吴芳 李二 例如:假设王兵的妻子是丁梅,他们的孩子是王一,李平的妻子是吴芳,他们的孩子是李一和李二,则取笛卡尔积的一个子集构造一个关系FAMILY Relation Schema A1, A2, …, An are attribute names R = (A1, A2, …, An ) is a relat

文档评论(0)

1亿VIP精品文档

相关文档