Home> Database> SQL> body text

MongoDB – Polymorphic schema built with schemas

步履不停
Release: 2019-07-01 18:02:05
Original
3611 people have browsed it

MongoDB – Polymorphic schema built with schemas

Brief description:

When all documents in a collection have a similar but not identical structure, we call it polymorphic pattern

Example:

In actual business, user posts need to be used. The general structure of the posts is the same, but the specific content needs to be displayed differently according to different post types. Therefore, it is more appropriate to use polymorphic mode at this time. A single query can get all posts and their contents, which improves performance. As shown below:

MongoDB – Polymorphic schema built with schemas

Summary:

Polymorphic mode is used when documents have more similarities than differences. Typical use cases for this pattern design are:

Single view application content management mobile application product catalog

The polymorphic pattern provides an easy-to-implement design that allows queries within a single collection . This is also the schema-less design of mongodb that provides a convenient data construction function.

For more technical articles related to SQL, please visit theSQL Tutorialcolumn to learn!

The above is the detailed content of MongoDB – Polymorphic schema built with schemas. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!