Chapter4 The Relational Model

Chapter4 The Relational Model
4.2Terminology

An relational model is based on the mathematical concept of a relation,which is physically represented as a table.


4.2.1Relational Data Structure
we disscuss the structural part and relational integrity constraints of relation data model.in next chapter , we discuss the relational manipulation

operations.


Relation:  is a table with columns and rows.

Attribute  is a named column of a relation.


*in the relational model,relations are used to hold information about objects to be represented in the database.A relation is represented as two dimensional table in which the rows of the table correspond to individual records and table columns corresponds to attributes.


Domain: A domain is the set of the allowable values for one or more attributes.


Tuple : A tuple is a row of a relation.


Degree: The degree of a relation is the number of attributes it contains.


Cardinality: A collection of normalized relation with distinct relation names.


Relational database: A collection of normalized relations with distinct relation names.


4.2.2Mathematical Relations

The Cartesian product of these two sets, writen D1 x D2 , is(=) the set of all ordered pairs such that the first element is a member of D1 and the second element is a member of D2.


4.2.3Database Relations
Relation schema:A named relation defined by a set of attribute and domain name pairs.

Let A1,A2,...,An be attributes with domains D1,D2,...,Dn.Then the set{A1:D1,...,An:Dn} is a relation schema.


A relation R defined by a relation schema S is a schema S is a set of mappings from the attribute names to their corresponding domains.

Thus , relation R is a set of n-tuples: (A1:d1,...,,An:Dn) such that d1⇚D1,... dn⇚Dn


Each element in the n-tuple consists of an attribute and a value for that attribute. Normally,when we write out a relation as a table,we list the attribute names as column headings and write out the tuples as rows having the form(d1,...,dn),where each value is taken from the appropriate domain.
In this way,we can think of a relation in the relational model as any subset of

the cartesian prodect of the domains of the attributes.


A table is simply a physical representation of such a relation.

Relational database schema:A set of relation schema,each with a distinct name.


4.2.4Properites of Relations
A relation has the following properties:
• the relation has a name that is distinct from all other relation name in the relation schema.
Each cell of the relation contains exactly one atomic value.
Each attribute has a distinct name.
• The value of attribute from same domain.
• The order of attribute has no significance

• the order of tuples has no significance,theretically


Most of the properties specified for relations result from the properties of mathematical relations:
• When we derive the Cartesian product of sets with simple , each element in each tuple was single-value.
• In a relation , the possible value for a given position are determine by the set , or domain.
• In a set , no elements are repeated.
• Because a relation is a set,the order of elements has no significance.
4.2.5Relational Keys
We need to be able to identify one or more attributes(called relational key) that uniquely dentifies cach tuple in a relation.
Superkey:An attribute , or set of attributes that uniquely identifies a tuple within a relation.

Candidate key:A superkey such no proper subset is a superkey within the relation.


A candidate key K for relation R has two properties:
• uniqueness

• irreducibility


When a key consists of more than one attribute , we call it a composite key.

Primary key:The candidate key that is select to identify tuples uniquely within the relation.

The candidate key that are not selected to be the primary key are called alternate keys.

Foreign key:An attribute , or set of attribute , within one relation that matches the candidate key of some(possible the same) relation.

4.2.6 Representing Relation Database Schema

The common convention for representing a relation schema is to give the name of the relation followed the attribute names in parentless.Normally,the
primary key is underlined.
The conceptual model , or conceptual schema ,is the set of all such schema for the database.
4.3Integrity Constraints
4.3.1Nulls
Null Represents a value for an attribute that is currently unknown or is not applicable for this tuple....as a null is not a value but represents the absence
of a value.

4.3.2 Entity Integrity
Entity integrity:In a base relation,no attribute of a primary key can be null....By definition , a primary key is a minimal identifier that is used to identify
tuple uniquely.This means that no subset of the primary key is sufficient to provide unique identification. If we allow a null for any part of a primary

key,we are implying that not all the attributes are needed to distinguish between tuples,which contradicts the definition of the primary key.


4.3.3Referential Integrity
The second integrity rule applies to foreign keys.
Referential integrity:If a foreign key exist in a relation,either the foreign key value must match a candidate key value of some tuple in its home relation or
the foreign key value must be wholly null.
4.3.4General Constraints
General constraints: Additional rules specifies by the users or database administrators of a database the define or constrain some aspect of the
    enterprise.
4.4Views
view is a virtual or derived relatoin:a relation that does not necessarily exist in its own right,but may be dynamically derived from one or more base
relations.
4.4.1Terminology

Base relation:A named relation corresponding to an entity in the conceptual schema,whose tuple are physically stored in the database.


View:The dynamic result of one or more relational operations operating on the base relations to produce another relation.A view is a virtual relation that
does not necessarily exist in the database but can be produced upon request by a particular user,at the time of the request.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值