First experience of mongodb, mongodb

Source: Internet
Author: User

First experience of mongodb, mongodb
Mongodb initial experience

A new workflow product needs to be developed after the start of the year. It is mainly used to manage the management process in the automotive industry. Because it is similar to the old product business last year, it also uses the same platform. The static data and business data on the old platform are based on hibernate and mysql. The ORM relationship is complex, so the related business code on the old platform becomes abnormal and complex. The RIA method is used, and ajax is used to request json data to complete the business process. Therefore, the database verification is complicated. At the same time, because mysql table structures are mostly associated with intermediate tables when dealing with relational ing, it is quite painful to process detailed forms of data reports, many tables need to be joined for processing, so it is very painful to write many HQL statements. So I decided to introduce mongodb, because mongodb is a file-type database, most like a relational database NOSQL database, and also a very extensive NOSQL database that has been used in the Internet field in recent years. Due to the characteristics of the system itself, the transaction requirements are not very high, so the choice of mongodb is also based on a more careful consideration. Because the system framework uses spring, mongodb uses spring-data-mongodb as the central price. Its usage is similar to that of hibernate. For the sake of prudence, we still store structured data, such as departments, personnel, permissions, and other data in mysql. for business data, such as metadata workflows, workflows, nodes, and forms, fields are stored in mongodb. At the design stage, we will use single DBRef Association. For sub-documents, we will save the parent document and the id of the parent document at the same time. This benefits will be reflected later. The framework quickly got up. Because the basic modules are already very well-developed and mainly used to process the Business Database, mongodb's advantages are immediately apparent. Because mongodb is document-type, therefore, fields are not restricted and can be seamlessly associated with java pojo. In the process of warehouse receiving and updating, you only need to verify and filter the character format. You do not need to consider the length and so on, so the code is much simpler. Objects are processed separately, and the corresponding processing of the association relationship is much simpler. The amount of code is reduced by at least 2/3, which reduces the maintenance response. The reason why the Sub-document saves the parent document and the grandfather Document ID is that when we maintain the data, we can use the parent ID to identify the active grandfather ID for maintenance, this is equivalent to flattening a hierarchical data, and the query efficiency is very high, especially when updating data. In addition, the query efficiency is also improved for report data. At present, our applications are still at a relatively low level of basic applications, but they have already reflected the inherent advantages of NOSQL databases. This greatly improves the development efficiency of our products and reduces maintenance costs.

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.