A E-R diagram is an entity-contact diagram that provides methods to represent the entity, attributes, and associations to describe the conceptual models of the real world.
Constitute E-RThe basic elements of a graph are the real shape, attributes, and connections,The representation is as follows:
Solid shape(Entity):It is represented by a rectangle, and the entity name is indicated in the rectangle. For example, both student Zhang 3 and student LI 4 are entities.
Attribute(Attribute):It is represented by an elliptical shape and connected to the corresponding entity with an undirected edge. For example, the student's name, student ID, and gender are attributes.
Contact(Relationship):It is represented by a diamond. The contact name is specified in the diamond box, and the contact type is connected with the relevant entities by the undirected edge (1
: 1, 1: N or m
: N ).
For example, a teacher, a class is an entity, a name, a teacher number, and a gender is the attributes of a teacher, a class number, a good professional, and a college number is the attributes of a class; management is the connection between teachers and classes. The E-R diagram is as follows:
Rules for converting a E-R diagram to a link
Entity ConversionA real shape is converted into a relational model. The object name becomes the relational name, and the object property becomes the link property. The entity code is the link code.
Contact Conversion1. A contact can be converted into an independent link mode, or merged with the link mode corresponding to any end of the contact. 2. if it is converted to an independent link mode, the codes and attributes of each object connected to the link are converted to the attributes of the new link, each entity's code is a candidate code for this relationship; 3. if you merge the link mode corresponding to a certain object in the link mode, you must add the code of another link mode and the attributes of the link.
.4. A 1: N contact can be converted into an independent link mode, or merged with the link mode corresponding to n. 5. if it is converted to an independent link mode, the codes of the entities connected to the link and the attributes of the link itself are converted to the attributes of the new link mode, the code of the N-side object becomes the code of the new link; 6. if you merge the Relationship Mode corresponding to the n-end object, add the code of the 1-end link and the attributes of the link to the link mode corresponding to the n-end object, at this time, the code of the link mode corresponding to the n-end object remains unchanged. For M: N connections, convert them into an independent relational mode. The codes and attributes of each object connected to this link are converted into new attributes, and the codes of the new link mode are the codes of each object.