MySQL (10): Entity and Entity tables

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.