General principles of database four models

Source: Internet
Author: User

1. When do I use "main extension mode"?
There are not many objects, the attributes of each object are different, the properties of each object can be fully determined during the database design phase, and the individual extension objects have independent, relatively complex business processing requirements, with "main extension mode". The common attributes of each object are drawn out to be designed as "main Table", the remaining properties of each object are designed as the corresponding "extension table", and "Main Table" has a one-to-one relationship with each "extension table" respectively.

The main extended mode main extension mode, usually used to extract the common attributes of several similar objects to form a "common attribute table", the rest of the properties are formed by the "proprietary attribute table", and "public attribute table" and "proprietary attribute table" are "one to the other" relationship. The "proprietary attribute table" can be thought of as an extension of the "common attribute table", which together is a complete description of a particular object, hence the name "main extension mode".

The "Company Employees" table is the main table, the "buyer" table is an extension table, the two are "one-to-one" relationship, the two-table field together is the "buyer" the object of the complete description. Similarly, the "Company employees" table and the other 5 tables also constitute a "one-to-one" relationship.

2. When do I use "master-slave mode"?
The number of objects is not fixed; the properties of the objects are almost no different; The object's properties are fully determined during the database design phase, and the individual objects do not have separate business processing requirements, with master-slave mode. Create a one-to-many relationship with the main Table object by designing individual objects as records from tables.

such as forum procedures. A forum usually has a number of "plates", in each plate, you can publish a lot of new posts. At this time, "plate" and "POST" is the master-slave mode, the main table is "plate", from the table is "post", the two are "one-to-many" relationship.

3. When do I use the "Name value mode"?
The number of objects is very large, the properties between the objects are very different, the object properties can not be determined during the database design phase, or there are large changes when the system is running, and the individual objects do not have separate business processing requirements, with "Name value mode".

A name-value pattern, typically used to describe an object that is not fully deterministic during the system design phase, where the properties of these objects change greatly when the system is running, or if there are significant differences between the properties of multiple objects.

When designing with the name value pattern, if you have special handling of "other properties", such as statistical summarization, then this attribute name needs to be "hardcoded" in the program code, that is, the property name needs to be reflected in the program code, the property name can be recorded directly in the product other properties table, no longer required " Property Templates table.
When the system is running, if you need to maintain "product other properties", the program directly lists the "property name", and then fill in the "attribute value" to save, the system will be the corresponding Product ID, attribute name and the "attribute value" just completed in the "Product other properties", so that the relevant settings. In the future, if the requirements change, you only need to modify the corresponding program code, you do not have to modify the database design.

4. When to use "multi-mode"?
Two objects are one-to-many relationships, use multi-to-many mode.

General principles of database four models

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.