How can Laravel's multi-to-Multi-link model be used in a distributed manner, such as using a user table on another server?

Source: Internet
Author: User
Tags node server
Recently I encountered a problem when working on an App background interface. Currently, the server where the article table is located is a separate node, and the user table is on another node server. Article Server article table Article Details table Article favorites link intermediate table user Server user performance... recently encountered a problem when working on an App background interface.
Currently, the server where the article table is located is a separate node, and the user table is on another node server.

Article Server
  • Article table

  • Document Details table

  • Add link intermediate tables to favorites

User Server
  • User table

The problem now is that the article Server accepts the user_id sent by the App client, and can only query by hand, and then combine the json response packet format to return the result. The laravel model is not easy to use.

Is there any way to use a model without a table?

Reply content:

Recently I encountered a problem when working on an App background interface.
Currently, the server where the article table is located is a separate node, and the user table is on another node server.

Article Server
  • Article table

  • Document Details table

  • Add link intermediate tables to favorites

User Server
  • User table

The problem now is that the article Server accepts the user_id sent by the App client, and can only query by hand, and then combine the json response packet format to return the result. The laravel model is not easy to use.

Is there any way to use a model without a table?

This is equivalent to a small distributed system. It is better to associate two servers in the form of interfaces or services.
There is no need to use many-to-many models. laravel's associated relational models cannot deal with these complex scenarios.
It cannot be considered that the model relationship is elegant. The decoupling and servitization between systems, and the interface is a more elegant implementation solution.

Another question is, if user_id is often used in your article table, why not add a redundant field of user_id in the article table?

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.