Database Design Reference

Source: Internet
Author: User

First of all, let us understand the next e-r diagram, the E-r diagram is composed of entities, attributes, links.

For example:

One: After the system has been understood, in accordance with the principle of standardization to draw a e-r diagram.

Two: Look at the link in the picture.

For 1:1 and 1:n, in order to query the needs of data, such as the reference, in general, you can set a party from the table, the properties of the contact attribute to its properties, plus a foreign key, referring to the primary table primary key (if necessary, plus higher-level operation).

For m:n, in order to query the need, data reference, etc., there are usually 3 ways to refer to:

Method One: Let one of the tables as from the table, and also add a property to it as the primary key, the property in the contact attribute to its properties, and then add a foreign key, reference to the primary table primary key (if necessary, plus higher-level operation).

Method Two: Let the two tables and the attributes in the contact merge a table, and two tables each take a property to form the combined primary key.

Method Three: Let the contact form a third table, add two foreign keys, respectively, referring to the two tables of the primary key (if necessary, plus a higher-level operation), the third table of the primary key can be added to their own properties to form, can also be composed of the two foreign keys to form a combined primary key.

These three methods are based on the actual situation and are usually used in method three.

FOREIGN key: It is a constraint that if a field in a table is added to a foreign key constraint, then the table is added and modified as a value from the table, the foreign key field of the table, and the main table is referenced. Cascade operations are added, and the deletion of records in the primary table affects the table. A table can have more than one foreign key, and a primary key can also be added to a foreign key constraint. The tag used is FK (Foreigen Key).

Connection query: In the actual development, in order to get more comprehensive information, the general situation is based on the "foreign key = Primary Key" in the internal connection query and the outer join query (left outer connection (), right outer connection, full outer connection (fully)).

Redundancy: For the convenience of query, sometimes the master-slave, table redundancy some fields. The mark used is Yu.

View: a virtual table resulting from a connection query based on a base table. You can query the data through the view, without restriction, the view to modify the data, the corresponding base table will also change, the same base table modified data, views will change.

  

Database Design Reference

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.