资源描述
Database Chapter Six Outline
Design Process
Conceptual-design •一 Chooses a data model, translates the requirements into a conceptual schema of databaseRedundancy
IncompletenessModeling
A database can be modeled as: a collection of entities, relationship among entities.
An entity is an object that exists and is distinguishable from other objects. Entities have attributes
An entity set is a set of entities of the same type that share the same properties.
Relationship Sets
A relationship is an association among several entities
A relationship set is a mathematical relation among n > 2 entities, each taken from entity sets{(ei, e2/... en) | ei e Ei, e2 e E2,en g En} where (ei, ei,en) is a relationship
The association between entity sets is referred to as participationThe entity sets El,E2,...,En participate in relationship set R
Relationship instance represents an association between the named entities in the real-world enterprise that is being modeledRole•一The function that an entity plays in a relationship
Recursive relationship set-一the same entity set participate in a relationship set more than once
Descriptive attribute -An attribute can also be property of a relationship set.
Degree-Refers to number of entity sets that participate in a relationship set.
Attributes
An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set.
Domain - the set of permitted values for each attribute
Attribute types:
Simple and composite attributes.
Single-valued and multi-valued attributes
► Example: multivalued attribute: phone_numbers Derived attributes► Can be computed from other attributes
Mapping Cardinality Constraints
Express the number of entities to which another entity can be associated via a relationship set.
For a binary relationship set the mapping cardinality must be one of the following types:
One to oneOne to many
Many to oneMany to many
E-R DiagramsRectangles represent entity sets.
Diamonds represent relationship sets.
Lines link attributes to entity sets and entity sets to relationship sets.
Ellipses represent attributesDouble ellipses represent multivalued attributes.
Dashed ellipses denote derived attributes.
Underline indicates primary key attributesRoles
Role labels are optional, and are used to clarify semantics of the relationshipWe express cardinality constraints by drawing either a directed line signifying “one," or an undirected line (一), signifying "many," between the relationship set and the entity set.
One-To-Many Relationship
In the one-to-many relationship a loan is associated with at most one customer via borrower, a customer is associated with several (including 0) loans via borrowerMany-To-One Relationships
In a many-to-one relationship a loan is associated with several (including 0) customers via borrower, a customer is associated with at most one loan via borrowerMany-To-Many Relationship
Participation of an Entity Set in a Relationship Set
Total participation (indicated by double line): every entity in the entity set participates in at least one relationship in the relationship set
Partial participation: some entities may not participate in any relationship in the relationship setDesign Issues
Use of entity sets vs. relationship setsPossible guideline is to designate a relationship set to describe an action that occurs between entities
May cause replicationBinary versus n-ary relationship sets
Although it is possible to replace any nonbinary (n-ary, for n > 2) relationship set by a number of distinct binary relationship sets, a n-ary relationship set shows more clearly that several entities participate in a single relationship.
Placement of relationship attributesFor 1-1, reposition to either
For l-m,or m-1, reposition to m sideConverting Non-Binary Relationships to Binary Form
Weak Entity SetsAn entity set that does not have a primary key is referred to as a weak entity set.
An entity set that does not have a primary key is referred to as a weak entity set. e.g. Employee and Family member, Contract and Attachment The existence of a weak entity set depends on the existence of a identifying entity set
it must relate to the identifying entity set via a total, one-to-many relationship set from the identifying to the weak entity set Identifying relationship depicted using a double diamondThe discriminator (or partial key) of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set.
标示性联系是从弱实体机到标识实体集的多对一关系,并且弱实体集全部参与。 弱实体集主码由标志实体集的主码并上弱实体集的分辨符。
Design Constraints on a Specialization/GeneralizationConstraint on which entities can be members of a given lower-level entity set.
condition-definedExample: all customers over 65 years are members of senior-citizen entity set; senior-citizen ISA person.•一attribute-defined
user-definedConstraint on whether or not entities may belong to more than one lower-level entity set within a single generalization.
Disjointan entity can belong to only one lower-level entity set
► Noted in E-R diagram by writing disjoint next to the ISA triangleOverlapping
► an entity can belong to more than one lower-level entity setCompleteness constraint - specifies whether or not an entity in the higher-level entity set must belong to at least one of the lower-level entity sets within a generalization.
total : an entity must belong to one of the lower-level entity sets. We use a double line to connect the box representing the higher-level entity set to the triangle symbol partial: an entity need not belong to one of the lower-level entity setsAggregation (Cont.)
Eliminate this redundancy via aggregationTreat relationship as an abstract entity
Allows relationships between relationshipsAbstraction of relationship into new entity
Summary of Symbols Used in E-R Notationentity set J
weak entity set J
entity set J
weak entity set J
relationship set
identifying relationship set for weak entity set J
primaty key
manv_to_manv JJ
relationship
one_to
_one relationship
role indicator
total
generalization
cardinality limits
ISA (specialization o generalization)
disjoint generalization
attribute multivalued attribute
derived attribuk
total participation of entity set J in relationship
discriminating attribute of weak entity set J
many-to-one relationship
Representing Entity Sets as Schemas
A strong entity set reduces to a schema with the same attributes.
A weak entity set becomes a table that includes a column for the primary key of the identifying strong entity setRepresenting Relationship Sets as Schemas
A binary many-to-many relationship set is represented as a schema with attributes for the primary keys of the two participating entity sets, and any descriptive attributes of the relationship set.
{ai,a2/-/3n} U {bi/b2/.../bn}参与联系的实体集的主码跟联系自身的属性。
Redundancy of Schemas 多对一时,可以将多的实体类跟联系集合并在成一个包含了两个模式所有属性 的并集的模式。
一对一时,联装集的关系模式可以跟参与联系的任何一个实体集的模式进行合 并。
般来讲,连接弱实体集与强实体集的联系是冗余的,可以忽略。
Representing Specialization via Schemas
n Method 1:
Form a schema for the higher-level entity
Form a schema for each lower-level entity set, include primary key of higher-level entity set and local attributes schema attributes person name, street, city customername, credit_ratingemployeename, salary
Drawback: gettinginformation about,anemployeerequiresaccessing two relations, the one correspondingtothe low-level
schema and the one corresponding to the high-level schemaSchemas Corresponding to Aggregation
To represent aggregation, create a schema containing primary key of the aggregated relationship, the primary key of the associated entity set any descriptive attributes
展开阅读全文