SQL SERVER (3) drawing E-R diagram design database

1 Basic elements for drawing ER diagram The basic elements
    involved in the ER diagram are entities, attributes, codes, domains, connections, and attributes. The three elements of entities, attributes, and relationships are described in detail below.
  (1) Entity
  is an object that exists objectively and can be distinguished from each other. An entity can be either a person, an object, or an abstract concept. For example, a doctor, a driver, and a book can be considered as an entity. Entities of the same type can constitute an Entity Set. For example, all drivers of a fleet can constitute an Entity Set. The entity in the ER diagram is generally represented by a rectangular frame, and the name of the entity is written in the rectangular frame, for example, an entity representing a driver, as shown in Figure 1.1.

Figure 1.1 Representation of the driver entity

  (2) Attribute An attribute
  possessed by an entity can be called an attribute, and an entity can be composed of several attributes. In the ER diagram, it is generally represented by an ellipse, and it is connected to the corresponding entity with an undirected edge. Information such as the price of the book, the name, author, and publisher can be called attributes. For example, add five attributes of name, age, gender, driving age, and fleet to the driver entity shown in Figure 1.1, as shown in Figure 1.2.


  (3) Relationship (Relationship)
  refers to the connection within or between entities in the information world. Relationships are divided into internal relationships between entities and relationships between entities. The intra-entity relationship usually refers to the relationship between the attributes that make up the entity; the relationship between the entities usually refers to the relationship between different sets of entities. The connection is represented by a diamond-shaped box in the ER diagram. The connection name is written in the diamond-shaped box, and connected to the relevant entities with undirected edges, and the type of relationship is marked beside the undirected edge. There are three types of relationships between entities, one-to-one, one-to-many, and many-to-many, which are reflected in the ER diagram as the corresponding relationship types, namely 1: 1, 1: N, M: N.

2. ER diagram drawing example
    Draw an ER diagram of a student elective system. In the student elective system, four entities of students, courses, majors, and teachers can be analyzed. The attribute graph of each entity is drawn below and an overall ER is drawn at the end Figure.
    (1). Student entity attribute map
    Student entities mainly include student ID, name, age, gender, ID card number, contact information, and major 7 attributes. The entity attribute map is shown in Figure 1.6.

   (2). Course entity attribute graph
    Course entity mainly includes six attributes: course number, course name, lecture time, lecturer, major, and course description. The entity attribute graph is shown in Figure 1.7.

(3). Professional entity attribute diagram
  Professional entity mainly includes two attributes: professional number and professional name. The entity attribute diagram is shown in Figure 1.8.

    (4). Teacher entity attribute map
    Teacher entity mainly includes seven attributes of teacher number, name, age, gender, major, professional title, and contact information. The entity attribute map is shown in Figure 1.9.

    5.
    Before drawing the overall ER diagram of the student's course selection system ER diagram , we must understand the process of the student's course selection system. The specific process is for students to view all the course information, view their professional courses and the teachers of each course. Then the student selects the courses to be selected according to the needs, and finally saves the courses selected by the student in the student elective information table. Among the above four entities are:

  • The relationship between students and courses is a many-to-many relationship. One course can be selected by multiple students. At the same time, one student can also take multiple courses, but the courses cannot be repeated.
  • The relationship between teachers and courses is a many-to-many relationship. One course can be taught by multiple teachers, and at the same time, one teacher can also teach multiple courses. For example, different majors can set up computer basic courses, so all the computer basic courses can be taught by the same teacher or different teachers. Similarly, a computer teacher can teach computer basic courses and other computer courses. .
  • The relationship between courses and majors is a many-to-many relationship. A major course is composed of multiple courses. Each course, especially a public course, can belong to multiple majors. For example, computer basic courses can be offered by multiple majors.
  • The relationship between students and majors is a many-to-one relationship. A student can only belong to one major, and a major can be composed of multiple students.

Published 146 original articles · praised 0 · visits 2714

Guess you like

Origin blog.csdn.net/ngbshzhn/article/details/105667582