Database System concepts reading notes-entity-contact model bitsCN.com
Database System concepts reading notes-entity-contact model
Preface
To review the message system architecture I wrote, I need to reread the first three chapters of the database system concept. here I will take a simple note for you to review.
Basic concepts
The object-link (E-R) data model is based on an understanding of the real world: The world is composed of a group of basic objects called entities and the relationships between these objects. Three main concepts used in E-R data model are: Entity Set, link set and attribute.
Entity Set
An object is an "event" or "object" that can be different from other objects in the real world"
An entity set is an entity set with the same type and share the same properties (or attributes ).
An object is represented by a set of attributes. Attribute is the descriptive nature of each member in the entity set. Assigning an attribute to an object set indicates that the database stores similar information for each object in the object set, but each object has its own values for each attribute. Attribute type Division:
Simple and compliant attributes
Single-value and multi-value attributes
Derived attributes
Contact set
A link is an association between multiple entities.
A contact set is a set of the same type of contact. According to the norm, the contact set is the mathematical relationship between n (n> = 2) entity sets. These entity sets do not need to be different from each other. If E1, E2 ,..., if En is n entity sets, then the contact set R is {(e1, e2, e3 ,.., en) | e1 (-E1, e2 (-E2 ,..., A subset of en (-En}, where (e1, e2, e3 ,..., en) is a contact
Constraints
With an object set and a link set, constraints are generated naturally. the constraints describe the relationship between the object set and the object set. this relationship is now a link set. What we want to discuss is the ing base and participation constraints.
Ing base
Map the base or base ratio to specify the number of entities that can be associated with another object at the same time through one contact set
For the binary correlation set R between entity set A and entity set B, the ing base must be one of the following situations:
One-to-one
One-to-multiple
Many-to-one
Many-to-many
Participation constraint
If every entity in entity set E is involved in at least one contact in the contact set R, we call entity set E all involved in the contact set R.
If only some entities in entity set E are involved in the contact set R, we call entity set E part of it involved in the contact set R.
Code
We must have a method that can distinguish all objects in an entity set. In terms of concept, entities are different from each other. However, from the database point of view, their differences must be indicated by their attributes.
The concept of code allows us to differentiate entities. codes can also uniquely identify connections and distinguish them from each other.
Supercode: a set of one or more attributes. The combination of these attributes allows us to uniquely identify an object in an object set.
Candidate Code: any real subset cannot be called a supercode, that is, the smallest supercode.
Master Code: Candidate Code selected by the database designer
Design problems
The concepts of object sets and contact sets are not accurate. there are multiple ways to define a group of entities and their associations.
Entity Set or attribute
The phone number and name examples in the book clearly show which is the property and which is the entity set. pay attention to two common errors:
A common error is that the primary code of an object set is used as the attribute of another object set, instead of the link.
Another common error is that the primary code attribute of the related object set is used as the attribute of the contact set.
Entity Set or contact set
Two problems that may occur with the contact set:
Data is stored multiple times, wasting storage space
Updates may cause data to be inconsistent. that is, attributes with the same value in the two links have different values.
Binary and n-yuan contact sets
The n-element relationship can be decomposed into binary relationships, but the relationship description is inaccurate.
Entity-contact diagram
The E-R diagram includes the following components:
Rectangle: Entity Set
Elliptic: attribute
Diamond: Contact set
Line segment: connects an attribute to an object set or connects an object set to an attribute set.
Double elliptic: multi-value attributes
Virtual elliptic: Derived attributes
Double rectangle: weak entity set
Here is an example:
Postscript
Purely in order to review the E-R model and E-R graph painting, comparison of water, master can directly skip it!
BitsCN.com