1. Entities
All kinds of data management objects, such as database tables, views, stored procedures, etc. , are the database entities in the database management system, which are convenient for data management. Broadly speaking, the data stored in these objects is also a database entity. Because they are also the exact entities that exist.
2. Entity Relationship (table design)
(1)1-to-1 relationship :
The same primary key field exists in two entity tables;
If the primary key value of the record is equal to the primary key value of the record in another relational table, the corresponding two record corresponds to a 1-to-1 relationship
Example:
Here the Student Master Information table and the Student Detail table should be connected horizontally, but here it is vertically divided, which is called vertical Segmentation
Usually there are too many record fields in a table, we usually split two or more, divided into common information tables and infrequently used information tables;
As long as these split multiple tables have a uniform primary key value ID, they are logically associative.
(2)1-to-many relationship :
An entity that corresponds to several other entities, such as a class that corresponds to multiple students:
Design scheme:
On multiple sides (this is where multiple students are), add a field ( class number ) that points to the identity of another entity to which the entity belongs;
(3) Many-to-many relationships :
Design Typically, an intermediate table is used to represent the correspondence between entities . Each record in the intermediate table represents a relationship.
can be analyzed: a m:n can be disassembled to 1:m 1:n to achieve :
MySQL (10): Entity and Entity tables